Package com.amazonaws.services.dynamodb.model

Examples of com.amazonaws.services.dynamodb.model.Key


            }
            rangeKeyElement = getRangeKeyElement(rangeKey, rangeKeyMethod);
        }

        GetItemResult item = db.getItem(applyUserAgent(new GetItemRequest().withTableName(tableName)
                .withKey(new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement))
                .withConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT)));
        Map<String, AttributeValue> itemAttributes = item.getItem();
        if ( itemAttributes == null ) {
            return null;
        }
View Full Code Here


        Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
        if ( rangeKeyGetter != null ) {
            rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, object), rangeKeyGetter);
        }

        Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

        Map<String, AttributeValueUpdate> updateValues = new HashMap<String, AttributeValueUpdate>();
        Map<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue>();

        boolean forcePut = config.getSaveBehavior() == SaveBehavior.CLOBBER;
View Full Code Here

        Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
        if ( rangeKeyGetter != null ) {
            rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, object), rangeKeyGetter);
        }

        Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

        /*
         * If there is a version field, make sure we assert its value. If the
         * version field is null (only should happen in unusual circumstances),
         * pretend it doesn't have a version field after all.
View Full Code Here

            Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
            if ( rangeKeyGetter != null ) {
                rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, toDelete), rangeKeyGetter);
            }

            Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }
View Full Code Here

                                + DynamoDBRangeKey.class);
                    }
                    rangeKeyElement = getRangeKeyElement(keyPair.getRangeKey(), rangeKeyMethod);
                }

                keys.add(new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement));
                count++;
                // Reach the maximum number which can be handled in a single
                // batchGet
                if (count == 100) {
                    requestItems.put(tableName, new KeysAndAttributes().withKeys(keys).withConsistentRead(consistentReads));
View Full Code Here

        command = new BatchGetItemsCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(new AttributeValue("Key_1"));
        Key unprocessedKey = new Key(new AttributeValue("UNPROCESSED_KEY"));
        Map<String, KeysAndAttributes> keysAndAttributesMap = new HashMap<String, KeysAndAttributes>();
        KeysAndAttributes keysAndAttributes = new KeysAndAttributes().withKeys(key);
        keysAndAttributesMap.put("DOMAIN1", keysAndAttributes);
        exchange.getIn().setHeader(DdbConstants.BATCH_ITEMS, keysAndAttributesMap);

        command.execute();

        assertEquals(keysAndAttributesMap, ddbClient.batchGetItemRequest.getRequestItems());


        BatchResponse batchResponse = (BatchResponse)exchange.getIn()
                .getHeader(DdbConstants.BATCH_RESPONSE, Map.class).get("DOMAIN1");
        AttributeValue value = batchResponse.getItems().get(0).get("attrName");

        KeysAndAttributes unProcessedAttributes = (KeysAndAttributes)exchange.getIn().getHeader(
                DdbConstants.UNPROCESSED_KEYS, Map.class).get("DOMAIN1");
        Key next = unProcessedAttributes.getKeys().iterator().next();

        assertEquals(new AttributeValue("attrValue"), value);
        assertEquals(unprocessedKey, next);
    }
View Full Code Here

        command = new DeleteItemCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(new AttributeValue("Key_1"));
        exchange.getIn().setHeader(DdbConstants.KEY, key);


        Map<String, ExpectedAttributeValue> updateCondition = new HashMap<String, ExpectedAttributeValue>();
        updateCondition
View Full Code Here

    }

    @Test
    public void execute() {

        Key startKey = new Key(new AttributeValue("startKey"));
        AttributeValue attributeValue = new AttributeValue().withN("1985");
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));

        List<String> attributeNames = Arrays.asList("attrNameOne", "attrNameTwo");
        exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attributeNames);
        exchange.getIn().setHeader(DdbConstants.EXACT_COUNT, true);
        exchange.getIn().setHeader(DdbConstants.CONSISTENT_READ, true);
        exchange.getIn().setHeader(DdbConstants.START_KEY, startKey);
        exchange.getIn().setHeader(DdbConstants.HASH_KEY_VALUE, attributeValue);
        exchange.getIn().setHeader(DdbConstants.LIMIT, 10);
        exchange.getIn().setHeader(DdbConstants.SCAN_RANGE_KEY_CONDITION, condition);
        exchange.getIn().setHeader(DdbConstants.SCAN_INDEX_FORWARD, true);

        command.execute();

        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY, Double.class));
        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(DdbConstants.LAST_EVALUATED_KEY, Key.class));

        Map<?, ?> items = (Map<?, ?>) exchange.getIn().getHeader(DdbConstants.ITEMS, List.class).get(0);
        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
    }
View Full Code Here

        command = new UpdateItemCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(new AttributeValue("Key_1"));
        exchange.getIn().setHeader(DdbConstants.KEY, key);

        Map<String, AttributeValueUpdate> attributeMap = new HashMap<String, AttributeValueUpdate>();
        AttributeValueUpdate attributeValue = new AttributeValueUpdate(
                new AttributeValue("new value"), AttributeAction.ADD);
View Full Code Here

        assertEquals(scanFilter, ddbClient.scanRequest.getScanFilter());
        assertEquals(Integer.valueOf(10), exchange.getIn().getHeader(DdbConstants.SCANNED_COUNT, Integer.class));
        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY, Double.class));
        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(DdbConstants.LAST_EVALUATED_KEY, Key.class));

        Map<?, ?> items = (Map<?, ?>) exchange.getIn().getHeader(DdbConstants.ITEMS, List.class).get(0);
        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodb.model.Key

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.