Interface DynamoDbIndex<T>
-
- Type Parameters:
T
- The type of the modelled object.
- All Known Implementing Classes:
DefaultDynamoDbIndex
@ThreadSafe public interface DynamoDbIndex<T>
Synchronous interface for running commands against an object that is linked to a specific DynamoDb secondary index and knows how to map records from the table that index is linked to into a modelled object.By default, all command methods throw an
UnsupportedOperationException
to prevent interface extensions from breaking implementing classes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
indexName()
Gets the physical secondary index name that operations performed by this object will be executed against.Key
keyFrom(T item)
Creates aKey
object from a modelled item.DynamoDbEnhancedClientExtension
mapperExtension()
Gets theDynamoDbEnhancedClientExtension
associated with this mapped resource.default SdkIterable<Page<T>>
query(Consumer<QueryEnhancedRequest.Builder> requestConsumer)
Executes a query against a secondary index using aQueryConditional
expression to retrieve a list of items matching the given conditions.default SdkIterable<Page<T>>
query(QueryConditional queryConditional)
Executes a query against the secondary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.default SdkIterable<Page<T>>
query(QueryEnhancedRequest request)
Executes a query against a secondary index using aQueryConditional
expression to retrieve a list of items matching the given conditions.default SdkIterable<Page<T>>
scan()
Scans the table against a secondary index and retrieves all items using default settings.default SdkIterable<Page<T>>
scan(Consumer<ScanEnhancedRequest.Builder> requestConsumer)
Scans the table against a secondary index and retrieves all items.default SdkIterable<Page<T>>
scan(ScanEnhancedRequest request)
Scans the table against a secondary index and retrieves all items.String
tableName()
Gets the physical table name that operations performed by this object will be executed against.TableSchema<T>
tableSchema()
Gets theTableSchema
object that this mapped table was built with.
-
-
-
Method Detail
-
query
default SdkIterable<Page<T>> query(QueryEnhancedRequest request)
Executes a query against a secondary index using aQueryConditional
expression to retrieve a list of items matching the given conditions.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page. Results are sorted by sort key value in ascending order by default; this behavior can be overridden in theQueryEnhancedRequest
.The additional configuration parameters that the enhanced client supports are defined in the
QueryEnhancedRequest
.This operation calls the low-level DynamoDB API Query operation. Consult the Query documentation for further details and constraints.
Example:
QueryConditional queryConditional = QueryConditional.keyEqualTo(Key.builder().partitionValue("id-value").build()); Iterator<Page<MyItem>> results = mappedIndex.query(QueryEnhancedRequest.builder() .queryConditional(queryConditional) .build());
- Parameters:
request
- AQueryEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
query
default SdkIterable<Page<T>> query(Consumer<QueryEnhancedRequest.Builder> requestConsumer)
Executes a query against a secondary index using aQueryConditional
expression to retrieve a list of items matching the given conditions.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page. Results are sorted by sort key value in ascending order by default; this behavior can be overridden in theQueryEnhancedRequest
.The additional configuration parameters that the enhanced client supports are defined in the
QueryEnhancedRequest
.This operation calls the low-level DynamoDB API Query operation. Consult the Query documentation for further details and constraints.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
QueryEnhancedRequest.builder()
.Example:
Iterator<Page<MyItem>> results = mappedIndex.query(r -> r.queryConditional(QueryConditional.keyEqualTo(k -> k.partitionValue("id-value"))));
- Parameters:
requestConsumer
- AConsumer
ofQueryEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
query
default SdkIterable<Page<T>> query(QueryConditional queryConditional)
Executes a query against the secondary index of the table using aQueryConditional
expression to retrieve a list of items matching the given conditions.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a query call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page. Results are sorted by sort key value in ascending order.This operation calls the low-level DynamoDB API Query operation. Consult the Query documentation for further details and constraints.
Example:
Iterator<Page<MyItem>> results = mappedIndex.query(QueryConditional.keyEqualTo(Key.builder().partitionValue("id-value").build()));
- Parameters:
queryConditional
- AQueryConditional
defining the matching criteria for records to be queried.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
scan
default SdkIterable<Page<T>> scan(ScanEnhancedRequest request)
Scans the table against a secondary index and retrieves all items.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a scan call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page.The additional configuration parameters that the enhanced client supports are defined in the
ScanEnhancedRequest
.Example:
Iterator<Page<MyItem>> results = mappedTable.scan(ScanEnhancedRequest.builder().consistentRead(true).build());
- Parameters:
request
- AScanEnhancedRequest
defining how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
scan
default SdkIterable<Page<T>> scan(Consumer<ScanEnhancedRequest.Builder> requestConsumer)
Scans the table against a secondary index and retrieves all items.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a scan call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page.The additional configuration parameters that the enhanced client supports are defined in the
ScanEnhancedRequest
.Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
ScanEnhancedRequest.builder()
.Example:
Iterator<Page<MyItem>> results = mappedTable.scan(r -> r.limit(5));
- Parameters:
requestConsumer
- AConsumer
ofScanEnhancedRequest
defining the query conditions and how to handle the results.- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
scan
default SdkIterable<Page<T>> scan()
Scans the table against a secondary index and retrieves all items using default settings.The result is accessed through iterable pages (see
Page
) in an interactive way; each time a result page is retrieved, a scan call is made to DynamoDb to get those entries. If no matches are found, the resulting iterator will contain an empty page.Example:
Iterator<Page<MyItem>> results = mappedTable.scan();
- Returns:
- an iterator of type
SdkIterable
with paginated results (seePage
).
-
mapperExtension
DynamoDbEnhancedClientExtension mapperExtension()
Gets theDynamoDbEnhancedClientExtension
associated with this mapped resource.- Returns:
- The
DynamoDbEnhancedClientExtension
associated with this mapped resource.
-
tableSchema
TableSchema<T> tableSchema()
Gets theTableSchema
object that this mapped table was built with.- Returns:
- The
TableSchema
object for this mapped table.
-
tableName
String tableName()
Gets the physical table name that operations performed by this object will be executed against.- Returns:
- The physical table name.
-
indexName
String indexName()
Gets the physical secondary index name that operations performed by this object will be executed against.- Returns:
- The physical secondary index name.
-
keyFrom
Key keyFrom(T item)
Creates aKey
object from a modelled item. This key can be used in query conditionals and get operations to locate a specific record.- Parameters:
item
- The item to extract the key fields from.- Returns:
- A key that has been initialized with the index values extracted from the modelled object.
-
-