Search in sources :

Example 1 with Selection

use of com.scalar.db.api.Selection in project scalardb by scalar-labs.

the class SelectStatementHandler method execute.

@Override
@Nonnull
protected List<Record> execute(Operation operation) throws CosmosException, ExecutionException {
    assert operation instanceof Selection;
    Selection selection = (Selection) operation;
    TableMetadata tableMetadata = metadataManager.getTableMetadata(operation);
    try {
        if (selection instanceof Get) {
            return executeRead((Get) selection, tableMetadata);
        } else {
            return executeQuery((Scan) selection, tableMetadata);
        }
    } catch (CosmosException e) {
        if (e.getStatusCode() == CosmosErrorCode.NOT_FOUND.get()) {
            return Collections.emptyList();
        }
        throw e;
    }
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) Selection(com.scalar.db.api.Selection) Get(com.scalar.db.api.Get) CosmosException(com.azure.cosmos.CosmosException) Nonnull(javax.annotation.Nonnull)

Aggregations

CosmosException (com.azure.cosmos.CosmosException)1 Get (com.scalar.db.api.Get)1 Selection (com.scalar.db.api.Selection)1 TableMetadata (com.scalar.db.api.TableMetadata)1 Nonnull (javax.annotation.Nonnull)1