All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.storage.dynamo.request.QueryRequest Maven / Gradle / Ivy

Go to download

A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases

There is a newer version: 3.14.0
Show newest version
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();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy