Class SplitKeyUtils


  • public class SplitKeyUtils
    extends Object
    Utility class to deal split keys and split key ranges.
    • Constructor Detail

      • SplitKeyUtils

        public SplitKeyUtils()
    • Method Detail

      • splitKeyRangeContains

        public static boolean splitKeyRangeContains​(Object[] key,
                                                    Object[] splitKeyStart,
                                                    Object[] splitKeyEnd)
        Returns the specific key contains in the split key range or not.
      • getSplitKey

        public static Object[] getSplitKey​(org.apache.flink.table.types.logical.RowType splitBoundaryType,
                                           io.debezium.util.SchemaNameAdjuster nameAdjuster,
                                           org.apache.kafka.connect.data.Struct target)
      • sortFinishedSplitInfos

        public static void sortFinishedSplitInfos​(List<FinishedSnapshotSplitInfo> splits)
        Sorts the list of FinishedSnapshotSplitInfo by splitStart in ascending order. This is required for binary search to work correctly.

        Handles special cases: - Splits with null splitStart are considered as MIN value (sorted to front) - Splits with null splitEnd are considered as MAX value (sorted to back)

        NOTE: Current implementation assumes single-field split keys (as indicated by getSplitKey()). If multi-field split keys are supported in the future, the comparison logic should be reviewed to ensure consistency with splitKeyRangeContains(Object[],Object[],Object[]).

        Parameters:
        splits - List of splits to be sorted (sorted in-place)
      • findSplitByKeyBinary

        public static FinishedSnapshotSplitInfo findSplitByKeyBinary​(List<FinishedSnapshotSplitInfo> sortedSplits,
                                                                     Object[] key)
        Uses binary search to find the split containing the specified key in a sorted split list.

        IMPORTANT: The splits list MUST be sorted by splitStart before calling this method. Use sortFinishedSplitInfos() to sort the list if needed.

        To leverage data locality for append-heavy workloads (e.g. auto-increment PKs), this method checks the first and last splits before applying binary search to the remaining subset.

        Parameters:
        sortedSplits - List of splits sorted by splitStart (MUST be sorted!)
        key - The chunk key to search for
        Returns:
        The split containing the key, or null if not found