Package org.apache.cassandra.db
Class Columns
- java.lang.Object
-
- java.util.AbstractCollection<ColumnMetadata>
-
- org.apache.cassandra.db.Columns
-
- All Implemented Interfaces:
java.lang.Iterable<ColumnMetadata>,java.util.Collection<ColumnMetadata>
public class Columns extends java.util.AbstractCollection<ColumnMetadata> implements java.util.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
RegularAndStaticColumnsobject.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classColumns.Serializer
-
Field Summary
Fields Modifier and Type Field Description static ColumnMetadataFIRST_COMPLEX_REGULARstatic ColumnMetadataFIRST_COMPLEX_STATICstatic ColumnsNONEstatic Columns.Serializerserializer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(java.util.function.Consumer<ColumnMetadata> function)Apply a function to each column definition in forwards or reversed order.intcomplexColumnCount()The number of complex columns (non-frozen collections, udts, ...) in this object.java.util.Iterator<ColumnMetadata>complexColumns()Iterator over the complex columns of this object.intcomplexIdx(ColumnMetadata c)The index of the provided complex column in this object (if it contains the provided column).booleancontains(ColumnMetadata c)Whether the provided column is contained by this object.booleancontainsAll(java.util.Collection<?> other)Whether this object is a superset of the provided otherColumns object.voiddigest(Digest digest)booleanequals(java.lang.Object other)static Columnsfrom(java.util.Collection<ColumnMetadata> s)Returns a newColumnsobject holding the same columns than the provided set.static Columnsfrom(Row row)Returns a newColumnsobject holing the same columns as the provided Row.static Columnsfrom(BTree.Builder<ColumnMetadata> builder)ColumnMetadatagetComplex(int i)Returns the ith complex column of this object.ColumnMetadatagetSimple(int i)Returns the ith simple column of this object.booleanhasComplex()Whether this objects contains complex columns.inthashCode()booleanhasSimple()Whether this objects contains simple columns.java.util.function.Predicate<ColumnMetadata>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.booleanisEmpty()Whether this columns is empty.BTreeSearchIterator<ColumnMetadata,ColumnMetadata>iterator()Iterator over all the columns of this object.ColumnsmergeTo(Columns other)Returns the result of merging thisColumnsobject with the provided one.static Columnsof(ColumnMetadata c)Creates aColumnsholding only the one column provided.java.util.Iterator<ColumnMetadata>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).intsimpleColumnCount()The number of simple columns in this object.java.util.Iterator<ColumnMetadata>simpleColumns()Iterator over the simple columns of this object.intsimpleIdx(ColumnMetadata c)The index of the provided simple column in this object (if it contains the provided column).intsize()The total number of columns in this object.java.lang.StringtoString()longunsharedHeapSize()Columnswithout(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, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
serializer
public static final Columns.Serializer serializer
-
NONE
public static final Columns NONE
-
FIRST_COMPLEX_STATIC
public static final ColumnMetadata FIRST_COMPLEX_STATIC
-
FIRST_COMPLEX_REGULAR
public static final ColumnMetadata FIRST_COMPLEX_REGULAR
-
-
Method Detail
-
of
public static Columns of(ColumnMetadata c)
Creates aColumnsholding only the one column provided.- Parameters:
c- the column for which to create aColumnsobject.- Returns:
- the newly created
Columnscontaining onlyc.
-
from
public static Columns from(Row row)
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
public static Columns from(BTree.Builder<ColumnMetadata> builder)
-
from
public static Columns from(java.util.Collection<ColumnMetadata> s)
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 interfacejava.util.Collection<ColumnMetadata>- Overrides:
isEmptyin classjava.util.AbstractCollection<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 interfacejava.util.Collection<ColumnMetadata>- Specified by:
sizein classjava.util.AbstractCollection<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
public ColumnMetadata getSimple(int i)
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
public ColumnMetadata getComplex(int i)
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
public int simpleIdx(ColumnMetadata c)
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
public int complexIdx(ColumnMetadata c)
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
public boolean contains(ColumnMetadata c)
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
public Columns mergeTo(Columns other)
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
public boolean containsAll(java.util.Collection<?> other)
Whether this object is a superset of the provided otherColumns object.- Specified by:
containsAllin interfacejava.util.Collection<ColumnMetadata>- Overrides:
containsAllin classjava.util.AbstractCollection<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
public java.util.Iterator<ColumnMetadata> simpleColumns()
Iterator over the simple columns of this object.- Returns:
- an iterator over the simple columns of this object.
-
complexColumns
public java.util.Iterator<ColumnMetadata> complexColumns()
Iterator over the complex columns of this object.- Returns:
- an iterator over the complex columns of this object.
-
iterator
public BTreeSearchIterator<ColumnMetadata,ColumnMetadata> iterator()
Iterator over all the columns of this object.- Specified by:
iteratorin interfacejava.util.Collection<ColumnMetadata>- Specified by:
iteratorin interfacejava.lang.Iterable<ColumnMetadata>- Specified by:
iteratorin classjava.util.AbstractCollection<ColumnMetadata>- Returns:
- an iterator over all the columns of this object.
-
selectOrderIterator
public java.util.Iterator<ColumnMetadata> 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
public Columns without(ColumnMetadata column)
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
public java.util.function.Predicate<ColumnMetadata> 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
public void digest(Digest digest)
-
apply
public void apply(java.util.function.Consumer<ColumnMetadata> function)
Apply a function to each column definition in forwards or reversed order.- Parameters:
function-
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equalsin interfacejava.util.Collection<ColumnMetadata>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<ColumnMetadata>- Overrides:
hashCodein classjava.lang.Object
-
unsharedHeapSize
public long unsharedHeapSize()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractCollection<ColumnMetadata>
-
-