Package org.apache.cassandra.db
Class Columns
- All Implemented Interfaces:
Iterable<ColumnMetadata>,Collection<ColumnMetadata>
public class Columns
extends AbstractCollection<ColumnMetadata>
implements Collection<ColumnMetadata>
An immutable and sorted list of (non-PK) columns for a given table.
Note that in practice, it will either store only static columns, or only regular ones. When
we need both type of columns, we use a RegularAndStaticColumns object.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColumnMetadatastatic final ColumnMetadatastatic final Columnsstatic final Columns.Serializer -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Consumer<ColumnMetadata> function) Apply a function to each column definition in forwards or reversed order.intThe number of complex columns (non-frozen collections, udts, ...) in this object.Iterator over the complex columns of this object.intThe index of the provided complex column in this object (if it contains the provided column).booleanWhether the provided column is contained by this object.booleancontainsAll(Collection<?> other) Whether this object is a superset of the provided otherColumns object.voidbooleanstatic ColumnsReturns a newColumnsobject holding the same columns than the provided set.static ColumnsReturns a newColumnsobject holing the same columns as the provided Row.static Columnsfrom(BTree.Builder<ColumnMetadata> builder) getComplex(int i) Returns the ith complex column of this object.getSimple(int i) Returns the ith simple column of this object.booleanWhether this objects contains complex columns.inthashCode()booleanWhether this objects contains simple columns.Returns a predicate to test whether columns are included in thisColumnsobject, assuming that tes tested columns are passed to the predicate in sorted order.booleanisEmpty()Whether this columns is empty.iterator()Iterator over all the columns of this object.Returns the result of merging thisColumnsobject with the provided one.static Columnsof(ColumnMetadata c) Creates aColumnsholding only the one column provided.An iterator that returns the columns of this object in "select" order (that is in global alphabetical order, where the "normal" iterator returns simple columns first and the complex second).intThe number of simple columns in this object.Iterator over the simple columns of this object.intThe index of the provided simple column in this object (if it contains the provided column).intsize()The total number of columns in this object.toString()longwithout(ColumnMetadata column) Returns the equivalent of those columns but with the provided column removed.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
add, addAll, clear, contains, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
serializer
-
NONE
-
FIRST_COMPLEX_STATIC
-
FIRST_COMPLEX_REGULAR
-
-
Method Details
-
of
Creates aColumnsholding only the one column provided.- Parameters:
c- the column for which to create aColumnsobject.- Returns:
- the newly created
Columnscontaining onlyc.
-
from
Returns a newColumnsobject holing the same columns as the provided Row.- Parameters:
row- the row from which to create the newColumns.- Returns:
- the newly created
Columnscontaining the columns fromrow.
-
from
-
from
Returns a newColumnsobject holding the same columns than the provided set. This method assumes nothing about the order ofs.- Parameters:
s- the set from which to create the newColumns.- Returns:
- the newly created
Columnscontaining the columns froms.
-
isEmpty
public boolean isEmpty()Whether this columns is empty.- Specified by:
isEmptyin interfaceCollection<ColumnMetadata>- Overrides:
isEmptyin classAbstractCollection<ColumnMetadata>- Returns:
- whether this columns is empty.
-
simpleColumnCount
public int simpleColumnCount()The number of simple columns in this object.- Returns:
- the number of simple columns in this object.
-
complexColumnCount
public int complexColumnCount()The number of complex columns (non-frozen collections, udts, ...) in this object.- Returns:
- the number of complex columns in this object.
-
size
public int size()The total number of columns in this object.- Specified by:
sizein interfaceCollection<ColumnMetadata>- Specified by:
sizein classAbstractCollection<ColumnMetadata>- Returns:
- the total number of columns in this object.
-
hasSimple
public boolean hasSimple()Whether this objects contains simple columns.- Returns:
- whether this objects contains simple columns.
-
hasComplex
public boolean hasComplex()Whether this objects contains complex columns.- Returns:
- whether this objects contains complex columns.
-
getSimple
Returns the ith simple column of this object.- Parameters:
i- the index for the simple column to fectch. This must satisfy0 <= i < simpleColumnCount().- Returns:
- the
ith simple column in this object.
-
getComplex
Returns the ith complex column of this object.- Parameters:
i- the index for the complex column to fectch. This must satisfy0 <= i < complexColumnCount().- Returns:
- the
ith complex column in this object.
-
simpleIdx
The index of the provided simple column in this object (if it contains the provided column).- Parameters:
c- the simple column for which to return the index of.- Returns:
- the index for simple column
cif it is contains in this object
-
complexIdx
The index of the provided complex column in this object (if it contains the provided column).- Parameters:
c- the complex column for which to return the index of.- Returns:
- the index for complex column
cif it is contains in this object
-
contains
Whether the provided column is contained by this object.- Parameters:
c- the column to check presence of.- Returns:
- whether
cis contained by this object.
-
mergeTo
Returns the result of merging thisColumnsobject with the provided one.- Parameters:
other- the otherColumnsto merge this object with.- Returns:
- the result of merging/taking the union of
thisandother. The returned object may be one of the operand and that operand is a subset of the other operand.
-
containsAll
Whether this object is a superset of the provided otherColumns object.- Specified by:
containsAllin interfaceCollection<ColumnMetadata>- Overrides:
containsAllin classAbstractCollection<ColumnMetadata>- Parameters:
other- the other object to test for inclusion in this object.- Returns:
- whether all the columns of
otherare contained by this object.
-
simpleColumns
Iterator over the simple columns of this object.- Returns:
- an iterator over the simple columns of this object.
-
complexColumns
Iterator over the complex columns of this object.- Returns:
- an iterator over the complex columns of this object.
-
iterator
Iterator over all the columns of this object.- Specified by:
iteratorin interfaceCollection<ColumnMetadata>- Specified by:
iteratorin interfaceIterable<ColumnMetadata>- Specified by:
iteratorin classAbstractCollection<ColumnMetadata>- Returns:
- an iterator over all the columns of this object.
-
selectOrderIterator
An iterator that returns the columns of this object in "select" order (that is in global alphabetical order, where the "normal" iterator returns simple columns first and the complex second).- Returns:
- an iterator returning columns in alphabetical order.
-
without
Returns the equivalent of those columns but with the provided column removed.- Parameters:
column- the column to remove.- Returns:
- newly allocated columns containing all the columns of
thisexpect forcolumn.
-
inOrderInclusionTester
Returns a predicate to test whether columns are included in thisColumnsobject, assuming that tes tested columns are passed to the predicate in sorted order.- Returns:
- a predicate to test the inclusion of sorted columns in this object.
-
digest
-
apply
Apply a function to each column definition in forwards or reversed order.- Parameters:
function-
-
equals
- Specified by:
equalsin interfaceCollection<ColumnMetadata>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<ColumnMetadata>- Overrides:
hashCodein classObject
-
toString
- Overrides:
toStringin classAbstractCollection<ColumnMetadata>
-