use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class Cassandra method scan.
@Override
@Nonnull
public Scanner scan(Scan scan) throws ExecutionException {
scan = copyAndSetTargetToIfNot(scan);
if (scan instanceof ScanAll) {
operationChecker.check((ScanAll) scan);
} else {
operationChecker.check(scan);
}
ResultSet results = handlers.select().handle(scan);
return new ScannerImpl(results, new ResultInterpreter(scan.getProjections(), metadataManager.getTableMetadata(scan)));
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class SelectStatementHandler method executeQuery.
private List<Record> executeQuery(Scan scan, TableMetadata tableMetadata) throws CosmosException {
CosmosOperation cosmosOperation = new CosmosOperation(scan, tableMetadata);
String query;
CosmosQueryRequestOptions options;
if (scan instanceof ScanAll) {
query = makeQueryWithProjections(scan, tableMetadata).getSQL(ParamType.INLINED);
options = new CosmosQueryRequestOptions();
} else if (ScalarDbUtils.isSecondaryIndexSpecified(scan, tableMetadata)) {
query = makeQueryWithIndex(scan, tableMetadata);
options = new CosmosQueryRequestOptions();
} else {
query = makeQueryWithCondition(tableMetadata, cosmosOperation, scan);
options = new CosmosQueryRequestOptions().setPartitionKey(cosmosOperation.getCosmosPartitionKey());
}
if (scan.getLimit() > 0) {
// Add limit as a string
// because JOOQ doesn't support OFFSET LIMIT clause which Cosmos DB requires
query += " offset 0 limit " + scan.getLimit();
}
CosmosPagedIterable<Record> iterable = getContainer(scan).queryItems(query, options, Record.class);
return Lists.newArrayList(iterable);
}
Aggregations