org.apache.flink.runtime.state.gemini.engine.page.DataPageAbstractSubPage Maven / Gradle / Ivy
/*
* 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.exceptions.GeminiRuntimeException;
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.vm.HitRecord;
import java.util.Map;
import java.util.Set;
/**
* DataPageAbstractSubPage.
*/
public abstract class DataPageAbstractSubPage implements DataPage {
protected final HitRecord hitRecord = new HitRecord();
//chainIndex is changable
protected volatile short chainIndex = 0;
@Override
public abstract int getSize();
@Override
public abstract int getCheckSum();
@Override
public abstract GBinaryHashMap getGBinaryHashMap();
@Override
public abstract void retain();
@Override
public abstract void release();
@Override
public abstract void close();
@Override
public BinaryValue getBinaryValue(K key) {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public GSValue get(K key) {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public boolean contains(K key) {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public long getVersion() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public DataPageType getDataPageType() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public int getCount() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public Map> getPOJOMap() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public Set getPOJOSet() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public Tuple2 split(
PageIndexContext indexContext, int curBucketNum, int curIndex, Allocator allocator, GCompressAlgorithm gCompressAlgorithm, GRegionContext gRegionContext) {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public long getCompactionCount() {
throw new GeminiRuntimeException("Sub Page doesn't support this method");
}
@Override
public void setChainIndex(int index) {
this.chainIndex = (short) index;
}
@Override
public int getChainIndex() {
return this.chainIndex;
}
@Override
public void addRequestCount(long tickTime, int requestCount) {
hitRecord.addRequestCount(tickTime, requestCount);
}
@Override
public double score(long tickTime) {
return hitRecord.score(tickTime, getSize(), getChainIndex());
}
@Override
public long getRequestCount(long tickTime) {
return hitRecord.getRequestCount(tickTime);
}
}