Class Index

  • All Implemented Interfaces:
    QueryApi, ScanApi

    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 via Table.getIndex(String).
    • 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,
                                                  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 interface QueryApi
        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 interface QueryApi
        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

        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 interface QueryApi
        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.
      • 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 the UPDATING state. While the index is in the UPDATING 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 the ACTIVE 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 the DELETING 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 exist
        ResourceNotFoundException - if the table doesn't exist
        InterruptedException
      • 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 exist
        InterruptedException
      • 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 deleted
        ResourceNotFoundException - if the table doesn't exist
        InterruptedException
      • 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 interface ScanApi
        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 interface ScanApi
        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.