use of org.apache.cassandra.cql3.ResultSet in project cassandra by apache.
the class ModificationStatement method buildCasFailureResultSet.
private static ResultSet buildCasFailureResultSet(RowIterator partition, Iterable<ColumnMetadata> columnsWithConditions, boolean isBatch, QueryOptions options) throws InvalidRequestException {
TableMetadata metadata = partition.metadata();
Selection selection;
if (columnsWithConditions == null) {
selection = Selection.wildcard(metadata);
} 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));
}
Selection.ResultSetBuilder builder = selection.resultSetBuilder(options, false);
SelectStatement.forSelection(metadata, selection).processPartition(partition, options, builder, FBUtilities.nowInSeconds());
return builder.build();
}
use of org.apache.cassandra.cql3.ResultSet in project cassandra by apache.
the class SelectStatement method process.
private ResultSet process(PartitionIterator partitions, QueryOptions options, int nowInSec, int userLimit) throws InvalidRequestException {
Selection.ResultSetBuilder result = selection.resultSetBuilder(options, parameters.isJson, aggregationSpec);
while (partitions.hasNext()) {
try (RowIterator partition = partitions.next()) {
processPartition(partition, options, result, nowInSec);
}
}
ResultSet cqlRows = result.build();
orderResults(cqlRows);
cqlRows.trim(userLimit);
return cqlRows;
}
use of org.apache.cassandra.cql3.ResultSet in project cassandra by apache.
the class SystemKeyspace method loadPreparedStatements.
public static List<Pair<String, String>> loadPreparedStatements() {
String query = format("SELECT logged_keyspace, query_string FROM %s", PreparedStatements.toString());
UntypedResultSet resultSet = executeOnceInternal(query);
List<Pair<String, String>> r = new ArrayList<>();
for (UntypedResultSet.Row row : resultSet) r.add(Pair.create(row.has("logged_keyspace") ? row.getString("logged_keyspace") : null, row.getString("query_string")));
return r;
}
use of org.apache.cassandra.cql3.ResultSet in project cassandra by apache.
the class CompactionHistoryTabularData method from.
public static TabularData from(UntypedResultSet resultSet) throws OpenDataException {
TabularDataSupport result = new TabularDataSupport(TABULAR_TYPE);
for (UntypedResultSet.Row row : resultSet) {
UUID id = row.getUUID(ITEM_NAMES[0]);
String ksName = row.getString(ITEM_NAMES[1]);
String cfName = row.getString(ITEM_NAMES[2]);
long compactedAt = row.getLong(ITEM_NAMES[3]);
long bytesIn = row.getLong(ITEM_NAMES[4]);
long bytesOut = row.getLong(ITEM_NAMES[5]);
Map<Integer, Long> rowMerged = row.getMap(ITEM_NAMES[6], Int32Type.instance, LongType.instance);
result.put(new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { id.toString(), ksName, cfName, compactedAt, bytesIn, bytesOut, "{" + FBUtilities.toString(rowMerged) + "}" }));
}
return result;
}
use of org.apache.cassandra.cql3.ResultSet 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;
}
Aggregations