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()
Comparator that compares bucket keys for this instance.Comparator<byte[]>
byteKeyComparator()
Comparator that compares byte arrays of keys for this instance using the given signature directly.boolean
equals(Object o)
int
getBucketByCount()
How many fields fromgetColumns()
comprise the "bucket key".List<KeyColumn>
getColumns()
The columns that comprise this key, in order.int
hashCode()
boolean
isEmpty()
Whether this key is empty.Comparator<RowKey>
keyComparator()
Comparator that compares keys for this instance using the given signature.RowKeyReader
keyReader(ColumnInspector inspector)
Create a reader for keys for this instance.static ClusterBy
none()
Create an empty key.boolean
sortable()
Whether this key is sortable.String
toString()
-
-
-
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 providedColumnInspector
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()
Comparator that compares keys for this instance using the given signature.
-
byteKeyComparator
public Comparator<byte[]> byteKeyComparator()
Comparator that compares byte arrays of keys for this instance using the given signature directly.
-
bucketComparator
public Comparator<RowKey> bucketComparator()
Comparator that compares bucket keys for this instance. Bucket keys are retrieved by callingRowKeyReader.trim(RowKey, int)
withgetBucketByCount()
.
-
-