public class TableMetadata extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TableOrView.Order
Clustering orders.
|
Modifier and Type | Field and Description |
---|---|
protected VersionNumber |
cassandraVersion |
protected List<ColumnMetadata> |
clusteringColumns |
protected List<TableOrView.Order> |
clusteringOrder |
protected Map<String,ColumnMetadata> |
columns |
protected UUID |
id |
protected KeyspaceMetadata |
keyspace |
protected String |
name |
protected TableOptionsMetadata |
options |
protected List<ColumnMetadata> |
partitionKey |
Modifier and Type | Method and Description |
---|---|
protected StringBuilder |
appendOptions(StringBuilder sb,
boolean formatted) |
String |
asCQLQuery()
Returns a CQL query representing this table.
|
protected String |
asCQLQuery(boolean formatted) |
boolean |
equals(Object other) |
String |
exportAsString()
Returns a
String containing CQL queries representing this
table and the index on it. |
List<ColumnMetadata> |
getClusteringColumns()
Returns the list of clustering columns for this table.
|
List<TableOrView.Order> |
getClusteringOrder()
Returns the clustering order for this table.
|
ColumnMetadata |
getColumn(String name)
Returns metadata on a column of this table.
|
List<ColumnMetadata> |
getColumns()
Returns a list containing all the columns of this table.
|
UUID |
getId()
Returns the unique id of this table.
|
IndexMetadata |
getIndex(String name)
Returns metadata on a index of this table.
|
List<IndexMetadata> |
getIndexes()
Returns a list containing all the indexes of this table.
|
KeyspaceMetadata |
getKeyspace()
Returns the keyspace this table belong to.
|
String |
getName()
Returns the name of this table.
|
TableOptionsMetadata |
getOptions()
Returns the options for this table.
|
List<ColumnMetadata> |
getPartitionKey()
Returns the list of columns composing the partition key for this table.
|
List<ColumnMetadata> |
getPrimaryKey()
Returns the list of columns composing the primary key for this table.
|
MaterializedViewMetadata |
getView(String name)
Returns metadata on a view of this table.
|
List<MaterializedViewMetadata> |
getViews()
Returns a list containing all the viewes of this table.
|
int |
hashCode() |
String |
toString() |
protected final KeyspaceMetadata keyspace
protected final String name
protected final UUID id
protected final List<ColumnMetadata> partitionKey
protected final List<ColumnMetadata> clusteringColumns
protected final Map<String,ColumnMetadata> columns
protected final TableOptionsMetadata options
protected final List<TableOrView.Order> clusteringOrder
protected final VersionNumber cassandraVersion
public IndexMetadata getIndex(String name)
name
- the name of the index to retrieve (name
will be
interpreted as a case-insensitive identifier unless enclosed in double-quotes,
see Metadata.quote(java.lang.String)
).name
index if it exists, or
null
otherwise.public List<IndexMetadata> getIndexes()
public MaterializedViewMetadata getView(String name)
name
- the name of the view to retrieve (name
will be
interpreted as a case-insensitive identifier unless enclosed in double-quotes,
see Metadata.quote(java.lang.String)
).name
view if it exists, or
null
otherwise.public List<MaterializedViewMetadata> getViews()
public String exportAsString()
String
containing CQL queries representing this
table and the index on it.
In other words, this method returns the queries that would allow you to recreate the schema of this table, along with the indexes and views defined on this table, if any.
Note that the returned String is formatted to be human readable (for some definition of human readable at least).
protected String asCQLQuery(boolean formatted)
public String getName()
public UUID getId()
Note: this id is available in Cassandra 2.1 and above. It will be
null
for earlier versions.
public KeyspaceMetadata getKeyspace()
public ColumnMetadata getColumn(String name)
name
- the name of the column to retrieve (name
will be
interpreted as a case-insensitive identifier unless enclosed in double-quotes,
see Metadata.quote(java.lang.String)
).null
otherwise.public List<ColumnMetadata> getColumns()
SELECT * FROM thisTable
:
the first column is the partition key, next are the clustering
columns in their defined order, and then the rest of the
columns follow in alphabetic order.public List<ColumnMetadata> getPrimaryKey()
public List<ColumnMetadata> getPartitionKey()
public List<ColumnMetadata> getClusteringColumns()
public List<TableOrView.Order> getClusteringOrder()
The returned contains the clustering order of each clustering column. The
i
th element of the result correspond to the order (ascending or
descending) of the i
th clustering column (see
getClusteringColumns()
). Note that a table defined without any
particular clustering order is equivalent to one for which all the
clustering key are in ascending order.
public TableOptionsMetadata getOptions()
public String asCQLQuery()
This method returns a single 'CREATE TABLE' query with the options corresponding to this table definition.
Note that the returned string is a single line; the returned query is not formatted in any way.
exportAsString()
protected StringBuilder appendOptions(StringBuilder sb, boolean formatted)
Copyright © 2012–2015. All rights reserved.