Search in sources :

Example 1 with QueryPlan

use of org.apache.cassandra.index.sasi.plan.QueryPlan in project cassandra by apache.

the class SASIIndex method searcherFor.

public Searcher searcherFor(ReadCommand command) throws InvalidRequestException {
    TableMetadata config = command.metadata();
    ColumnFamilyStore cfs = Schema.instance.getColumnFamilyStoreInstance(config.id);
    return controller -> new QueryPlan(cfs, command, DatabaseDescriptor.getRangeRpcTimeout()).execute(controller);
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) org.apache.cassandra.config(org.apache.cassandra.config) java.util(java.util) CompactionManager(org.apache.cassandra.db.compaction.CompactionManager) PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate) ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) BiFunction(java.util.function.BiFunction) org.apache.cassandra.db(org.apache.cassandra.db) PerSSTableIndexWriter(org.apache.cassandra.index.sasi.disk.PerSSTableIndexWriter) Callable(java.util.concurrent.Callable) AbstractType(org.apache.cassandra.db.marshal.AbstractType) QueryPlan(org.apache.cassandra.index.sasi.plan.QueryPlan) SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Tracker(org.apache.cassandra.db.lifecycle.Tracker) Schema(org.apache.cassandra.schema.Schema) OpOrder(org.apache.cassandra.utils.concurrent.OpOrder) Row(org.apache.cassandra.db.rows.Row) Operator(org.apache.cassandra.cql3.Operator) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) OperationType(org.apache.cassandra.db.compaction.OperationType) Pair(org.apache.cassandra.utils.Pair) Murmur3Partitioner(org.apache.cassandra.dht.Murmur3Partitioner) Descriptor(org.apache.cassandra.io.sstable.Descriptor) IndexTarget(org.apache.cassandra.cql3.statements.IndexTarget) IndexMode(org.apache.cassandra.index.sasi.conf.IndexMode) Index(org.apache.cassandra.index.Index) InvalidRequestException(org.apache.cassandra.exceptions.InvalidRequestException) ColumnIndex(org.apache.cassandra.index.sasi.conf.ColumnIndex) TargetParser(org.apache.cassandra.index.TargetParser) RowFilter(org.apache.cassandra.db.filter.RowFilter) Mode(org.apache.cassandra.index.sasi.disk.OnDiskIndexBuilder.Mode) IndexTransaction(org.apache.cassandra.index.transactions.IndexTransaction) FBUtilities(org.apache.cassandra.utils.FBUtilities) org.apache.cassandra.notifications(org.apache.cassandra.notifications) IndexMetadata(org.apache.cassandra.schema.IndexMetadata) IndexRegistry(org.apache.cassandra.index.IndexRegistry) Iterables(com.googlecode.concurrenttrees.common.Iterables) SecondaryIndexBuilder(org.apache.cassandra.index.SecondaryIndexBuilder) SSTableFlushObserver(org.apache.cassandra.io.sstable.format.SSTableFlushObserver) TableMetadata(org.apache.cassandra.schema.TableMetadata) PartitionIterator(org.apache.cassandra.db.partitions.PartitionIterator) QueryPlan(org.apache.cassandra.index.sasi.plan.QueryPlan)

Example 2 with QueryPlan

use of org.apache.cassandra.index.sasi.plan.QueryPlan in project cassandra by apache.

the class SASIIndexTest method testSearchTimeouts.

@Test
public void testSearchTimeouts() throws Exception {
    final ByteBuffer firstName = UTF8Type.instance.decompose("first_name");
    Map<String, Pair<String, Integer>> data1 = new HashMap<String, Pair<String, Integer>>() {

        {
            put("key1", Pair.create("Pavel", 14));
            put("key2", Pair.create("Pavel", 26));
            put("key3", Pair.create("Pavel", 27));
            put("key4", Pair.create("Jason", 27));
        }
    };
    ColumnFamilyStore store = loadData(data1, true);
    RowFilter filter = RowFilter.create();
    filter.add(store.metadata().getColumn(firstName), Operator.LIKE_CONTAINS, AsciiType.instance.fromString("a"));
    ReadCommand command = new PartitionRangeReadCommand(store.metadata(), FBUtilities.nowInSeconds(), ColumnFilter.all(store.metadata()), filter, DataLimits.NONE, DataRange.allData(store.metadata().partitioner), Optional.empty());
    try {
        new QueryPlan(store, command, 0).execute(ReadExecutionController.empty());
        Assert.fail();
    } catch (TimeQuotaExceededException e) {
    // correct behavior
    } catch (Exception e) {
        Assert.fail();
        e.printStackTrace();
    }
    try (ReadExecutionController controller = command.executionController()) {
        Set<String> rows = getKeys(new QueryPlan(store, command, DatabaseDescriptor.getRangeRpcTimeout()).execute(controller));
        Assert.assertTrue(rows.toString(), Arrays.equals(new String[] { "key1", "key2", "key3", "key4" }, rows.toArray(new String[rows.size()])));
    }
}
Also used : QueryPlan(org.apache.cassandra.index.sasi.plan.QueryPlan) ByteBuffer(java.nio.ByteBuffer) TimeQuotaExceededException(org.apache.cassandra.index.sasi.exceptions.TimeQuotaExceededException) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) TimeQuotaExceededException(org.apache.cassandra.index.sasi.exceptions.TimeQuotaExceededException) InvalidRequestException(org.apache.cassandra.exceptions.InvalidRequestException) MarshalException(org.apache.cassandra.serializers.MarshalException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RowFilter(org.apache.cassandra.db.filter.RowFilter) Pair(org.apache.cassandra.utils.Pair)

Aggregations

RowFilter (org.apache.cassandra.db.filter.RowFilter)2 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)2 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)2 QueryPlan (org.apache.cassandra.index.sasi.plan.QueryPlan)2 Pair (org.apache.cassandra.utils.Pair)2 Iterables (com.googlecode.concurrenttrees.common.Iterables)1 ByteBuffer (java.nio.ByteBuffer)1 java.util (java.util)1 Callable (java.util.concurrent.Callable)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BiFunction (java.util.function.BiFunction)1 org.apache.cassandra.config (org.apache.cassandra.config)1 Operator (org.apache.cassandra.cql3.Operator)1 IndexTarget (org.apache.cassandra.cql3.statements.IndexTarget)1 org.apache.cassandra.db (org.apache.cassandra.db)1 CompactionManager (org.apache.cassandra.db.compaction.CompactionManager)1 OperationType (org.apache.cassandra.db.compaction.OperationType)1 Tracker (org.apache.cassandra.db.lifecycle.Tracker)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)1