Class AbstractScanBuilder<T, S extends AbstractScanBuilder<T,S>>

java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractScanBuilder<T,S>
Type Parameters:
T - the item type
S - the concrete builder type (for fluent chaining)
Direct Known Subclasses:
AsyncScanBuilder, ScanBuilder

public abstract class AbstractScanBuilder<T, S extends AbstractScanBuilder<T,S>> extends Object
Abstract base for sync and async scan builders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Boolean
    Whether to use strongly consistent reads (false by default).
    protected Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue>
    Exclusive start key for paginated scans.
    Optional filter expression applied after the scan.
    protected Integer
    Maximum number of items to evaluate per page.
    protected static final org.slf4j.Logger
    Logger for this builder class.
    Optional projection expression to restrict returned attributes.
    protected software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity
    Optional consumed capacity reporting level.
    protected Integer
    The segment index for this scan worker (0-based).
    protected software.amazon.awssdk.services.dynamodb.model.Select
    Optional select parameter controlling which attributes are returned.
    protected Integer
    Total number of segments for a parallel scan.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new AbstractScanBuilder.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected @NonNull software.amazon.awssdk.services.dynamodb.model.ScanRequest
    buildCountRequest(@NonNull software.amazon.awssdk.services.dynamodb.model.Select select)
    Builds a low-level ScanRequest for count operations using the given Select mode.
    protected @NonNull software.amazon.awssdk.enhanced.dynamodb.model.ScanEnhancedRequest
    Builds a high-level ScanEnhancedRequest from the configured parameters.
    @NonNull S
    consistentRead(boolean consistentRead)
    Enables or disables strongly consistent reads.
    @NonNull S
    filter(@Nullable FilterExpression filter)
    Configures a scan filter expression from a pre-built FilterExpression.
    @NonNull S
    filter(@NonNull Map<String,Object> conditions)
    Configures a scan filter from a map of attribute-value pairs.
    @NonNull S
    filter(@NonNull Consumer<FilterExpression> filterBuilder)
    Configures a scan filter expression using a FilterExpression consumer.
    protected abstract @Nullable String
    Returns the DynamoDB index name, or null if the scan targets the base table.
    @NonNull S
    limit(int limit)
    Limits the number of items evaluated per page.
    @NonNull S
    parallelScan(int totalSegments, int segment)
    Configures a parallel scan by specifying the total number of segments and the segment index for this scan worker.
    @NonNull S
    project(@NonNull String... attributes)
    Restricts the returned attributes to the specified ones.
    @NonNull S
    project(@NonNull Consumer<ProjectionExpression> projectionBuilder)
    Restricts the returned attributes by configuring a ProjectionExpression via a consumer.
    @NonNull S
    returnConsumedCapacity(@NonNull software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity returnConsumedCapacity)
    Configures the level of consumed capacity that should be returned by the scan.
    @NonNull S
    select(@Nullable software.amazon.awssdk.services.dynamodb.model.Select select)
    Sets the select parameter for the scan, controlling which attributes are returned.
    protected abstract S
    Returns this typed as S for fluent chaining.
    @NonNull S
    startFrom(@Nullable Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> lastEvaluatedKey)
    Sets the exclusive start key for paginated scans.
    protected abstract @NonNull String
    Returns the DynamoDB table name.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger for this builder class.
    • filterExpression

      protected FilterExpression filterExpression
      Optional filter expression applied after the scan.
    • projectionExpression

      protected ProjectionExpression projectionExpression
      Optional projection expression to restrict returned attributes.
    • limit

      protected Integer limit
      Maximum number of items to evaluate per page.
    • exclusiveStartKey

      protected Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> exclusiveStartKey
      Exclusive start key for paginated scans.
    • consistentRead

      protected Boolean consistentRead
      Whether to use strongly consistent reads (false by default).
    • returnConsumedCapacity

      protected software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity returnConsumedCapacity
      Optional consumed capacity reporting level.
    • select

      protected software.amazon.awssdk.services.dynamodb.model.Select select
      Optional select parameter controlling which attributes are returned.
    • totalSegments

      protected Integer totalSegments
      Total number of segments for a parallel scan.
    • segment

      protected Integer segment
      The segment index for this scan worker (0-based).
  • Constructor Details

    • AbstractScanBuilder

      protected AbstractScanBuilder()
      Constructs a new AbstractScanBuilder.
  • Method Details

    • self

      protected abstract S self()
      Returns this typed as S for fluent chaining.
      Returns:
      this builder
    • tableName

      protected abstract @NonNull String tableName()
      Returns the DynamoDB table name.
      Returns:
      the DynamoDB table name
    • indexName

      protected abstract @Nullable String indexName()
      Returns the DynamoDB index name, or null if the scan targets the base table.
      Returns:
      the index name, or null for the base table
    • filter

      public @NonNull S filter(@NonNull Consumer<FilterExpression> filterBuilder)
      Configures a scan filter expression using a FilterExpression consumer.
      Parameters:
      filterBuilder - a consumer that configures the FilterExpression
      Returns:
      this builder for chaining
    • filter

      public @NonNull S filter(@Nullable FilterExpression filter)
      Configures a scan filter expression from a pre-built FilterExpression.
      Parameters:
      filter - the filter expression
      Returns:
      this builder for chaining
    • filter

      public @NonNull S filter(@NonNull Map<String,Object> conditions)
      Configures a scan filter from a map of attribute-value pairs.

      All conditions are combined with AND. Each entry is treated as an equality filter. For other condition types, use filter(Consumer).

      Parameters:
      conditions - a map of attribute names to their expected values
      Returns:
      this builder for chaining
    • project

      public @NonNull S project(@NonNull String... attributes)
      Restricts the returned attributes to the specified ones.
      Parameters:
      attributes - the attribute names to include in the result
      Returns:
      this builder for chaining
    • project

      public @NonNull S project(@NonNull Consumer<ProjectionExpression> projectionBuilder)
      Restricts the returned attributes by configuring a ProjectionExpression via a consumer.
      Parameters:
      projectionBuilder - a consumer that configures the ProjectionExpression
      Returns:
      this builder for chaining
    • parallelScan

      public @NonNull S parallelScan(int totalSegments, int segment)
      Configures a parallel scan by specifying the total number of segments and the segment index for this scan worker.
      Parameters:
      totalSegments - the total number of segments to divide the table into
      segment - the segment index for this worker (0-based)
      Returns:
      this builder for chaining
    • limit

      public @NonNull S limit(int limit)
      Limits the number of items evaluated per page.
      Parameters:
      limit - the maximum number of items to evaluate per page
      Returns:
      this builder for chaining
    • startFrom

      public @NonNull S startFrom(@Nullable Map<String, software.amazon.awssdk.services.dynamodb.model.AttributeValue> lastEvaluatedKey)
      Sets the exclusive start key for paginated scans. Typically obtained from the PagedResult.lastEvaluatedKey() of a previous scan.
      Parameters:
      lastEvaluatedKey - the key map from which to start the next page
      Returns:
      this builder for chaining
    • consistentRead

      public @NonNull S consistentRead(boolean consistentRead)
      Enables or disables strongly consistent reads.
      Parameters:
      consistentRead - true for a strongly consistent read, false (the default) for an eventually consistent read
      Returns:
      this builder for chaining
    • returnConsumedCapacity

      public @NonNull S returnConsumedCapacity(@NonNull software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity returnConsumedCapacity)
      Configures the level of consumed capacity that should be returned by the scan.
      Parameters:
      returnConsumedCapacity - the ReturnConsumedCapacity value
      Returns:
      this builder for chaining
    • select

      public @NonNull S select(@Nullable software.amazon.awssdk.services.dynamodb.model.Select select)
      Sets the select parameter for the scan, controlling which attributes are returned. Use Select.COUNT to request only the item count from the server.
      Parameters:
      select - the select parameter (nullable)
      Returns:
      this builder for chaining
    • buildScanRequest

      protected @NonNull software.amazon.awssdk.enhanced.dynamodb.model.ScanEnhancedRequest buildScanRequest()
      Builds a high-level ScanEnhancedRequest from the configured parameters.
      Returns:
      the built scan request
    • buildCountRequest

      protected @NonNull software.amazon.awssdk.services.dynamodb.model.ScanRequest buildCountRequest(@NonNull software.amazon.awssdk.services.dynamodb.model.Select select)
      Builds a low-level ScanRequest for count operations using the given Select mode.
      Parameters:
      select - the select mode (typically Select.COUNT)
      Returns:
      the built scan request