Class ClusterBy

java.lang.Object
org.apache.druid.frame.key.ClusterBy

public class ClusterBy extends Object
Describes a key used for sorting or partitioning. Keys have columns, and some of those columns may comprise a "bucket key". See getBucketByCount() for details about bucket keys.
  • Constructor Details

    • ClusterBy

      public ClusterBy(List<KeyColumn> columns, int bucketByCount)
  • Method Details

    • none

      public static ClusterBy none()
      Create an empty key.
    • getColumns

      public List<KeyColumn> getColumns()
      The columns that comprise this key, in order.
    • getBucketByCount

      public int getBucketByCount()
      How many fields from getColumns() comprise the "bucket key". Bucketing is like strict partitioning: all rows in a given partition will have the exact same bucket key. It is most commonly used to implement segment granularity during ingestion. The bucket key is a prefix of the complete key. Will always be less than, or equal to, the size of getColumns(). Only relevant when a ClusterBy instance is used as a partitioning key.
    • isEmpty

      public boolean isEmpty()
      Whether this key is empty.
    • sortable

      public boolean sortable()
      Whether this key is sortable. Empty keys (with no columns) are considered sortable.
    • keyReader

      public RowKeyReader keyReader(ColumnInspector inspector, FrameType frameType)
      Create a reader for keys for this instance. The provided ColumnInspector is used to determine the types of fields in the keys. The provided signature does not have to exactly match the sortColumns: it merely has to contain them all.
    • keyComparator

      public Comparator<RowKey> keyComparator(RowSignature rowSignature)
      Comparator that compares keys for this instance using the given signature.
    • byteKeyComparator

      public Comparator<byte[]> byteKeyComparator(RowSignature rowSignature)
      Comparator that compares byte arrays of keys for this instance using the given signature directly.
    • bucketComparator

      public Comparator<RowKey> bucketComparator(RowSignature rowSignature)
      Comparator that compares bucket keys for this instance. Bucket keys are retrieved by calling RowKeyReader.trim(RowKey, int) with getBucketByCount().
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object