Class SplitHelper
- java.lang.Object
-
- com.apple.foundationdb.record.provider.foundationdb.SplitHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SplitHelper.FoundSplitWithoutStartException
Exception thrown when only part of a split record is found.static class
SplitHelper.KeyValueUnsplitter
This cursor may exceed out-of-band limits in order to ensure that it only ever stops in between (split) records.static class
SplitHelper.SingleKeyUnsplitter
Unsplit a single record from a given range scan.static class
SplitHelper.SizeInfo
Accumulator for key-value sizes while loading / saving split records.
-
Field Summary
Fields Modifier and Type Field Description static long
RECORD_VERSION
Special split point added to end of the key when a record is associated with a version.static int
SPLIT_RECORD_SIZE
If a record is greater than this size (in bytes), it will be split into multiple kv pairs.static long
START_SPLIT_RECORD
Minimum index used when a record is split.static long
UNSPLIT_RECORD
Value added to the end of the key when a record is not split.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
deleteSplit(FDBRecordContext context, Subspace subspace, Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix, boolean clearBasedOnPreviousSizeInfo, FDBStoredSizes previousSizeInfo)
Delete the serialized representation of a record.static CompletableFuture<Boolean>
keyExists(ReadTransaction tr, FDBTransactionContext context, Subspace subspace, Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix)
Checks to see if a given key exists.static CompletableFuture<com.apple.foundationdb.record.provider.foundationdb.FDBRawRecord>
loadWithSplit(ReadTransaction tr, FDBRecordContext context, Subspace subspace, Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix, SplitHelper.SizeInfo sizeInfo)
Load serialized byte array that may be split among several keys.static void
saveWithSplit(FDBRecordContext context, Subspace subspace, Tuple key, byte[] serialized, FDBRecordVersion version)
Save serialized representation using multiple keys if necessary.static void
saveWithSplit(FDBRecordContext context, Subspace subspace, Tuple key, byte[] serialized, FDBRecordVersion version, boolean splitLongRecords, boolean omitUnsplitSuffix, boolean clearBasedOnPreviousSizeInfo, FDBStoredSizes previousSizeInfo, SplitHelper.SizeInfo sizeInfo)
Save serialized representation using multiple keys if necessary, clearing only as much as needed.static Tuple
unpackKey(Subspace subspace, KeyValue kv)
-
-
-
Field Detail
-
SPLIT_RECORD_SIZE
public static final int SPLIT_RECORD_SIZE
If a record is greater than this size (in bytes), it will be split into multiple kv pairs.- See Also:
- Constant Field Values
-
RECORD_VERSION
public static final long RECORD_VERSION
Special split point added to end of the key when a record is associated with a version.- See Also:
- Constant Field Values
-
UNSPLIT_RECORD
public static final long UNSPLIT_RECORD
Value added to the end of the key when a record is not split.- See Also:
- Constant Field Values
-
START_SPLIT_RECORD
public static final long START_SPLIT_RECORD
Minimum index used when a record is split. The index is appended to the key, one for each split portion.- See Also:
- Constant Field Values
-
-
Method Detail
-
saveWithSplit
public static void saveWithSplit(@Nonnull FDBRecordContext context, @Nonnull Subspace subspace, @Nonnull Tuple key, @Nonnull byte[] serialized, @Nullable FDBRecordVersion version)
Save serialized representation using multiple keys if necessary.- Parameters:
context
- write transactionsubspace
- subspace to save inkey
- key within subspaceserialized
- serialized representationversion
- the version to store inline with this record
-
saveWithSplit
public static void saveWithSplit(@Nonnull FDBRecordContext context, @Nonnull Subspace subspace, @Nonnull Tuple key, @Nonnull byte[] serialized, @Nullable FDBRecordVersion version, boolean splitLongRecords, boolean omitUnsplitSuffix, boolean clearBasedOnPreviousSizeInfo, @Nullable FDBStoredSizes previousSizeInfo, @Nullable SplitHelper.SizeInfo sizeInfo)
Save serialized representation using multiple keys if necessary, clearing only as much as needed.- Parameters:
context
- write transactionsubspace
- subspace to save inkey
- key within subspaceserialized
- serialized representationversion
- the version to store inline with this recordsplitLongRecords
-true
if multiple keys should be used; iffalse
,serialized
must fit in a single keyomitUnsplitSuffix
- ifsplitLongRecords
isfalse
, then this will omit a suffix added to the end of the key iftrue
for backwards-compatibility reasonsclearBasedOnPreviousSizeInfo
- ifsplitLongRecords
, whether to usepreviousSizeInfo
to determine how much to clearpreviousSizeInfo
- ifclearBasedOnPreviousSizeInfo
, theFDBStoredSizes
for any old record, ornull
if there was no old recordsizeInfo
- optional size information to populate
-
loadWithSplit
public static CompletableFuture<com.apple.foundationdb.record.provider.foundationdb.FDBRawRecord> loadWithSplit(@Nonnull ReadTransaction tr, @Nonnull FDBRecordContext context, @Nonnull Subspace subspace, @Nonnull Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix, @Nullable SplitHelper.SizeInfo sizeInfo)
Load serialized byte array that may be split among several keys.- Parameters:
tr
- read transactioncontext
- transaction contextsubspace
- subspace containing serialized valuekey
- key within subspacesplitLongRecords
-true
if multiple keys should be used; iffalse
,serialized
must fit in a single keymissingUnsplitRecordSuffix
- ifsplitLongRecords
isfalse
and this istrue
, this will assume keys are missing a suffix for backwards compatibility reasonssizeInfo
- optional size information to populate- Returns:
- the merged byte array
-
keyExists
public static CompletableFuture<Boolean> keyExists(@Nonnull ReadTransaction tr, @Nonnull FDBTransactionContext context, @Nonnull Subspace subspace, @Nonnull Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix)
Checks to see if a given key exists.- Parameters:
tr
- read transactioncontext
- transaction contextsubspace
- subspace containing serialized valuekey
- key within subspacesplitLongRecords
-true
if multiple keys should be used; iffalse
,serialized
must fit in a single keymissingUnsplitRecordSuffix
- ifsplitLongRecords
isfalse
and this istrue
, this will assume keys are missing a suffix for backwards compatibility reasons- Returns:
true
if the provided key exists, false otherwise.
-
deleteSplit
public static void deleteSplit(@Nonnull FDBRecordContext context, @Nonnull Subspace subspace, @Nonnull Tuple key, boolean splitLongRecords, boolean missingUnsplitRecordSuffix, boolean clearBasedOnPreviousSizeInfo, @Nullable FDBStoredSizes previousSizeInfo)
Delete the serialized representation of a record. This possibly requires deleting multiple keys, but this method makes an effort to clear only as much as needed.- Parameters:
context
- write transactionsubspace
- subspace to delete fromkey
- primary key of the record to delete withinsubspace
splitLongRecords
-true
if multiple keys should be used; iffalse
,serialized
must fit in a single keymissingUnsplitRecordSuffix
- ifsplitLongRecords
isfalse
and this istrue
, this will assume keys are missing a suffix for backwards compatibility reasonsclearBasedOnPreviousSizeInfo
- ifsplitLongRecords
, whether to usepreviousSizeInfo
to determine how much to clearpreviousSizeInfo
- ifclearBasedOnPreviousSizeInfo
, theFDBStoredSizes
for any old record, ornull
if there was no old record
-
-