Package org.apache.druid.frame.key
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". SeegetBucketByCount()for details about bucket keys.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Comparator<RowKey>bucketComparator(RowSignature rowSignature)Comparator that compares bucket keys for this instance.Comparator<byte[]>byteKeyComparator(RowSignature rowSignature)Comparator that compares byte arrays of keys for this instance using the given signature directly.booleanequals(Object o)intgetBucketByCount()How many fields fromgetColumns()comprise the "bucket key".List<KeyColumn>getColumns()The columns that comprise this key, in order.inthashCode()booleanisEmpty()Whether this key is empty.Comparator<RowKey>keyComparator(RowSignature rowSignature)Comparator that compares keys for this instance using the given signature.RowKeyReaderkeyReader(ColumnInspector inspector)Create a reader for keys for this instance.static ClusterBynone()Create an empty key.booleansortable()Whether this key is sortable.StringtoString()
-
-
-
Method Detail
-
none
public static ClusterBy none()
Create an empty key.
-
getBucketByCount
public int getBucketByCount()
How many fields fromgetColumns()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 ofgetColumns(). 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)
Create a reader for keys for this instance. The providedColumnInspectoris 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 callingRowKeyReader.trim(RowKey, int)withgetBucketByCount().
-
-