Package org.apache.flink.state.forst
Class ForStIncrementalCheckpointUtils
- java.lang.Object
-
- org.apache.flink.state.forst.ForStIncrementalCheckpointUtils
-
public class ForStIncrementalCheckpointUtils extends Object
Utils for RocksDB Incremental Checkpoint.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForStIncrementalCheckpointUtils.RangeCheckResultHelper class that represents the result of a range check of the actual keys in a RocksDB instance against the proclaimed key-group range of the instance.
-
Constructor Summary
Constructors Constructor Description ForStIncrementalCheckpointUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanbeforeThePrefixBytes(byte[] bytes, byte[] prefixBytes)check whether the bytes is before prefixBytes in the character order.static ForStIncrementalCheckpointUtils.RangeCheckResultcheckSstDataAgainstKeyGroupRange(org.forstdb.RocksDB db, int keyGroupPrefixBytes, org.apache.flink.runtime.state.KeyGroupRange dbExpectedKeyGroupRange)Checks data in the SST files of the given DB for keys that exceed either the lower and upper bound of the proclaimed key-groups range of the DB.static voidclipDBWithKeyGroupRange(org.forstdb.RocksDB db, List<org.forstdb.ColumnFamilyHandle> columnFamilyHandles, org.apache.flink.runtime.state.KeyGroupRange targetKeyGroupRange, org.apache.flink.runtime.state.KeyGroupRange currentKeyGroupRange, int keyGroupPrefixBytes, boolean useDeleteFilesInRange)The method to clip the db instance according to the target key group range using theRocksDB.delete(ColumnFamilyHandle, byte[]).static <T extends org.apache.flink.runtime.state.KeyedStateHandle>
intfindTheBestStateHandleForInitial(List<T> restoreStateHandles, org.apache.flink.runtime.state.KeyGroupRange targetKeyGroupRange, double overlapFractionThreshold)Choose the best state handle according to thestateHandleEvaluator(KeyedStateHandle, KeyGroupRange, double)to init the initial db from the given lists and returns its index.
-
-
-
Method Detail
-
clipDBWithKeyGroupRange
public static void clipDBWithKeyGroupRange(@Nonnull org.forstdb.RocksDB db, @Nonnull List<org.forstdb.ColumnFamilyHandle> columnFamilyHandles, @Nonnull org.apache.flink.runtime.state.KeyGroupRange targetKeyGroupRange, @Nonnull org.apache.flink.runtime.state.KeyGroupRange currentKeyGroupRange, @Nonnegative int keyGroupPrefixBytes, boolean useDeleteFilesInRange) throws org.forstdb.RocksDBExceptionThe method to clip the db instance according to the target key group range using theRocksDB.delete(ColumnFamilyHandle, byte[]).- Parameters:
db- the RocksDB instance to be clipped.columnFamilyHandles- the column families in the db instance.targetKeyGroupRange- the target key group range.currentKeyGroupRange- the key group range of the db instance.keyGroupPrefixBytes- Number of bytes required to prefix the key groups.useDeleteFilesInRange- whether to call db.deleteFilesInRanges for the deleted ranges.- Throws:
org.forstdb.RocksDBException
-
checkSstDataAgainstKeyGroupRange
public static ForStIncrementalCheckpointUtils.RangeCheckResult checkSstDataAgainstKeyGroupRange(org.forstdb.RocksDB db, int keyGroupPrefixBytes, org.apache.flink.runtime.state.KeyGroupRange dbExpectedKeyGroupRange)
Checks data in the SST files of the given DB for keys that exceed either the lower and upper bound of the proclaimed key-groups range of the DB.- Parameters:
db- the DB to check.keyGroupPrefixBytes- the number of bytes used to serialize the key-group prefix of keys in the DB.dbExpectedKeyGroupRange- the expected key-groups range of the DB.- Returns:
- the check result with detailed info about lower and upper bound violations.
-
beforeThePrefixBytes
public static boolean beforeThePrefixBytes(@Nonnull byte[] bytes, @Nonnull byte[] prefixBytes)check whether the bytes is before prefixBytes in the character order.
-
findTheBestStateHandleForInitial
public static <T extends org.apache.flink.runtime.state.KeyedStateHandle> int findTheBestStateHandleForInitial(@Nonnull List<T> restoreStateHandles, @Nonnull org.apache.flink.runtime.state.KeyGroupRange targetKeyGroupRange, double overlapFractionThreshold)Choose the best state handle according to thestateHandleEvaluator(KeyedStateHandle, KeyGroupRange, double)to init the initial db from the given lists and returns its index.- Type Parameters:
T- the generic parameter type of the state handles.- Parameters:
restoreStateHandles- The candidate state handles.targetKeyGroupRange- The target key group range.overlapFractionThreshold- configured threshold for overlap.- Returns:
- the index of the best candidate handle in the list or -1 if the list was empty.
-
-