Search in sources :

Example 11 with IndexTarget

use of org.apache.cassandra.cql3.statements.schema.IndexTarget in project cassandra by apache.

the class SchemaLoader method customIndexCFMD.

public static TableMetadata.Builder customIndexCFMD(String ksName, String cfName) {
    TableMetadata.Builder builder = TableMetadata.builder(ksName, cfName).addPartitionKeyColumn("key", AsciiType.instance).addClusteringColumn("c1", AsciiType.instance).addRegularColumn("value", LongType.instance).compression(getCompressionParameters());
    IndexMetadata index = IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("value", true), IndexTarget.Type.VALUES)), cfName + "_value_index", IndexMetadata.Kind.CUSTOM, Collections.singletonMap(IndexTarget.CUSTOM_INDEX_OPTION_NAME, StubIndex.class.getName()));
    builder.indexes(Indexes.of(index));
    return builder;
}
Also used : IndexTarget(org.apache.cassandra.cql3.statements.schema.IndexTarget) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier)

Aggregations

IndexTarget (org.apache.cassandra.cql3.statements.schema.IndexTarget)10 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)7 TableMetadata (org.apache.cassandra.schema.TableMetadata)5 Test (org.junit.Test)5 IndexMetadata (org.apache.cassandra.schema.IndexMetadata)4 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)3 ByteBuffer (java.nio.ByteBuffer)2 java.util (java.util)2 Future (java.util.concurrent.Future)2 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)2 StubIndex (org.apache.cassandra.index.StubIndex)2 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables.transform (com.google.common.collect.Iterables.transform)1 Iterables.tryFind (com.google.common.collect.Iterables.tryFind)1 Iterators (com.google.common.collect.Iterators)1 Lists (com.google.common.collect.Lists)1 ExecutionException (java.util.concurrent.ExecutionException)1 SchemaLoader (org.apache.cassandra.SchemaLoader)1