Class Index
- java.lang.Object
-
- com.amazonaws.services.dynamodbv2.document.Index
-
public class Index extends Object implements QueryApi, ScanApi
Represents a secondary index on a DynamoDB table. This covers both GSI (Global Secondary Index) and LSI (Local Secondary Index). Instance of this class can be obtained viaTable.getIndex(String)
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableDescription
deleteGSI()
Deletes this global secondary index (GSI) from the DynamoDB table.String
getIndexName()
Table
getTable()
Returns the owning table.ItemCollection<QueryOutcome>
query(KeyAttribute hashKey)
Retrieves items by the specified hash key.ItemCollection<QueryOutcome>
query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition)
Retrieves items by the specified hash key and a range key condition.ItemCollection<QueryOutcome>
query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters)
Retrieves items by the specified hash key, a range key condition and a list of query filters.ItemCollection<QueryOutcome>
query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryExpressionSpec queryExpressions)
ItemCollection<QueryOutcome>
query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String projectionExpression, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Retrieves items by the specified hash key, a range key condition, a filter expression and a projection expression.ItemCollection<QueryOutcome>
query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Retrieves items by the specified hash key, a range key condition, and a filter expression string.ItemCollection<QueryOutcome>
query(QuerySpec spec)
Queries table by specifying all the details.ItemCollection<QueryOutcome>
query(String hashKeyName, Object hashKeyValue)
Retrieves items by the specified hash key.ItemCollection<QueryOutcome>
query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition)
ItemCollection<QueryOutcome>
query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters)
ItemCollection<QueryOutcome>
query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, String filterExpression, String projectionExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Retrieves items by the specified hash key, a range key condition, a filter expression and a projection expression.ItemCollection<QueryOutcome>
query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
ItemCollection<ScanOutcome>
scan(ScanFilter... scanFilters)
Retrieves items by the specified list of scan filters.ItemCollection<ScanOutcome>
scan(ScanSpec params)
Scans table by specifying all the details.ItemCollection<ScanOutcome>
scan(ScanExpressionSpec xspec)
ItemCollection<ScanOutcome>
scan(String filterExpression, String projectionExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Scans table using a Filter Expression and a Projection Expression.ItemCollection<ScanOutcome>
scan(String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Scans table using a Filter Expression.TableDescription
updateGSI(ProvisionedThroughput provisionedThroughput)
Updates the provisioned throughput for this global secondary index (GSI).TableDescription
waitForActive()
A convenient blocking call that can be used, typically during index creation, to wait for the index to become active by polling the table every 5 seconds.TableDescription
waitForActiveOrDelete()
A convenient blocking call that can be used to wait on an index until it has either become active or deleted (ie no longer exists) by polling the table every 5 seconds.TableDescription
waitForDelete()
A convenient blocking call that can be used, typically during index deletion on an active table, to wait for the index to become deleted by polling the table every 5 seconds.
-
-
-
Method Detail
-
getTable
public final Table getTable()
Returns the owning table.
-
getIndexName
public final String getIndexName()
- Returns:
- the name of this index
-
query
public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition)
Description copied from interface:QueryApi
Retrieves items by the specified hash key and a range key condition.
-
query
public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters)
Description copied from interface:QueryApi
Retrieves items by the specified hash key, a range key condition and a list of query filters.
-
query
public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Description copied from interface:QueryApi
Retrieves items by the specified hash key, a range key condition, and a filter expression string.- Specified by:
query
in interfaceQueryApi
filterExpression
- filter expression example: "(#a > :a) AND (#c > :c OR #e < :e)"nameMap
- actual values for the attribute-name place holders; can be null if there is no attribute-name placeholder.valueMap
- actual values for the value place holders can be null if there is no attribute-value placeholder.
-
query
public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String projectionExpression, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Description copied from interface:QueryApi
Retrieves items by the specified hash key, a range key condition, a filter expression and a projection expression.- Specified by:
query
in interfaceQueryApi
projectionExpression
- filter expression example: "(#a > :a) AND (#c > :c OR #e < :e)"filterExpression
- projection expression example: "a.b, c[0].e"nameMap
- actual values for the attribute-name place holders; can be null if there is no attribute-name placeholder.valueMap
- actual values for the value place holders can be null if there is no attribute-value placeholder.
-
query
@Beta public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryExpressionSpec queryExpressions)
-
query
public ItemCollection<QueryOutcome> query(QuerySpec spec)
Description copied from interface:QueryApi
Queries table by specifying all the details.
-
query
public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKeyValue)
Description copied from interface:QueryApi
Retrieves items by the specified hash key.
-
query
public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition)
-
query
public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters)
-
query
public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
-
query
public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKeyValue, RangeKeyCondition rangeKeyCondition, String filterExpression, String projectionExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Description copied from interface:QueryApi
Retrieves items by the specified hash key, a range key condition, a filter expression and a projection expression.- Specified by:
query
in interfaceQueryApi
filterExpression
- filter expression example: "(#a > :a) AND (#c > :c OR #e < :e)"projectionExpression
- projection expression example: "a.b, c[0].e"nameMap
- actual values for the attribute-name place holders; can be null if there is no attribute-name placeholder.valueMap
- actual values for the value place holders can be null if there is no attribute-value placeholder.
-
query
public ItemCollection<QueryOutcome> query(KeyAttribute hashKey)
Description copied from interface:QueryApi
Retrieves items by the specified hash key.
-
updateGSI
public TableDescription updateGSI(ProvisionedThroughput provisionedThroughput)
Updates the provisioned throughput for this global secondary index (GSI). Setting the throughput for an index helps you manage performance and is part of the provisioned throughput feature of DynamoDB.The provisioned throughput values can be upgraded or downgraded based on the maximums and minimums listed in the Limits section in the Amazon DynamoDB Developer Guide.
This index must be a global secondary index and in the
ACTIVE
state for this operation to succeed. Updating a GSI is an asynchronous operation; while executing the operation, the index is in theUPDATING
state. While the index is in theUPDATING
state, the index still has the provisioned throughput from before the call. The new provisioned throughput setting is in effect only when the index returns to theACTIVE
state after the update is complete.- Parameters:
provisionedThroughput
- target provisioned throughput- Returns:
- the updated table description returned from DynamoDB.
-
deleteGSI
public TableDescription deleteGSI()
Deletes this global secondary index (GSI) from the DynamoDB table. Involves network calls.This index must be a global secondary index and in the
ACTIVE
state for this operation to succeed. Deleting a GSI is an asynchronous operation; while executing the operation, the index is in theDELETING
state.- Returns:
- the updated table description returned from DynamoDB.
-
waitForActive
public TableDescription waitForActive() throws InterruptedException
A convenient blocking call that can be used, typically during index creation, to wait for the index to become active by polling the table every 5 seconds.Currently online index creation is only supported for Global Secondary Index (GSI). Calling this method on a Local Secondary Index (LSI) would result in
IllegalArgumentException
.- Returns:
- the table description when the index has become active
- Throws:
IllegalArgumentException
- if the table is being deleted, or if the GSI is not being created or updated, or if the GSI doesn't existResourceNotFoundException
- if the table doesn't existInterruptedException
-
waitForDelete
public TableDescription waitForDelete() throws InterruptedException
A convenient blocking call that can be used, typically during index deletion on an active table, to wait for the index to become deleted by polling the table every 5 seconds.Currently online index deletion is only supported for Global Secondary Index (GSI). The behavior of calling this method on a Local Secondary Index (LSI) would result in returning the latest table description.
- Returns:
- the table description if this GSI has been deleted; or null if the underlying table has been deleted.
- Throws:
IllegalArgumentException
- if the table is being deleted, or if the GSI is not being deleted.ResourceNotFoundException
- if the table doesn't existInterruptedException
-
waitForActiveOrDelete
public TableDescription waitForActiveOrDelete() throws InterruptedException
A convenient blocking call that can be used to wait on an index until it has either become active or deleted (ie no longer exists) by polling the table every 5 seconds.Currently online index creation/deletion is only supported for Global Secondary Index (GSI). The behavior of calling this method on a Local Secondary Index (LSI) would result in returning the latest table description.
- Returns:
- the table description when the index has become either active or deleted
- Throws:
IllegalArgumentException
- if the table is being deletedResourceNotFoundException
- if the table doesn't existInterruptedException
-
scan
public ItemCollection<ScanOutcome> scan(ScanFilter... scanFilters)
Description copied from interface:ScanApi
Retrieves items by the specified list of scan filters.
-
scan
public ItemCollection<ScanOutcome> scan(String filterExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Description copied from interface:ScanApi
Scans table using a Filter Expression.- Specified by:
scan
in interfaceScanApi
- Parameters:
filterExpression
- condition expression example: "(#a > :a) AND (#c > :c OR #e < :e)"nameMap
- actual values for the attribute-name place holders; can be null if there is no attribute-name placeholder.valueMap
- actual values for the value place holders can be null if there is no attribute-value placeholder.
-
scan
public ItemCollection<ScanOutcome> scan(String filterExpression, String projectionExpression, Map<String,String> nameMap, Map<String,Object> valueMap)
Description copied from interface:ScanApi
Scans table using a Filter Expression and a Projection Expression.- Specified by:
scan
in interfaceScanApi
- Parameters:
filterExpression
- condition expression example: "(#a > :a) AND (#c > :c OR #e < :e)"projectionExpression
- projection expression example: "a.b , c[0].e"nameMap
- actual values for the attribute-name place holders; can be null if there is no attribute-name placeholder.valueMap
- actual values for the value place holders can be null if there is no attribute-value placeholder.
-
scan
@Beta public ItemCollection<ScanOutcome> scan(ScanExpressionSpec xspec)
-
scan
public ItemCollection<ScanOutcome> scan(ScanSpec params)
Description copied from interface:ScanApi
Scans table by specifying all the details.
-
-