Class SplitHelper


  • @API(INTERNAL)
    public class SplitHelper
    extends Object
    Helper classes for splitting records across multiple key-value pairs.
    • 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 transaction
        subspace - subspace to save in
        key - key within subspace
        serialized - serialized representation
        version - 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 transaction
        subspace - subspace to save in
        key - key within subspace
        serialized - serialized representation
        version - the version to store inline with this record
        splitLongRecords - true if multiple keys should be used; if false, serialized must fit in a single key
        omitUnsplitSuffix - if splitLongRecords is false, then this will omit a suffix added to the end of the key if true for backwards-compatibility reasons
        clearBasedOnPreviousSizeInfo - if splitLongRecords, whether to use previousSizeInfo to determine how much to clear
        previousSizeInfo - if clearBasedOnPreviousSizeInfo, the FDBStoredSizes for any old record, or null if there was no old record
        sizeInfo - optional size information to populate
      • 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 transaction
        context - transaction context
        subspace - subspace containing serialized value
        key - key within subspace
        splitLongRecords - true if multiple keys should be used; if false, serialized must fit in a single key
        missingUnsplitRecordSuffix - if splitLongRecords is false and this is true, 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 transaction
        subspace - subspace to delete from
        key - primary key of the record to delete within subspace
        splitLongRecords - true if multiple keys should be used; if false, serialized must fit in a single key
        missingUnsplitRecordSuffix - if splitLongRecords is false and this is true, this will assume keys are missing a suffix for backwards compatibility reasons
        clearBasedOnPreviousSizeInfo - if splitLongRecords, whether to use previousSizeInfo to determine how much to clear
        previousSizeInfo - if clearBasedOnPreviousSizeInfo, the FDBStoredSizes for any old record, or null if there was no old record