Search in sources :

Example 1 with SecondaryIndexManager

use of org.apache.cassandra.index.SecondaryIndexManager in project cassandra by apache.

the class SecondaryIndexTest method createAndDropIndexWithQuotedColumnIdentifier.

private void createAndDropIndexWithQuotedColumnIdentifier(String target) throws Throwable {
    String indexName = "test_mixed_case_idx";
    createIndex(String.format("CREATE INDEX %s ON %%s(%s)", indexName, target));
    SecondaryIndexManager indexManager = getCurrentColumnFamilyStore().indexManager;
    IndexMetadata indexDef = indexManager.getIndexByName(indexName).getIndexMetadata();
    dropIndex(String.format("DROP INDEX %s.%s", KEYSPACE, indexName));
    // verify we can re-create the index using the target string
    createIndex(String.format("CREATE INDEX %s ON %%s(%s)", indexName, indexDef.options.get(IndexTarget.TARGET_OPTION_NAME)));
    assertEquals(indexDef, indexManager.getIndexByName(indexName).getIndexMetadata());
    dropIndex(String.format("DROP INDEX %s.%s", KEYSPACE, indexName));
}
Also used : SecondaryIndexManager(org.apache.cassandra.index.SecondaryIndexManager) IndexMetadata(org.apache.cassandra.schema.IndexMetadata)

Example 2 with SecondaryIndexManager

use of org.apache.cassandra.index.SecondaryIndexManager in project cassandra by apache.

the class JoinTokenRingTest method testIndexPreJoinInvocation.

@Test
public void testIndexPreJoinInvocation() throws IOException {
    StorageService ss = StorageService.instance;
    ss.joinRing();
    SecondaryIndexManager indexManager = ColumnFamilyStore.getIfExists("JoinTokenRingTestKeyspace7", "Indexed1").indexManager;
    StubIndex stub = (StubIndex) indexManager.getIndexByName("Indexed1_value_index");
    Assert.assertTrue(stub.preJoinInvocation);
}
Also used : StubIndex(org.apache.cassandra.index.StubIndex) SecondaryIndexManager(org.apache.cassandra.index.SecondaryIndexManager) Test(org.junit.Test)

Example 3 with SecondaryIndexManager

use of org.apache.cassandra.index.SecondaryIndexManager in project cassandra by apache.

the class SecondaryIndexTest method createAndDropCollectionValuesIndex.

private void createAndDropCollectionValuesIndex(String columnName) throws Throwable {
    String indexName = columnName + "_idx";
    SecondaryIndexManager indexManager = getCurrentColumnFamilyStore().indexManager;
    createIndex(String.format("CREATE INDEX %s on %%s(%s)", indexName, columnName));
    IndexMetadata indexDef = indexManager.getIndexByName(indexName).getIndexMetadata();
    assertEquals(String.format("values(%s)", columnName), indexDef.options.get(IndexTarget.TARGET_OPTION_NAME));
    dropIndex(String.format("DROP INDEX %s.%s", KEYSPACE, indexName));
    assertFalse(indexManager.hasIndexes());
    createIndex(String.format("CREATE INDEX %s on %%s(values(%s))", indexName, columnName));
    assertEquals(indexDef, indexManager.getIndexByName(indexName).getIndexMetadata());
    dropIndex(String.format("DROP INDEX %s.%s", KEYSPACE, indexName));
}
Also used : SecondaryIndexManager(org.apache.cassandra.index.SecondaryIndexManager) IndexMetadata(org.apache.cassandra.schema.IndexMetadata)

Example 4 with SecondaryIndexManager

use of org.apache.cassandra.index.SecondaryIndexManager in project cassandra by apache.

the class SelectStatement method getRowFilter.

/**
     * May be used by custom QueryHandler implementations
     */
public RowFilter getRowFilter(QueryOptions options) throws InvalidRequestException {
    ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(columnFamily());
    SecondaryIndexManager secondaryIndexManager = cfs.indexManager;
    RowFilter filter = restrictions.getRowFilter(secondaryIndexManager, options);
    return filter;
}
Also used : SecondaryIndexManager(org.apache.cassandra.index.SecondaryIndexManager)

Aggregations

SecondaryIndexManager (org.apache.cassandra.index.SecondaryIndexManager)4 IndexMetadata (org.apache.cassandra.schema.IndexMetadata)2 StubIndex (org.apache.cassandra.index.StubIndex)1 Test (org.junit.Test)1