Class 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.DataContext
    DataContext 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 the SimpleTableDef class.
    • Field Summary

      • Fields inherited from class org.apache.metamodel.QueryPostprocessDataContext

        INFORMATION_SCHEMA_NAME, SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS
    • 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 cluster Cluster instance and detects the cassandra types structure based on the metadata provided by the datastax cassandra java client.
      static org.apache.metamodel.util.SimpleTableDef detectTable​(com.datastax.driver.core.TableMetadata tableMetaData)
      Performs an analysis of an available table in Cassandra.
      protected Number executeCountQuery​(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.query.FilterItem> whereItems, boolean functionApproximationAllowed)  
      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)  
      protected org.apache.metamodel.schema.Schema getMainSchema()  
      protected String getMainSchemaName()  
      protected org.apache.metamodel.data.DataSet materializeMainSchemaTable​(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
      • Methods inherited from interface org.apache.metamodel.DataContext

        compileQuery, executeQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
    • Constructor Detail

      • CassandraDataContext

        public CassandraDataContext​(com.datastax.driver.core.Cluster cluster,
                                    String keySpace,
                                    org.apache.metamodel.util.SimpleTableDef... tableDefs)
        Constructs a CassandraDataContext. This constructor accepts a custom array of SimpleTableDefs which allows the user to define his own view on the indexes in the engine.
        Parameters:
        cluster - the Cassandra cluster
        keySpace - the name of the Cassandra keyspace
        tableDefs - an array of SimpleTableDefs, which define the table and column model of the ElasticSearch index.
      • CassandraDataContext

        public CassandraDataContext​(com.datastax.driver.core.Cluster cluster,
                                    String keySpace)
        Constructs a CassandraDataContext and automatically detects the schema structure/view on the keyspace (see detectSchema(Cluster, String)).
        Parameters:
        cluster - the Cassandra cluster
        keySpace - 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 cluster Cluster instance and detects the cassandra types structure based on the metadata provided by the datastax cassandra java client.
        Parameters:
        cluster - the cluster to inspect
        keyspaceName -
        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:
        getMainSchema in class org.apache.metamodel.QueryPostprocessDataContext
        Throws:
        org.apache.metamodel.MetaModelException
      • getMainSchemaName

        protected String getMainSchemaName()
                                    throws org.apache.metamodel.MetaModelException
        Specified by:
        getMainSchemaName in class org.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:
        materializeMainSchemaTable in class org.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:
        executePrimaryKeyLookupQuery in class org.apache.metamodel.QueryPostprocessDataContext
      • executeCountQuery

        protected Number executeCountQuery​(org.apache.metamodel.schema.Table table,
                                           List<org.apache.metamodel.query.FilterItem> whereItems,
                                           boolean functionApproximationAllowed)
        Overrides:
        executeCountQuery in class org.apache.metamodel.QueryPostprocessDataContext