Class DetectPrimaryKeysInDataset

java.lang.Object
com.northconcepts.datapipeline.foundations.tools.DetectPrimaryKeysInDataset

public class DetectPrimaryKeysInDataset extends Object
Finds the fields, or smallest field combinations, whose values are unique across all records of a RecordList.
  • Constructor Details

    • DetectPrimaryKeysInDataset

      public DetectPrimaryKeysInDataset()
  • Method Details

    • detectPrimaryKeys

      public static List<FieldList> detectPrimaryKeys(RecordList records)
      Returns a list with the first of the smallest field combinations whose values are unique across the records, or an empty list if there is none.
    • detectPrimaryKeys

      public static List<FieldList> detectPrimaryKeys(RecordList records, int maxKeyFieldCount, boolean stopOnFirstMatch)
      Returns the combinations of up to maxKeyFieldCount fields whose values are unique across the records, smallest first and skipping supersets of keys already found; stops at the first one if stopOnFirstMatch is true.
    • isCandidateKey

      public static boolean isCandidateKey(RecordList records, String... fieldNames)
      Returns true if no two records have the same values for the given fields.
    • getFieldListCandidates

      public static List<String[]> getFieldListCandidates(List<String> fieldNames, int keyLength)
      Returns every combination of keyLength names from fieldNames, keeping their order; throws if keyLength is less than 1.