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);
}
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()])));
}
}
Aggregations