Package org.apache.metamodel.cassandra
Class CassandraDataContext
- java.lang.Object
-
- org.apache.metamodel.AbstractDataContext
-
- org.apache.metamodel.QueryPostprocessDataContext
-
- org.apache.metamodel.cassandra.CassandraDataContext
-
- All Implemented Interfaces:
org.apache.metamodel.convert.HasReadTypeConverters,org.apache.metamodel.DataContext
public class CassandraDataContext extends org.apache.metamodel.QueryPostprocessDataContext implements org.apache.metamodel.DataContextDataContext implementation for Apache Cassandra database. When instantiating this DataContext, a keyspace name is provided. In Cassandra, the keyspace is the container for your application data, similar to a schema in a relational database. Keyspaces are used to group column families together. This implementation supports either automatic discovery of a schema or manual specification of a schema, through theSimpleTableDefclass.
-
-
Constructor Summary
Constructors Constructor Description CassandraDataContext(com.datastax.driver.core.Cluster cluster, String keySpace)Constructs aCassandraDataContextand automatically detects the schema structure/view on the keyspace (seedetectSchema(Cluster, String)).CassandraDataContext(com.datastax.driver.core.Cluster cluster, String keySpace, org.apache.metamodel.util.SimpleTableDef... tableDefs)Constructs aCassandraDataContext.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.metamodel.util.SimpleTableDef[]detectSchema(com.datastax.driver.core.Cluster cluster, String keyspaceName)Performs an analysis of the given keyspace in a Cassandra clusterClusterinstance and detects the cassandra types structure based on the metadata provided by the datastax cassandra java client.static org.apache.metamodel.util.SimpleTableDefdetectTable(com.datastax.driver.core.TableMetadata tableMetaData)Performs an analysis of an available table in Cassandra.protected NumberexecuteCountQuery(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.query.FilterItem> whereItems, boolean functionApproximationAllowed)protected org.apache.metamodel.data.RowexecutePrimaryKeyLookupQuery(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.query.SelectItem> selectItems, org.apache.metamodel.schema.Column primaryKeyColumn, Object keyValue)protected org.apache.metamodel.schema.SchemagetMainSchema()protected StringgetMainSchemaName()protected org.apache.metamodel.data.DataSetmaterializeMainSchemaTable(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.schema.Column> columns, int maxRows)-
Methods inherited from class org.apache.metamodel.QueryPostprocessDataContext
addConverter, executeQuery, getDefaultSchemaName, getSchemaByNameInternal, getSchemaNamesInternal, isMainSchemaTable, isScalarFunctionMaterialized, materializeFromItem, materializeMainSchemaTable, materializeMainSchemaTable, materializeMainSchemaTableSelect, materializeTable
-
Methods inherited from class org.apache.metamodel.AbstractDataContext
compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, onSchemaCacheRefreshed, parseQuery, query, refreshSchemas
-
-
-
-
Constructor Detail
-
CassandraDataContext
public CassandraDataContext(com.datastax.driver.core.Cluster cluster, String keySpace, org.apache.metamodel.util.SimpleTableDef... tableDefs)Constructs aCassandraDataContext. This constructor accepts a custom array ofSimpleTableDefs which allows the user to define his own view on the indexes in the engine.- Parameters:
cluster- the Cassandra clusterkeySpace- the name of the Cassandra keyspacetableDefs- an array ofSimpleTableDefs, which define the table and column model of the ElasticSearch index.
-
CassandraDataContext
public CassandraDataContext(com.datastax.driver.core.Cluster cluster, String keySpace)Constructs aCassandraDataContextand automatically detects the schema structure/view on the keyspace (seedetectSchema(Cluster, String)).- Parameters:
cluster- the Cassandra clusterkeySpace- the name of the Cassandra keyspace to represent
-
-
Method Detail
-
detectSchema
public static org.apache.metamodel.util.SimpleTableDef[] detectSchema(com.datastax.driver.core.Cluster cluster, String keyspaceName)Performs an analysis of the given keyspace in a Cassandra clusterClusterinstance and detects the cassandra types structure based on the metadata provided by the datastax cassandra java client.- Parameters:
cluster- the cluster to inspectkeyspaceName-- Returns:
- a mutable schema instance, useful for further fine tuning by the user.
- See Also:
detectTable(TableMetadata)
-
detectTable
public static org.apache.metamodel.util.SimpleTableDef detectTable(com.datastax.driver.core.TableMetadata tableMetaData)
Performs an analysis of an available table in Cassandra.- Parameters:
tableMetaData- the table meta data- Returns:
- a table definition for cassandra.
-
getMainSchema
protected org.apache.metamodel.schema.Schema getMainSchema() throws org.apache.metamodel.MetaModelException- Specified by:
getMainSchemain classorg.apache.metamodel.QueryPostprocessDataContext- Throws:
org.apache.metamodel.MetaModelException
-
getMainSchemaName
protected String getMainSchemaName() throws org.apache.metamodel.MetaModelException
- Specified by:
getMainSchemaNamein classorg.apache.metamodel.QueryPostprocessDataContext- Throws:
org.apache.metamodel.MetaModelException
-
materializeMainSchemaTable
protected org.apache.metamodel.data.DataSet materializeMainSchemaTable(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.schema.Column> columns, int maxRows)- Specified by:
materializeMainSchemaTablein classorg.apache.metamodel.QueryPostprocessDataContext
-
executePrimaryKeyLookupQuery
protected org.apache.metamodel.data.Row executePrimaryKeyLookupQuery(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.query.SelectItem> selectItems, org.apache.metamodel.schema.Column primaryKeyColumn, Object keyValue)- Overrides:
executePrimaryKeyLookupQueryin classorg.apache.metamodel.QueryPostprocessDataContext
-
-