Class ScanBuilder<T>
java.lang.Object
dev.hogwai.dynamodb.simplified.builder.base.AbstractScanBuilder<T, ScanBuilder<T>>
dev.hogwai.dynamodb.simplified.builder.ScanBuilder<T>
- Type Parameters:
T- the type of the item
A fluent builder for scanning a DynamoDB table with optional filter, projection,
parallel scan segments, and pagination. Part of the DynamoDB Simplified library.
-
Field Summary
Fields inherited from class AbstractScanBuilder
consistentRead, exclusiveStartKey, filterExpression, limit, projectionExpression, returnConsumedCapacity, segment, select, totalSegments -
Constructor Summary
ConstructorsConstructorDescriptionScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbIndex<T> index) Constructs a newScanBuilderfor the given secondary index.ScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbIndex<T> index, @Nullable software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newScanBuilderfor the given secondary index with a low-level client.ScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table) Constructs a newScanBuilderfor the given table.ScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @Nullable software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newScanBuilderfor the given table with a low-level client. -
Method Summary
Modifier and TypeMethodDescriptionlongcount()Returns the total number of items by iterating all scan result pages.Executes the scan and returns all matching items aggregated from all pages.Executes the scan and returns the first matching item, if any.Executes the scan and returns a lazyStreamof all matching items.@NonNull PagedResult<T> Executes the scan and returns only the first page of results along with the last evaluated key for pagination.protected @Nullable StringReturns the DynamoDB index name, ornullif the scan targets the base table.protected @NonNull ScanBuilder<T> self()Returnsthistyped asSfor fluent chaining.protected @NonNull StringReturns the DynamoDB table name.Methods inherited from class AbstractScanBuilder
buildCountRequest, buildScanRequest, consistentRead, filter, filter, filter, limit, parallelScan, project, project, returnConsumedCapacity, select, startFrom
-
Constructor Details
-
ScanBuilder
Constructs a newScanBuilderfor the given table.- Parameters:
table- the DynamoDB table
-
ScanBuilder
Constructs a newScanBuilderfor the given secondary index.- Parameters:
index- the DynamoDB index
-
ScanBuilder
public ScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable<T> table, @Nullable software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newScanBuilderfor the given table with a low-level client.- Parameters:
table- the DynamoDB tabledynamoDbClient- the low-level DynamoDB client (nullable)
-
ScanBuilder
public ScanBuilder(@NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbIndex<T> index, @Nullable software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient) Constructs a newScanBuilderfor the given secondary index with a low-level client.- Parameters:
index- the DynamoDB indexdynamoDbClient- the low-level DynamoDB client (nullable)
-
-
Method Details
-
self
Description copied from class:AbstractScanBuilderReturnsthistyped asSfor fluent chaining.- Specified by:
selfin classAbstractScanBuilder<T, ScanBuilder<T>>- Returns:
- this builder
-
tableName
Description copied from class:AbstractScanBuilderReturns the DynamoDB table name.- Specified by:
tableNamein classAbstractScanBuilder<T, ScanBuilder<T>>- Returns:
- the DynamoDB table name
-
indexName
Description copied from class:AbstractScanBuilderReturns the DynamoDB index name, ornullif the scan targets the base table.- Specified by:
indexNamein classAbstractScanBuilder<T, ScanBuilder<T>>- Returns:
- the index name, or
nullfor the base table
-
executeAll
Executes the scan and returns all matching items aggregated from all pages.Warning: This method loads all results into memory. For large result sets, consider using
executeStream()for lazy streaming or paginate manually withexecuteWithPagination().- Returns:
- a list of matching items
-
executeAndGetFirst
-
executeStream
-
executeWithPagination
Executes the scan and returns only the first page of results along with the last evaluated key for pagination.- Returns:
- a
PagedResultcontaining the first page of items and the last evaluated key (may benullif no more pages)
-
count
public long count()Returns the total number of items by iterating all scan result pages.When a low-level
DynamoDbClientis available, usesSelect.COUNTserver-side to avoid transferring item data. Falls back to the enhanced client page iteration otherwise.- Returns:
- the total count of scanned items matching the filter
-