use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class Cosmos method scan.
@Override
public Scanner scan(Scan scan) throws ExecutionException {
scan = copyAndSetTargetToIfNot(scan);
if (scan instanceof ScanAll) {
operationChecker.check((ScanAll) scan);
} else {
operationChecker.check(scan);
}
List<Record> records = selectStatementHandler.handle(scan);
TableMetadata metadata = metadataManager.getTableMetadata(scan);
return new ScannerImpl(records, new ResultInterpreter(scan.getProjections(), metadata));
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class SelectStatementHandler method prepare.
@Override
@Nonnull
protected PreparedStatement prepare(Operation operation) {
checkArgument(operation, Get.class, Scan.class, ScanAll.class);
Select select;
if (operation instanceof Get) {
select = prepare((Get) operation);
} else if (operation instanceof ScanAll) {
select = prepare((ScanAll) operation);
} else {
select = prepare((Scan) operation);
}
return prepare(select.getQueryString());
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class JdbcService method scan.
public List<Result> scan(Scan scan, Connection connection) throws SQLException, ExecutionException {
if (scan instanceof ScanAll) {
operationChecker.check((ScanAll) scan);
} else {
operationChecker.check(scan);
}
TableMetadata tableMetadata = tableMetadataManager.getTableMetadata(scan);
SelectQuery selectQuery = scan instanceof ScanAll ? buildSelectQueryForScanAll((ScanAll) scan, tableMetadata) : buildSelectQueryForScan(scan, tableMetadata);
try (PreparedStatement preparedStatement = connection.prepareStatement(selectQuery.sql())) {
selectQuery.bind(preparedStatement);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
List<Result> ret = new ArrayList<>();
ResultInterpreter resultInterpreter = new ResultInterpreter(scan.getProjections(), tableMetadata);
while (resultSet.next()) {
ret.add(resultInterpreter.interpret(resultSet));
}
return ret;
}
}
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class ScalarDbUtils method copyAndSetTargetToIfNot.
public static Scan copyAndSetTargetToIfNot(Scan scan, Optional<String> namespace, Optional<String> tableName) {
Scan ret;
if (scan instanceof ScanAll) {
// copy
ret = new ScanAll((ScanAll) scan);
} else {
// copy
ret = new Scan(scan);
}
setTargetToIfNot(ret, namespace, tableName);
return ret;
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class JdbcService method getScanner.
@SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE")
public Scanner getScanner(Scan scan, Connection connection) throws SQLException, ExecutionException {
if (scan instanceof ScanAll) {
operationChecker.check((ScanAll) scan);
} else {
operationChecker.check(scan);
}
TableMetadata tableMetadata = tableMetadataManager.getTableMetadata(scan);
SelectQuery selectQuery = scan instanceof ScanAll ? buildSelectQueryForScanAll((ScanAll) scan, tableMetadata) : buildSelectQueryForScan(scan, tableMetadata);
PreparedStatement preparedStatement = connection.prepareStatement(selectQuery.sql());
selectQuery.bind(preparedStatement);
ResultSet resultSet = preparedStatement.executeQuery();
return new ScannerImpl(new ResultInterpreter(scan.getProjections(), tableMetadata), connection, preparedStatement, resultSet);
}
Aggregations