Package org.apache.cassandra.db
Class Slice
- java.lang.Object
-
- org.apache.cassandra.db.Slice
-
public class Slice extends java.lang.Object
A slice represents the selection of a range of rows.A slice has a start and an end bound that are both (potentially full) clustering prefixes. A slice selects every row whose clustering is included within its start and end bounds. Both start and end can be either inclusive or exclusive.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Slice.Serializer
-
Field Summary
Fields Modifier and Type Field Description static Slice
ALL
The slice selecting all rows (of a given partition)static Slice.Serializer
serializer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ClusteringBound<?>
close(boolean reversed)
ClusteringBound<?>
end()
boolean
equals(java.lang.Object other)
Slice
forPaging(ClusteringComparator comparator, Clustering<?> lastReturned, boolean inclusive, boolean reversed)
Returns a slice for continuing paging from the last returned clustering prefix.int
hashCode()
boolean
includes(ClusteringComparator comparator, ClusteringPrefix<?> bound)
Returns whether a given clustering or bound is included in this slice.boolean
intersects(ClusteringComparator comparator, Slice other)
Whether this slice and the provided slice intersects.boolean
isEmpty(ClusteringComparator comparator)
Return whether the slice is empty.static boolean
isEmpty(ClusteringComparator comparator, ClusteringBound<?> start, ClusteringBound<?> end)
Return whether the slice formed by the two provided bound is empty or not.static Slice
make(Clustering<?> clustering)
Makes a slice covering a single clusteringstatic Slice
make(Clustering<?> start, Clustering<?> end)
Makes a slice covering a range from start to end clusterings, with both start and end includedstatic Slice
make(ClusteringBound<?> start, ClusteringBound<?> end)
static Slice
make(ClusteringBoundOrBoundary<?> start, ClusteringBoundOrBoundary<?> end)
Makes a slice for the given boundsstatic Slice
make(ClusteringComparator comparator, java.lang.Object... values)
ClusteringBound<?>
open(boolean reversed)
ClusteringBound<?>
start()
java.lang.String
toString(ClusteringComparator comparator)
-
-
-
Field Detail
-
serializer
public static final Slice.Serializer serializer
-
ALL
public static final Slice ALL
The slice selecting all rows (of a given partition)
-
-
Method Detail
-
make
public static Slice make(ClusteringBound<?> start, ClusteringBound<?> end)
-
make
public static Slice make(ClusteringComparator comparator, java.lang.Object... values)
-
make
public static Slice make(Clustering<?> clustering)
Makes a slice covering a single clustering
-
make
public static Slice make(Clustering<?> start, Clustering<?> end)
Makes a slice covering a range from start to end clusterings, with both start and end included
-
make
public static Slice make(ClusteringBoundOrBoundary<?> start, ClusteringBoundOrBoundary<?> end)
Makes a slice for the given bounds
-
start
public ClusteringBound<?> start()
-
end
public ClusteringBound<?> end()
-
open
public ClusteringBound<?> open(boolean reversed)
-
close
public ClusteringBound<?> close(boolean reversed)
-
isEmpty
public boolean isEmpty(ClusteringComparator comparator)
Return whether the slice is empty.- Parameters:
comparator
- the comparator to compare the bounds.- Returns:
- whether the slice formed is empty or not.
-
isEmpty
public static boolean isEmpty(ClusteringComparator comparator, ClusteringBound<?> start, ClusteringBound<?> end)
Return whether the slice formed by the two provided bound is empty or not.- Parameters:
comparator
- the comparator to compare the bounds.start
- the start for the slice to consider. This must be a start bound.end
- the end for the slice to consider. This must be an end bound.- Returns:
- whether the slice formed by
start
andend
is empty or not.
-
includes
public boolean includes(ClusteringComparator comparator, ClusteringPrefix<?> bound)
Returns whether a given clustering or bound is included in this slice.- Parameters:
comparator
- the comparator for the table this is a slice of.bound
- the bound to test inclusion of.- Returns:
- whether
bound
is within the bounds of this slice.
-
forPaging
public Slice forPaging(ClusteringComparator comparator, Clustering<?> lastReturned, boolean inclusive, boolean reversed)
Returns a slice for continuing paging from the last returned clustering prefix.- Parameters:
comparator
- the comparator for the table this is a filter for.lastReturned
- the last clustering that was returned for the query we are paging for. The resulting slices will be such that only results coming stricly afterlastReturned
are returned (where coming after means "greater than" if!reversed
and "lesser than" otherwise).inclusive
- whether we want to include thelastReturned
in the newly returned page of results.reversed
- whether the query we're paging for is reversed or not.- Returns:
- a new slice that selects results coming after
lastReturned
, ornull
if paging the resulting slice selects nothing (i.e. if it originally selects nothing coming afterlastReturned
).
-
intersects
public boolean intersects(ClusteringComparator comparator, Slice other)
Whether this slice and the provided slice intersects.- Parameters:
comparator
- the comparator for the table this is a slice of.other
- the other slice to check intersection with.- Returns:
- whether this slice intersects
other
.
-
toString
public java.lang.String toString(ClusteringComparator comparator)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-