Examples of KeySchemaElement


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

        }

        KeySchema keySchema = desc.getKeySchema();
        if (keySchema != null) {
          jsonWriter.key("KeySchema").object();
          KeySchemaElement hashKeyElement = keySchema.getHashKeyElement();
          if (hashKeyElement != null) {
            jsonWriter.key("HashKeyElement").object();
            if (hashKeyElement.getAttributeName() != null) {
              jsonWriter.key("AttributeName").value(hashKeyElement.getAttributeName());
            }
            if (hashKeyElement.getAttributeType() != null) {
              jsonWriter.key("AttributeType").value(hashKeyElement.getAttributeType());
            }
            jsonWriter.endObject();
          }
          KeySchemaElement rangeKeyElement = keySchema.getRangeKeyElement();
          if (rangeKeyElement != null) {
            jsonWriter.key("RangeKeyElement").object();
            if (rangeKeyElement.getAttributeName() != null) {
              jsonWriter.key("AttributeName").value(rangeKeyElement.getAttributeName());
            }
            if (rangeKeyElement.getAttributeType() != null) {
              jsonWriter.key("AttributeType").value(rangeKeyElement.getAttributeType());
            }
            jsonWriter.endObject();
          }
          jsonWriter.endObject();
        }
View Full Code Here

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

    }
  }

  @Test
  public void createTableWithSameHashAndRangeKey() {
    KeySchemaElement el = createStringKeyElement();
    try {
      createTable(createKeySchema(el, el));
      Assert.assertTrue(false);// Should have thrown an exception
    } catch (AmazonServiceException ase) {
    }
View Full Code Here

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

    }
   
    @Test
    public void queryUpdate() {
        // Setup table with items
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
       
        Key key = new Key();
        key.setHashKeyElement(new AttributeValue().withS("1"));
       
View Full Code Here

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

    }
   
    @Test
    public void accumulativeUpdate() {
        // Setup table with items
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
       
        Key key = new Key();
        key.setHashKeyElement(new AttributeValue().withS("1"));
       
View Full Code Here

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

    }
   
    @Test
    public void conditionalUpdateOnHit(){
      // Setup table with items
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
       
        Key key = new Key();
        key.setHashKeyElement(new AttributeValue().withS("1"));
       
View Full Code Here

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

    }
   
    @Test
    public void conditionalAddNewFieldUpdateOnHit(){
      // Setup table with items
        KeySchema schema = new KeySchema(new KeySchemaElement().withAttributeName("id").withAttributeType(ScalarAttributeType.S));
        createTable(tableName, schema);
       
        Key key = new Key();
        key.setHashKeyElement(new AttributeValue().withS("1"));
       
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.KeySchemaElement

            }

            if (gsiHashKeyName != null) {
                // Make sure that the HASH key element is always inserted at the beginning of the list
                if (gsi.getKeySchema() == null || gsi.getKeySchema().isEmpty()) {
                    gsi.withKeySchema(new KeySchemaElement(gsiHashKeyName, KeyType.HASH));
                } else {
                    LinkedList<KeySchemaElement> orderedKeys = new LinkedList<KeySchemaElement>(gsi.getKeySchema());
                    orderedKeys.addFirst(new KeySchemaElement(gsiHashKeyName, KeyType.HASH));
                    gsi.setKeySchema(orderedKeys);
                }

                // Register the mapping from the hash key name to the GSI name
                mapGsiHashKeyToIndexName(gsiHashKeyName, gsiName);
            }
            if (gsiRangeKeyName != null) {
                gsi.withKeySchema(new KeySchemaElement(gsiRangeKeyName, KeyType.RANGE));

                // Register the mapping from the range key name to the GSI name
                mapGsiRangeKeyToIndexName(gsiRangeKeyName, gsiName);
            }
        }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.KeySchemaElement

                lsiNameToLsiDefinition.put(
                        lsiName,
                        new LocalSecondaryIndex()
                                .withIndexName(lsiName)
                                .withKeySchema(
                                        new KeySchemaElement(pHashKeyName, KeyType.HASH),
                                        new KeySchemaElement(lsiRangeKeyName, KeyType.RANGE))
                                .withProjection(new Projection().withProjectionType(ProjectionType.KEYS_ONLY)));
                mapLsiRangeKeyToIndexName(lsiRangeKeyName, lsiName);
            }
        }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.KeySchemaElement

        createTableRequest.setTableName(DynamoDBMapper.getTableName(clazz, config, reflector));

        // Primary keys
        Method pHashKeyGetter = reflector.getPrimaryHashKeyGetter(clazz);
        AttributeDefinition pHashAttrDefinition = getKeyAttributeDefinition(pHashKeyGetter, converter);
        createTableRequest.withKeySchema(new KeySchemaElement(pHashAttrDefinition.getAttributeName(), KeyType.HASH));
        // Primary range
        Method pRangeKeyGetter = reflector.getPrimaryRangeKeyGetter(clazz);
        AttributeDefinition pRangeAttrDefinition = null;
        if (pRangeKeyGetter != null) {
            pRangeAttrDefinition = getKeyAttributeDefinition(pRangeKeyGetter, converter);
            createTableRequest.withKeySchema(new KeySchemaElement(pRangeAttrDefinition.getAttributeName(), KeyType.RANGE));
        }

        // Parse the index schema
        TableIndexesInfo indexesInfo = parseTableIndexes(clazz, reflector);
        if ( indexesInfo.getGlobalSecondaryIndexes().isEmpty() == false ) {
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.KeySchemaElement

            if (Tables.doesTableExist(dynamoDB, tableName)) {
                System.out.println("Table " + tableName + " is already ACTIVE");
            } else {
                // Create a table with a primary hash key named 'name', which holds a string
                CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
                    .withKeySchema(new KeySchemaElement().withAttributeName("name").withKeyType(KeyType.HASH))
                    .withAttributeDefinitions(new AttributeDefinition().withAttributeName("name").withAttributeType(ScalarAttributeType.S))
                    .withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
                    TableDescription createdTableDescription = dynamoDB.createTable(createTableRequest).getTableDescription();
                System.out.println("Created Table: " + createdTableDescription);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.