Class DDBPredicateUtils


  • public class DDBPredicateUtils
    extends Object
    Provides utility methods relating to predicate handling.
    • Method Detail

      • getBestIndexForPredicates

        public static DynamoDBIndex getBestIndexForPredicates​(DynamoDBTable table,
                                                              List<String> requestedCols,
                                                              Map<String,​ValueSet> predicates)
        Attempts to pick an optimal index (if any) from the given predicates. Returns the original table index if one was not found.
        Parameters:
        table - the original table
        predicates - the predicates
        Returns:
        the optimal index if found, otherwise the original table index
      • getHashKeyAttributeValues

        public static List<Object> getHashKeyAttributeValues​(ValueSet valueSet)
        Generates a list of distinct values from the given ValueSet or an empty list if not possible.
        Parameters:
        valueSet - the value set to generate from
        Returns:
        the list of distinct values
      • generateSingleColumnFilter

        public static String generateSingleColumnFilter​(String originalColumnName,
                                                        ValueSet predicate,
                                                        List<software.amazon.awssdk.services.dynamodb.model.AttributeValue> accumulator,
                                                        IncrementingValueNameProducer valueNameProducer,
                                                        DDBRecordMetadata recordMetadata,
                                                        boolean columnIsSortKey)
        Generates a filter expression for a single column given a ValueSet predicate for that column.
        Parameters:
        originalColumnName - the column name
        predicate - the associated predicate
        accumulator - the value accumulator to add values to
        valueNameProducer - the value name producer to generate value aliases with
        recordMetadata - object containing any necessary metadata from the glue table
        columnIsSortKey - whether or not the originalColumnName column is a sort key
        Returns:
        the generated filter expression
      • generateFilterExpression

        public static String generateFilterExpression​(Set<String> columnsToIgnore,
                                                      Map<String,​ValueSet> predicates,
                                                      List<software.amazon.awssdk.services.dynamodb.model.AttributeValue> accumulator,
                                                      IncrementingValueNameProducer valueNameProducer,
                                                      DDBRecordMetadata recordMetadata)
        Generates a combined filter expression for the given predicates. columnsToIgnore will contain any column that is of custom type (such as timestamp with tz) as these types are not natively supported by ddb or glue. we will need to filter them separately in the ddb query/scan result.
        Parameters:
        columnsToIgnore - the columns to not generate filters for
        predicates - the map of columns to predicates
        accumulator - the value accumulator to add values to
        valueNameProducer - the value name producer to generate value aliases with
        recordMetadata - object containing any necessary metadata from the glue table
        Returns:
        the combined filter expression