Package com.amazonaws.services.dynamodbv2.document

Examples of com.amazonaws.services.dynamodbv2.document.RangeKeyCondition


    public void before() throws InterruptedException {
        F_UpdateItemTest.setupData(dynamo);
        new B_PutItemTest().howToPutItems();
        ItemCollection<?> itemCol = dynamo.getTable(TABLE_NAME)
                .query(HASH_KEY_NAME, "foo",
                        new RangeKeyCondition(RANGE_KEY_NAME).between(1, 5));
          int count = 0;
          for (Item item: itemCol) {
              System.out.println(item);
              count++;
          }
View Full Code Here


    private void verify_BatchWrite_ToOneTable() {
        {   // Verify the 5 items put via the batch operation
            ItemCollection<?> itemCol = dynamo.getTable(TABLE_NAME)
                  .query(HASH_KEY_NAME, "TestingPutItemInBatch",
                          new RangeKeyCondition(RANGE_KEY_NAME).between(111, 555));
            int count = 0;
            for (Item item: itemCol) {
                System.out.println(item);
                count++;
            }
            Assert.assertTrue(count == 5);
        }
        {   // Verify the 5 keys deleted via the batch operation
            ItemCollection<?> itemCol = dynamo.getTable(TABLE_NAME)
                    .query(HASH_KEY_NAME, "foo",
                    new RangeKeyCondition(RANGE_KEY_NAME).between(1, 5));
            int count = 0;
            for (Item item : itemCol) {
                System.out.println(item);
                count++;
            }
View Full Code Here

    private void verify_BatchWrite_ToMultiTables() {
        {   // Verify the 2 items put to the 1st table via the batch operation
            ItemCollection<?> itemCol = dynamo.getTable(TABLE_NAME)
                  .query(HASH_KEY_NAME, "TestingPutItemInBatch",
                          new RangeKeyCondition(RANGE_KEY_NAME).between(666, 777));
            int count = 0;
            for (Item item: itemCol) {
                System.out.println(item);
                count++;
            }
            Assert.assertTrue(count == 2);
        }
        {   // Verify the 2 keys deleted from the 1st table via the batch operation
            ItemCollection<?> itemCol = dynamo.getTable(TABLE_NAME)
                    .query(HASH_KEY_NAME, "foo",
                    new RangeKeyCondition(RANGE_KEY_NAME).between(1, 2));
            int count = 0;
            for (Item item : itemCol) {
                System.out.println(item);
                count++;
            }
View Full Code Here

    @Test
    public void simpleQuery() {
        Table table = dynamo.getTable(TABLE_NAME);
        ItemCollection<?> col = table.query(HASH_KEY_NAME, "foo",
            new RangeKeyCondition(RANGE_KEY_NAME).between(1, 10));
        int count = 0;
        for (Item item: col) {
            System.out.println(item);
            count++;
        }
View Full Code Here

    @Test
    public void howToUseQueryFilters() {
        Table table = dynamo.getTable(TABLE_NAME);
        ItemCollection<QueryOutcome> col = table.query(HASH_KEY_NAME, "foo",
            new RangeKeyCondition(RANGE_KEY_NAME).between(1, 10),
            new QueryFilter("intAttr").gt(1238));
        int count = 0;
        QueryOutcome lastOutcome = null;
        for (Item item: col) {
            Assert.assertTrue(item.getInt("intAttr") > 1238);
View Full Code Here

    @Test
    public void howToUseFilterExpression() {
        Table table = dynamo.getTable(TABLE_NAME);
        ItemCollection<QueryOutcome> col = table.query(
            HASH_KEY_NAME, "foo",
            new RangeKeyCondition(RANGE_KEY_NAME).between(1, 10),
            // filter expression
            "intAttr > :intAttr",
            // no attribute name substitution
            null,    
            // attribute value substitution
View Full Code Here

    @Test
    public void howToUseFilterExpression_AttrNameSubstitution() {
        Table table = dynamo.getTable(TABLE_NAME);
        ItemCollection<?> col = table.query(
            HASH_KEY_NAME, "foo",
            new RangeKeyCondition(RANGE_KEY_NAME).between(1, 10),
            // filter expression with name substitution
            "#intAttr > :intAttr",
            // attribute name substitution
            new NameMap().with("#intAttr", "intAttr"),
            // attribute value substitution
View Full Code Here

    @Test
    public void howToUseProjectionExpression() {
        Table table = dynamo.getTable(TABLE_NAME);
        ItemCollection<?> col = table.query(
            HASH_KEY_NAME, "foo",
            new RangeKeyCondition(RANGE_KEY_NAME).between(1, 10),
            // filter expression
            "#intAttr > :intAttr",
            // projection expression
            "intAttr, #binary",
            // attribute name substitution
View Full Code Here

                new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(InternalUtils.toAttributeValue(hashKey.getValue()))
        );
        // range key condition
        RangeKeyCondition rangeKeyCond = spec.getRangeKeyCondition();
        if (rangeKeyCond != null) {
            KeyConditions keyCond = rangeKeyCond.getKeyCondition();
            if (keyCond == null)
                throw new IllegalArgumentException("key condition not specified in range key condition");
            Object[] values = rangeKeyCond.getValues();
            if (values == null)
                throw new IllegalArgumentException("key condition values not specified in range key condition");
            req.addKeyConditionsEntry(rangeKeyCond.getAttrName(),
                    new Condition()
                    .withComparisonOperator(keyCond.toComparisonOperator())
                    .withAttributeValueList(InternalUtils.toAttributeValues(values))
            );
        }
View Full Code Here

                if ( getterResult == null && reflector.isAssignableKey(method) ) {
                    onAutoGenerateAssignableKey(method, attributeName);
                }
               
                else {
                    AttributeValue newAttributeValue = getSimpleAttributeValue(method, getterResult);
                    if ( newAttributeValue == null ) {
                        throw new DynamoDBMappingException("Null or empty value for key: " + method);
                    }

                    onKeyAttributeValue(attributeName, newAttributeValue);
                }
            }

            /*
             * Next construct an update for every non-key property
             */
            for ( Method method : reflector.getRelevantGetters(clazz) ) {

                // Skip any key methods, since they are handled separately
                if ( keyGetters.contains(method) )
                    continue;

                Object getterResult = safeInvoke(method, object);
                String attributeName = reflector.getAttributeName(method);

                /*
                 * If this is a versioned field, update it
                 */
                if ( reflector.isVersionAttributeGetter(method) ) {
                    onVersionAttribute(method, getterResult, attributeName);
                    nonKeyAttributePresent = true;
                }

                /*
                 * Otherwise apply the update value for this attribute.
                 */
                else  {
                    AttributeValue currentValue = getSimpleAttributeValue(method, getterResult);
                    if ( currentValue != null ) {
                        onNonKeyAttribute(attributeName, currentValue);
                        nonKeyAttributePresent = true;
                    } else {
                        onNullNonKeyAttribute(attributeName);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.document.RangeKeyCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.