Search in sources :

Example 1 with TimeQuotaExceededException

use of org.apache.cassandra.index.sasi.exceptions.TimeQuotaExceededException in project cassandra by apache.

the class SASIIndexTest method testSearchTimeouts.

@Test
public void testSearchTimeouts() {
    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 = PartitionRangeReadCommand.create(store.metadata(), FBUtilities.nowInSeconds(), ColumnFilter.all(store.metadata()), filter, DataLimits.NONE, DataRange.allData(store.metadata().partitioner));
    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(MILLISECONDS)).execute(controller));
        assertRows(rows, "key1", "key2", "key3", "key4");
    }
}
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) IOException(java.io.IOException) 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

IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RowFilter (org.apache.cassandra.db.filter.RowFilter)1 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)1 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)1 TimeQuotaExceededException (org.apache.cassandra.index.sasi.exceptions.TimeQuotaExceededException)1 QueryPlan (org.apache.cassandra.index.sasi.plan.QueryPlan)1 MarshalException (org.apache.cassandra.serializers.MarshalException)1 Pair (org.apache.cassandra.utils.Pair)1