All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.runtime.state.gemini.engine.page.DataPage Maven / Gradle / Ivy

There is a newer version: 1.5.1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.runtime.state.gemini.engine.page;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.runtime.state.gemini.engine.GRegionContext;
import org.apache.flink.runtime.state.gemini.engine.memstore.GSValue;
import org.apache.flink.runtime.state.gemini.engine.page.bmap.BinaryValue;
import org.apache.flink.runtime.state.gemini.engine.page.bmap.GBinaryHashMap;
import org.apache.flink.runtime.state.gemini.engine.page.compress.GCompressAlgorithm;
import org.apache.flink.runtime.state.gemini.engine.rm.Allocator;
import org.apache.flink.runtime.state.gemini.engine.rm.ReferenceCountable;
import org.apache.flink.runtime.state.gemini.engine.vm.EvictablePage;

import java.util.Map;
import java.util.Set;

/**
 * DataPage which contains the actual value.
 */
public interface DataPage extends EvictablePage, ReferenceCountable, AutoCloseable {

	/**
	 * Returns the checksum of this data page.
	 *
	 * @return The checksum of this data page.
	 */
	int getCheckSum();

	/**
	 * DataPageType.
	 */
	enum DataPageType {//KV
		KV((byte) 1),
		KHashMap((byte) 2),
		KSortedMap((byte) 3),
		KList((byte) 4),
		KSplitHashRouting((byte) 5),
		KSplitSortedRouting((byte) 6),
		COMPRESS_HEADER((byte) 127);

		private final byte code;

		DataPageType(final byte c) {
			this.code = c;
		}

		public byte getCode() {
			return this.code;
		}

		public boolean isKMapType() {
			return this.code == KHashMap.code || this.code == KSortedMap.code;
		}

		public static DataPageType valueOf(byte pageType) {
			switch (pageType) {
				case 1:
					return KV;
				case 2:
					return KHashMap;
				case 3:
					return KSortedMap;
				case 4:
					return KList;
				case 5:
					return KSplitHashRouting;
				case 6:
					return KSplitSortedRouting;
				default:
					throw new IllegalArgumentException("Unknown PageType: " + pageType);
			}
		}
	}

	BinaryValue getBinaryValue(K key);

	GSValue get(K key);

	boolean contains(K key);

	long getVersion();

	DataPageType getDataPageType();

	int getSize();

	int getCount();

	Map> getPOJOMap();

	Set getPOJOSet();

	Tuple2 split(
		PageIndexContext indexContext, int curBucketNum, int curIndex, Allocator allocator, GCompressAlgorithm gCompressAlgorithm, GRegionContext gRegionContext);

	long getCompactionCount();

	GBinaryHashMap getGBinaryHashMap();

	void setChainIndex(int index);

	int getChainIndex();

	@Override
	void close();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy