Package com.amazonaws.services.dynamodb.model

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


        Assert.assertNotNull(result.getConsumedCapacityUnits());
    }

    @Test
    public void deleteItemWithHashKeyAndRangeKey() {
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        schema.setRangeKeyElement(new KeySchemaElement().withAttributeName("range").withAttributeType(ScalarAttributeType.N));
        createTable(tableName, schema);
        AttributeValue hash = new AttributeValue("ad");
        AttributeValue range1 = new AttributeValue().withN("1");
        AttributeValue range2 = new AttributeValue().withN("2");
        getClient().putItem(new PutItemRequest().withTableName(tableName).withItem(createGenericItem(hash, range1)));
View Full Code Here


  }

  @Test
  public void queryWithHashKey() {
    // Setup table with items
    KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
    createTable(tableName, schema);
    AttributeValue hashKey = createStringAttribute();
    getClient().putItem(new PutItemRequest().withItem(createGenericItem()).withTableName(tableName));
    getClient().putItem(new PutItemRequest().withItem(createGenericItem(hashKey)).withTableName(tableName));
    getClient().putItem(new PutItemRequest().withItem(createGenericItem()).withTableName(tableName));
View Full Code Here

    //I do not think this is a good design since
    @Test
    public void queryWithHashKeyNotExist() {
        // Setup table with items
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
        AttributeValue hashKey = createStringAttribute();
        getClient().putItem(new PutItemRequest().withItem(createGenericItem()).withTableName(tableName));
        getClient().putItem(new PutItemRequest().withItem(createGenericItem()).withTableName(tableName));
        getClient().putItem(new PutItemRequest().withItem(createGenericItem()).withTableName(tableName));
View Full Code Here

        Assert.assertNotNull(result.getItems());     //result should be null but unfortunately it not.
        Assert.assertSame(result.getItems().size(), 0);
    }

    private AttributeValue setupTableWithSeveralItems() {
    KeySchema schema = new KeySchema()
                .withHashKeyElement(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S))
                .withRangeKeyElement(new KeySchemaElement().withAttributeName("range").withAttributeType(ScalarAttributeType.S))
                ;
    createTable(tableName, schema);
View Full Code Here

        return hashKey1;
    }

    private AttributeValue setupNumericRangeTableWithSeveralItems() {
    KeySchema schema = new KeySchema()
                .withHashKeyElement(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S))
                .withRangeKeyElement(new KeySchemaElement().withAttributeName("range").withAttributeType(ScalarAttributeType.N))
                ;
    createTable(tableName, schema);
View Full Code Here

    private int nbOfItems;

    @Before
    public void setUp() {
        tableName = createTableName();
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
        nbOfItems = 90;
        for (int i = 0; i < (nbOfItems); i++) {
            putItemInDb(createIntegerAttribute(i/10+1,i/10+1));     //1~9
            putItemInDb(createIntegerAttribute(i/10+11,i/10+11));   //11~19
View Full Code Here

  protected KeySchema createKeySchema(KeySchemaElement hashKey) {
    return createKeySchema(hashKey, null);
  }

  protected KeySchema createKeySchema(KeySchemaElement hashKey, KeySchemaElement rangeKey) {
    KeySchema schema = new KeySchema(hashKey);
    schema.setRangeKeyElement(rangeKey);
    return schema;
  }
View Full Code Here

    }
    return map;
  }

    protected AttributeValue createItem(String tableName){
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
        AttributeValue hash = createStringAttribute();
        Map<String, AttributeValue> item = createGenericItem(hash);
        PutItemRequest req = new PutItemRequest().withTableName(tableName).withItem(item);
        getClient().putItem(req);
View Full Code Here

    //Test: put item with HashKey
    @Test
    public void putItemWithHashKey()
    {
        KeySchema schema =
                new KeySchema(
                    new KeySchemaElement().withAttributeName("code").withAttributeType(ScalarAttributeType.S)
                );
        createTable(hashTableName, schema);

        TestClassWithHashKey value = new TestClassWithHashKey();
View Full Code Here

    }

    @Test
    public void putItemWithHashKeyOverwriteItem()
    {
        KeySchema schema =
                new KeySchema(
                    new KeySchemaElement().withAttributeName("code").withAttributeType(ScalarAttributeType.S)
                );
    try {
        createTable(hashTableName, schema);
    } catch (ResourceInUseException riue) {
View Full Code Here

TOP

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

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.