Search in sources :

Example 16 with ColumnDefinition

use of org.apache.cassandra.config.ColumnDefinition in project eiger by wlloyd.

the class SecondaryIndex method buildIndexBlocking.

/**
     * Builds the index using the data in the underlying CFS
     * Blocks till it's complete
     */
protected void buildIndexBlocking() throws IOException {
    logger.info(String.format("Submitting index build of %s for data in %s", getIndexName(), StringUtils.join(baseCfs.getSSTables(), ", ")));
    SortedSet<ByteBuffer> columnNames = new TreeSet<ByteBuffer>();
    for (ColumnDefinition cdef : columnDefs) columnNames.add(cdef.name);
    Collection<SSTableReader> sstables = baseCfs.markCurrentSSTablesReferenced();
    SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs, columnNames, new ReducingKeyIterator(sstables));
    Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
    try {
        future.get();
        forceBlockingFlush();
        // Mark all indexed columns as built
        if (this instanceof PerRowSecondaryIndex) {
            for (ByteBuffer columnName : columnNames) SystemTable.setIndexBuilt(baseCfs.table.name, getIndexName() + ByteBufferUtil.string(columnName));
        } else {
            SystemTable.setIndexBuilt(baseCfs.table.name, getIndexName());
        }
    } catch (InterruptedException e) {
        throw new AssertionError(e);
    } catch (ExecutionException e) {
        throw new IOException(e);
    } finally {
        SSTableReader.releaseReferences(sstables);
    }
    logger.info("Index build of " + getIndexName() + " complete");
}
Also used : IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) ReducingKeyIterator(org.apache.cassandra.io.sstable.ReducingKeyIterator) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition) SSTableReader(org.apache.cassandra.io.sstable.SSTableReader)

Example 17 with ColumnDefinition

use of org.apache.cassandra.config.ColumnDefinition in project eiger by wlloyd.

the class KeysIndex method init.

public void init() {
    assert baseCfs != null && columnDefs != null;
    ColumnDefinition columnDef = columnDefs.iterator().next();
    CFMetaData indexedCfMetadata = CFMetaData.newIndexMetadata(baseCfs.metadata, columnDef, indexComparator());
    indexCfs = ColumnFamilyStore.createColumnFamilyStore(baseCfs.table, indexedCfMetadata.cfName, new LocalPartitioner(columnDef.getValidator()), indexedCfMetadata);
}
Also used : CFMetaData(org.apache.cassandra.config.CFMetaData) ColumnDefinition(org.apache.cassandra.config.ColumnDefinition)

Aggregations

ColumnDefinition (org.apache.cassandra.config.ColumnDefinition)17 ByteBuffer (java.nio.ByteBuffer)5 CFMetaData (org.apache.cassandra.config.CFMetaData)3 IOException (java.io.IOException)2 CellName (org.apache.cassandra.db.composites.CellName)2 Composite (org.apache.cassandra.db.composites.Composite)2 Options (com.tuplejump.stargate.lucene.Options)1 Properties (com.tuplejump.stargate.lucene.Properties)1 Type (com.tuplejump.stargate.lucene.Type)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfigurationException (org.apache.cassandra.config.ConfigurationException)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 KSMetaData (org.apache.cassandra.config.KSMetaData)1 CQL3Type (org.apache.cassandra.cql3.CQL3Type)1 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)1 CType (org.apache.cassandra.db.composites.CType)1 CellNameType (org.apache.cassandra.db.composites.CellNameType)1 ColumnSlice (org.apache.cassandra.db.filter.ColumnSlice)1 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)1