use of org.apache.cassandra.cql3.statements.IndexTarget in project cassandra by apache.
the class SchemaLoader method compositeIndexCFMD.
public static TableMetadata.Builder compositeIndexCFMD(String ksName, String cfName, boolean withRegularIndex, boolean withStaticIndex) throws ConfigurationException {
// the withIndex flag exists to allow tests index creation
// on existing columns
TableMetadata.Builder builder = TableMetadata.builder(ksName, cfName).addPartitionKeyColumn("key", AsciiType.instance).addClusteringColumn("c1", AsciiType.instance).addRegularColumn("birthdate", LongType.instance).addRegularColumn("notbirthdate", LongType.instance).addStaticColumn("static", LongType.instance).compression(getCompressionParameters());
Indexes.Builder indexes = Indexes.builder();
if (withRegularIndex) {
indexes.add(IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("birthdate", true), IndexTarget.Type.VALUES)), cfName + "_birthdate_key_index", IndexMetadata.Kind.COMPOSITES, Collections.EMPTY_MAP));
}
if (withStaticIndex) {
indexes.add(IndexMetadata.fromIndexTargets(Collections.singletonList(new IndexTarget(new ColumnIdentifier("static", true), IndexTarget.Type.VALUES)), cfName + "_static_index", IndexMetadata.Kind.COMPOSITES, Collections.EMPTY_MAP));
}
return builder.indexes(indexes.build());
}
use of org.apache.cassandra.cql3.statements.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).isCompound(false).isDense(true).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;
}
Aggregations