Search in sources :

Example 1 with GetResponse

use of com.scalar.db.rpc.TwoPhaseCommitTransactionResponse.GetResponse in project scalardb by scalar-labs.

the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method get.

public Optional<Result> get(Get get) throws CrudException {
    throwIfTransactionFinished();
    ResponseOrError responseOrError = sendRequest(TwoPhaseCommitTransactionRequest.newBuilder().setGetRequest(GetRequest.newBuilder().setGet(ProtoUtils.toGet(get))).build());
    throwIfErrorForCrud(responseOrError);
    GetResponse getResponse = responseOrError.getResponse().getGetResponse();
    if (getResponse.hasResult()) {
        TableMetadata tableMetadata = getTableMetadata(get);
        return Optional.of(ProtoUtils.toResult(getResponse.getResult(), tableMetadata));
    }
    return Optional.empty();
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) GetResponse(com.scalar.db.rpc.TwoPhaseCommitTransactionResponse.GetResponse)

Aggregations

TableMetadata (com.scalar.db.api.TableMetadata)1 GetResponse (com.scalar.db.rpc.TwoPhaseCommitTransactionResponse.GetResponse)1