com.scalar.db.storage.dynamo.request.QueryRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalardb Show documentation
Show all versions of scalardb Show documentation
A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases
package com.scalar.db.storage.dynamo.request;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
public class QueryRequest implements PaginatedRequest {
private final software.amazon.awssdk.services.dynamodb.model.QueryRequest dynamoRequest;
private final DynamoDbClient client;
@SuppressFBWarnings("EI_EXPOSE_REP2")
public QueryRequest(
DynamoDbClient client,
software.amazon.awssdk.services.dynamodb.model.QueryRequest dynamoRequest) {
this.client = client;
this.dynamoRequest = dynamoRequest;
}
@Override
public PaginatedRequestResponse execute(Map exclusiveStartKey) {
QueryRequest request =
new QueryRequest(
this.client,
this.dynamoRequest.toBuilder().exclusiveStartKey(exclusiveStartKey).build());
return request.execute();
}
@Override
public PaginatedRequestResponse execute() {
QueryResponse response = client.query(dynamoRequest);
return new PaginatedRequestResponse(
response.items(), response.hasLastEvaluatedKey(), response.lastEvaluatedKey());
}
@Override
public Integer limit() {
return dynamoRequest.limit();
}
}