Interface ClusteringPrefix<V>
-
- All Superinterfaces:
Clusterable<V>
,IMeasurableMemory
- All Known Subinterfaces:
Clustering<V>
,ClusteringBound<V>
,ClusteringBoundary<V>
,ClusteringBoundOrBoundary<V>
- All Known Implementing Classes:
AbstractArrayClusteringPrefix
,AbstractBufferClusteringPrefix
,AbstractOnHeapClusteringPrefix
,ArrayClustering
,ArrayClusteringBound
,ArrayClusteringBoundary
,ArrayClusteringBoundOrBoundary
,BufferClustering
,BufferClusteringBound
,BufferClusteringBoundary
,BufferClusteringBoundOrBoundary
,NativeClustering
public interface ClusteringPrefix<V> extends IMeasurableMemory, Clusterable<V>
A clustering prefix is the unit of what aClusteringComparator
can compare.It holds values for the clustering columns of a table (potentially only a prefix of all of them) and has a "kind" that allows us to implement slices with inclusive and exclusive bounds.
In practice,
ClusteringPrefix
is just the common parts to its 3 main subtype:Clustering
andClusteringBound
/ClusteringBoundary
, where: 1)Clustering
represents the clustering values for a row, i.e. the values for it's clustering columns. 2)ClusteringBound
represents a bound (start or end) of a slice (of rows) or a range tombstone. 3)ClusteringBoundary
represents the threshold between two adjacent range tombstones. See those classes for more details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ClusteringPrefix.Deserializer
Helper class that makes the deserialization of clustering prefixes faster.static class
ClusteringPrefix.Kind
The kind of clustering prefix this actually is.static class
ClusteringPrefix.Serializer
-
Field Summary
Fields Modifier and Type Field Description static ClusteringPrefix.Serializer
serializer
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ValueAccessor<V>
accessor()
ClusteringBound<V>
asEndBound()
Returns this prefix as an end bound.ClusteringBound<V>
asStartBound()
Returns this prefix as a start bound.default java.nio.ByteBuffer
bufferAt(int i)
default java.lang.String
clusteringString(java.util.List<AbstractType<?>> types)
Produce a human-readable representation of the clustering given the list of types.default int
dataSize()
The size of the data hold by this prefix.default void
digest(Digest digest)
Adds the data of this clustering prefix to the provided Digest instance.static boolean
equals(ClusteringPrefix<?> prefix, java.lang.Object o)
static <V1,V2>
booleanequals(ClusteringPrefix<V1> left, ClusteringPrefix<V2> right)
V
get(int i)
Retrieves the ith value of this prefix.java.nio.ByteBuffer[]
getBufferArray()
V[]
getRawValues()
The values of this prefix as an array.static <V> int
hashCode(ClusteringPrefix<V> prefix)
default boolean
isBottom()
default boolean
isEmpty()
default boolean
isTop()
ClusteringPrefix.Kind
kind()
ClusteringPrefix<V>
retainable()
Return the key in a form that can be retained for longer-term use.default java.nio.ByteBuffer
serializeAsPartitionKey()
int
size()
The number of values in this prefix.default java.lang.String
stringAt(int i, ClusteringComparator comparator)
java.lang.String
toString(TableMetadata metadata)
Generates a proper string representation of the prefix.default void
validate()
default void
validate(int i, ClusteringComparator comparator)
-
Methods inherited from interface org.apache.cassandra.db.Clusterable
clustering
-
Methods inherited from interface org.apache.cassandra.cache.IMeasurableMemory
unsharedHeapSize
-
-
-
-
Field Detail
-
serializer
static final ClusteringPrefix.Serializer serializer
-
-
Method Detail
-
isBottom
default boolean isBottom()
-
isTop
default boolean isTop()
-
kind
ClusteringPrefix.Kind kind()
-
size
int size()
The number of values in this prefix. There can't be more values that the this is a prefix of has of clustering columns.- Returns:
- the number of values in this prefix.
-
isEmpty
default boolean isEmpty()
-
get
V get(int i)
Retrieves the ith value of this prefix.- Parameters:
i
- the index of the value to retrieve. Must be such that0 <= i < size()
.- Returns:
- the ith value of this prefix. Note that a value can be
null
.
-
accessor
ValueAccessor<V> accessor()
-
bufferAt
default java.nio.ByteBuffer bufferAt(int i)
-
stringAt
default java.lang.String stringAt(int i, ClusteringComparator comparator)
-
validate
default void validate()
-
validate
default void validate(int i, ClusteringComparator comparator)
-
digest
default void digest(Digest digest)
Adds the data of this clustering prefix to the provided Digest instance.- Parameters:
digest
- the Digest instance to which to add this prefix.
-
dataSize
default int dataSize()
The size of the data hold by this prefix.- Returns:
- the size of the data hold by this prefix (this is not the size of the object in memory, just the size of the data it stores).
-
toString
java.lang.String toString(TableMetadata metadata)
Generates a proper string representation of the prefix.- Parameters:
metadata
- the metadata for the table the clustering prefix is of.- Returns:
- a human-readable string representation fo this prefix.
-
asStartBound
ClusteringBound<V> asStartBound()
Returns this prefix as a start bound. If this prefix is a bound, just returns it asserting that it is a start bound. If this prefix is a clustering, returns an included start bound. If this prefix is a boundary, returns an open bound of it
-
asEndBound
ClusteringBound<V> asEndBound()
Returns this prefix as an end bound. If this prefix is a bound, just returns it asserting that it is an end bound. If this prefix is a clustering, returns an included end bound. In this prefix is a boundary, returns a close bound of it.
-
serializeAsPartitionKey
default java.nio.ByteBuffer serializeAsPartitionKey()
-
clusteringString
default java.lang.String clusteringString(java.util.List<AbstractType<?>> types)
Produce a human-readable representation of the clustering given the list of types. Easier to access than metadata for debugging.
-
getRawValues
V[] getRawValues()
The values of this prefix as an array.Please note that this may or may not require an array creation. So 1) you should *not* modify the returned array and 2) it's more efficient to use
size()
andget(int)
unless you actually need an array.- Returns:
- the values for this prefix as an array.
-
getBufferArray
java.nio.ByteBuffer[] getBufferArray()
-
retainable
ClusteringPrefix<V> retainable()
Return the key in a form that can be retained for longer-term use. This means extracting keys stored in shared memory (i.e. in memtables) to minimized on-heap versions. If the object is already in minimal form, no action will be taken.
-
hashCode
static <V> int hashCode(ClusteringPrefix<V> prefix)
-
equals
static <V1,V2> boolean equals(ClusteringPrefix<V1> left, ClusteringPrefix<V2> right)
-
equals
static boolean equals(ClusteringPrefix<?> prefix, java.lang.Object o)
-
-