public class ClusteringComparator extends java.lang.Object implements java.util.Comparator<Clusterable>
Clusterable
}.
This is essentially just a composite comparator that the clustering values of the provided clustering prefixes in lexicographical order, with each component being compared based on the type of the clustering column this is a value of.
Constructor and Description |
---|
ClusteringComparator(AbstractType<?>... clusteringTypes) |
ClusteringComparator(java.util.List<AbstractType<?>> clusteringTypes) |
Modifier and Type | Method and Description |
---|---|
int |
compare(Clusterable c1,
Clusterable c2) |
int |
compare(Clustering c1,
Clustering c2) |
int |
compare(ClusteringPrefix c1,
ClusteringPrefix c2) |
int |
compareComponent(int i,
java.nio.ByteBuffer v1,
java.nio.ByteBuffer v2) |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
java.util.Comparator<IndexHelper.IndexInfo> |
indexComparator(boolean reversed) |
boolean |
isCompatibleWith(ClusteringComparator previous)
Returns whether this clustering comparator is compatible with the provided one,
that is if the provided one can be safely replaced by this new one.
|
Clustering |
make(java.lang.Object... values)
Creates a row clustering based on the clustering values.
|
java.util.Comparator<Clusterable> |
reversed() |
java.util.Comparator<Row> |
rowComparator()
A comparator for rows.
|
int |
size()
The number of clustering columns for the table this is the comparator of.
|
AbstractType<?> |
subtype(int i)
Returns the type of the ith clustering column of the table.
|
java.util.List<AbstractType<?>> |
subtypes()
The "subtypes" of this clustering comparator, that is the types of the clustering
columns for the table this is a comparator of.
|
java.lang.String |
toString() |
void |
validate(ClusteringPrefix clustering)
Validates the provided prefix for corrupted data.
|
public ClusteringComparator(AbstractType<?>... clusteringTypes)
public ClusteringComparator(java.util.List<AbstractType<?>> clusteringTypes)
public int size()
public java.util.List<AbstractType<?>> subtypes()
public AbstractType<?> subtype(int i)
public Clustering make(java.lang.Object... values)
Every argument can either be a ByteBuffer
, in which case it is used as-is, or a object
corresponding to the type of the corresponding clustering column, in which case it will be
converted to a byte buffer using the column type.
values
- the values to use for the created clustering. There should be exactly size()
values which must be either byte buffers or of the type the column expect.public int compare(Clusterable c1, Clusterable c2)
compare
in interface java.util.Comparator<Clusterable>
public int compare(ClusteringPrefix c1, ClusteringPrefix c2)
public int compare(Clustering c1, Clustering c2)
public int compareComponent(int i, java.nio.ByteBuffer v1, java.nio.ByteBuffer v2)
public boolean isCompatibleWith(ClusteringComparator previous)
previous
- the previous comparator that we want to replace and test
compatibility with.previous
can be safely replaced by this comparator.public void validate(ClusteringPrefix clustering)
clustering
- the clustering prefix to validate.MarshalException
- if clustering
contains some invalid data.public java.util.Comparator<Row> rowComparator()
Row
is a Clusterable
so ClusteringComparator
can be used
to compare rows directly, but when we know we deal with rows (and not Clusterable
in
general), this is a little faster because by knowing we compare Clustering
objects,
we know that 1) they all have the same size and 2) they all have the same kind.public java.util.Comparator<IndexHelper.IndexInfo> indexComparator(boolean reversed)
public java.util.Comparator<Clusterable> reversed()
reversed
in interface java.util.Comparator<Clusterable>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface java.util.Comparator<Clusterable>
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2015 The Apache Software Foundation