Search in sources :

Example 1 with TableMapper

use of com.tuplejump.stargate.cassandra.TableMapper in project stargate-core by tuplejump.

the class RowIndex method init.

@Override
public void init() {
    writeLock.lock();
    final Boolean isInfoLoggingEnabled = logger.isInfoEnabled();
    try {
        assert baseCfs != null;
        assert columnDefs != null;
        assert columnDefs.size() > 0;
        columnDefinition = columnDefs.iterator().next();
        //null comparator since this is a custom index.
        keyspace = baseCfs.metadata.ksName;
        indexName = columnDefinition.getIndexName();
        tableName = baseCfs.name;
        cfMetaData = baseCfs.metadata;
        primaryColumnName = columnDefinition.name.toString().toLowerCase();
        String optionsJson = columnDefinition.getIndexOptions().get(Constants.INDEX_OPTIONS_JSON);
        this.options = CassandraUtils.getOptions(primaryColumnName, baseCfs, optionsJson);
        this.nearRealTime = options.primary.isNearRealTime();
        if (isInfoLoggingEnabled) {
            logger.info("Creating new RowIndex for {}", indexName);
        }
        //            indexContainer = new PerVNodeIndexContainer(options.analyzer, keyspace, tableName, indexName);
        indexContainer = new MonolithIndexContainer(options.analyzer, keyspace, tableName, indexName);
        this.tableMapper = new TableMapper(baseCfs, options.primary.isMetaColumn(), columnDefinition);
        rowIndexSupport = new RowIndexSupport(keyspace, indexContainer, options, tableMapper);
        Stargate.getInstance().register(rowIndexSupport);
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                if (isInfoLoggingEnabled) {
                    logger.info("Closing RowIndex for {}", indexName);
                }
                if (indexContainer != null)
                    indexContainer.close();
            }
        });
    } finally {
        writeLock.unlock();
    }
}
Also used : RowIndexSupport(com.tuplejump.stargate.cassandra.RowIndexSupport) TableMapper(com.tuplejump.stargate.cassandra.TableMapper)

Aggregations

RowIndexSupport (com.tuplejump.stargate.cassandra.RowIndexSupport)1 TableMapper (com.tuplejump.stargate.cassandra.TableMapper)1