use of org.apache.cassandra.cql3.selection.Selection.Selectors in project cassandra by apache.
the class SelectStatement method process.
private ResultSet process(PartitionIterator partitions, QueryOptions options, Selectors selectors, int nowInSec, int userLimit) throws InvalidRequestException {
GroupMaker groupMaker = aggregationSpec == null ? null : aggregationSpec.newGroupMaker();
ResultSetBuilder result = new ResultSetBuilder(getResultMetadata(), selectors, groupMaker);
while (partitions.hasNext()) {
try (RowIterator partition = partitions.next()) {
processPartition(partition, options, result, nowInSec);
}
}
ResultSet cqlRows = result.build();
maybeWarn(result, options);
orderResults(cqlRows);
cqlRows.trim(userLimit);
return cqlRows;
}
use of org.apache.cassandra.cql3.selection.Selection.Selectors in project cassandra by apache.
the class ModificationStatement method buildCasFailureResultSet.
private static ResultSet buildCasFailureResultSet(RowIterator partition, Iterable<ColumnMetadata> columnsWithConditions, boolean isBatch, QueryOptions options, int nowInSeconds) {
TableMetadata metadata = partition.metadata();
Selection selection;
if (columnsWithConditions == null) {
selection = Selection.wildcard(metadata, false, false);
} else {
// We can have multiple conditions on the same columns (for collections) so use a set
// to avoid duplicate, but preserve the order just to it follows the order of IF in the query in general
Set<ColumnMetadata> defs = new LinkedHashSet<>();
// of batches for compatibility sakes).
if (isBatch)
Iterables.addAll(defs, metadata.primaryKeyColumns());
Iterables.addAll(defs, columnsWithConditions);
selection = Selection.forColumns(metadata, new ArrayList<>(defs), false);
}
Selectors selectors = selection.newSelectors(options);
ResultSetBuilder builder = new ResultSetBuilder(selection.getResultMetadata(), selectors);
SelectStatement.forSelection(metadata, selection).processPartition(partition, options, builder, nowInSeconds);
return builder.build();
}
use of org.apache.cassandra.cql3.selection.Selection.Selectors in project cassandra by apache.
the class SelectStatement method executeInternal.
public ResultMessage.Rows executeInternal(QueryState state, QueryOptions options, int nowInSec, long queryStartNanoTime) throws RequestExecutionException, RequestValidationException {
int userLimit = getLimit(options);
int userPerPartitionLimit = getPerPartitionLimit(options);
int pageSize = options.getPageSize();
Selectors selectors = selection.newSelectors(options);
ReadQuery query = getQuery(options, state.getClientState(), selectors.getColumnFilter(), nowInSec, userLimit, userPerPartitionLimit, pageSize);
try (ReadExecutionController executionController = query.executionController()) {
if (aggregationSpec == null && (pageSize <= 0 || (query.limits().count() <= pageSize))) {
try (PartitionIterator data = query.executeInternal(executionController)) {
return processResults(data, options, selectors, nowInSec, userLimit);
}
}
QueryPager pager = getPager(query, options);
return execute(state, Pager.forInternalQuery(pager, executionController), options, selectors, pageSize, nowInSec, userLimit, queryStartNanoTime);
}
}
use of org.apache.cassandra.cql3.selection.Selection.Selectors in project cassandra by apache.
the class SelectStatement method execute.
public ResultMessage.Rows execute(QueryState state, QueryOptions options, long queryStartNanoTime) {
ConsistencyLevel cl = options.getConsistency();
checkNotNull(cl, "Invalid empty consistency level");
cl.validateForRead();
int nowInSec = options.getNowInSeconds(state);
int userLimit = getLimit(options);
int userPerPartitionLimit = getPerPartitionLimit(options);
int pageSize = options.getPageSize();
Selectors selectors = selection.newSelectors(options);
ReadQuery query = getQuery(options, state.getClientState(), selectors.getColumnFilter(), nowInSec, userLimit, userPerPartitionLimit, pageSize);
if (options.isTrackWarningsEnabled())
query.trackWarnings();
if (aggregationSpec == null && (pageSize <= 0 || (query.limits().count() <= pageSize)))
return execute(query, options, state, selectors, nowInSec, userLimit, queryStartNanoTime);
QueryPager pager = getPager(query, options);
return execute(state, Pager.forDistributedQuery(pager, cl, state.getClientState()), options, selectors, pageSize, nowInSec, userLimit, queryStartNanoTime);
}
use of org.apache.cassandra.cql3.selection.Selection.Selectors in project cassandra by apache.
the class SelectStatement method process.
public ResultSet process(PartitionIterator partitions, int nowInSec) throws InvalidRequestException {
QueryOptions options = QueryOptions.DEFAULT;
Selectors selectors = selection.newSelectors(options);
return process(partitions, options, selectors, nowInSec, getLimit(options));
}
Aggregations