當前位置: 首頁>>代碼示例>>Java>>正文


Java KeySchemaElement類代碼示例

本文整理匯總了Java中com.amazonaws.services.dynamodbv2.model.KeySchemaElement的典型用法代碼示例。如果您正苦於以下問題:Java KeySchemaElement類的具體用法?Java KeySchemaElement怎麽用?Java KeySchemaElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeySchemaElement類屬於com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了KeySchemaElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: constructCreateTableRequest

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
public CreateTableRequest constructCreateTableRequest() {
    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(partitionKeyName.toString()).withAttributeType("S"));
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(sortKeyName.toString()).withAttributeType("N"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
    keySchema.add(new KeySchemaElement().withAttributeName(partitionKeyName.toString()).withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName(sortKeyName.toString()).withKeyType(KeyType.RANGE));

    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(1L)
            .withWriteCapacityUnits(1L);
    CreateTableRequest request = new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(keySchema)
            .withAttributeDefinitions(attributeDefinitions)
            .withProvisionedThroughput(provisionedThroughput);
    return request;
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:20,代碼來源:GenericDynamoDB.java

示例2: createRecipientTable

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
private void createRecipientTable() {
    CreateTableRequest request
            = new CreateTableRequest()
                    .withTableName(TABLE_NAME)
                    .withAttributeDefinitions(
                            new AttributeDefinition("_id", ScalarAttributeType.S)
                    )
                    .withKeySchema(
                            new KeySchemaElement("_id", KeyType.HASH)
                    )
                    .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L));

    ddb.createTable(request);
    try {
        TableUtils.waitUntilActive(ddb, TABLE_NAME);
    } catch (InterruptedException  e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:20,代碼來源:CloudNoticeDAO.java

示例3: closeStorage

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Override
public void closeStorage()
{
    try
    {
        dynamoDBConnection.getDynamoClient().describeTable(getTableName());
        dynamoDBConnection.getDynamoClient().deleteTable(getTableName());
    }
    catch(ResourceNotFoundException e)
    {

    }

    dynamoDBConnection.getDynamoDB().createTable(getTableName(),
            Collections.singletonList(
                    new KeySchemaElement("_id", KeyType.HASH)),
            Collections.singletonList(
                   new AttributeDefinition("_id", ScalarAttributeType.S)),
            new ProvisionedThroughput(1L, 1L));
}
 
開發者ID:orbit,項目名稱:orbit-dynamodb,代碼行數:21,代碼來源:DynamoDBPersistenceTest.java

示例4: getRowType

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
  RelDataType type = super.getRowType(typeFactory);
  // force add the star field, this is a dynamic row
  type.getFieldCount();
  // add the sort/partition keys that the mapper should produce
  if (key != null) {
    for (String field : key.getKeyNames()) {
      type.getField(field, true, false);
    }
  }
  // since we don't support pushing the key combination into the filter building, we need to
  // support the key schema elements in our key schema so hash/sort can be used in the filter.
  List<KeySchemaElement> keys = desc.getKeySchema();
  for (KeySchemaElement elem : keys) {
    type.getField(elem.getAttributeName(), true, false);

  }

  return type;
}
 
開發者ID:fineoio,項目名稱:drill-dynamo-adapter,代碼行數:22,代碼來源:DrillDynamoTable.java

示例5: createHashAndSortTable

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
protected Table createHashAndSortTable(String pk, String sort) throws InterruptedException {
  ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
  ScalarAttributeType type = ScalarAttributeType.S;
  attributeDefinitions.add(new AttributeDefinition()
    .withAttributeName(pk).withAttributeType(type));
  attributeDefinitions
    .add(new AttributeDefinition().withAttributeName(sort).withAttributeType(type));
  ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
  keySchema.add(new KeySchemaElement().withAttributeName(pk).withKeyType(KeyType.HASH));
  keySchema.add(new KeySchemaElement().withAttributeName(sort).withKeyType(KeyType.RANGE));

  CreateTableRequest request = new CreateTableRequest()
    .withKeySchema(keySchema)
    .withAttributeDefinitions(attributeDefinitions);
  return createTable(request);
}
 
開發者ID:fineoio,項目名稱:drill-dynamo-adapter,代碼行數:17,代碼來源:BaseDynamoTest.java

示例6: deploy

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
public void deploy() {

        final AttributeDefinition idAttr = new AttributeDefinition().withAttributeName("id")
                .withAttributeType(ScalarAttributeType.S);
        final ProvisionedThroughput throughput = new ProvisionedThroughput().withReadCapacityUnits(5L)
                .withWriteCapacityUnits(5L);

        final KeySchemaElement idKey = new KeySchemaElement().withAttributeName("id").withKeyType(KeyType.HASH);

        final CreateTableRequest createTableRequest = new CreateTableRequest().withTableName("TranslateSlack")
                .withAttributeDefinitions(idAttr)
                .withKeySchema(idKey)
                .withProvisionedThroughput(throughput);
        ;
        ;

        ddb.createTable(createTableRequest);

    }
 
開發者ID:aztecrex,項目名稱:java-translatebot,代碼行數:20,代碼來源:DatabaseDeployer.java

示例7: getQueryFilter

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
private DynamoDBQueryFilter getQueryFilter(JobConf conf, Map<String, String>
    hiveDynamoDBMapping, Map<String, String> hiveTypeMapping) throws IOException {
  if (hiveDynamoDBMapping == null) {
    /*
     * Column mapping may be null when user has mapped a DynamoDB item
     * onto a single hive map<string, string> column.
     */
    return new DynamoDBQueryFilter();
  }

  DynamoDBClient client = new DynamoDBClient(conf);
  String filterExprSerialized = conf.get(TableScanDesc.FILTER_EXPR_CONF_STR);
  if (filterExprSerialized == null) {
    return new DynamoDBQueryFilter();
  }
  ExprNodeDesc filterExpr =
      ShimsLoader.getHiveShims().deserializeExpression(filterExprSerialized);

  DynamoDBFilterPushdown pushdown = new DynamoDBFilterPushdown();
  List<KeySchemaElement> schema =
      client.describeTable(conf.get(DynamoDBConstants.TABLE_NAME)).getKeySchema();
  DynamoDBQueryFilter queryFilter = pushdown.predicateToDynamoDBFilter(
      schema, hiveDynamoDBMapping, hiveTypeMapping, filterExpr);
  return queryFilter;
}
 
開發者ID:awslabs,項目名稱:emr-dynamodb-connector,代碼行數:26,代碼來源:HiveDynamoDBInputFormat.java

示例8: getTableDescription

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
private TableDescription getTableDescription(String hashType, String rangeType) {
  List<KeySchemaElement> keySchema = new ArrayList<>();
  List<AttributeDefinition> definitions = new ArrayList<>();

  keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH));
  definitions.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType
      (hashType));

  if (rangeType != null) {
    keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType
        .RANGE));
    definitions.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType
        (rangeType));
  }

  TableDescription description = new TableDescription().withKeySchema(keySchema)
      .withAttributeDefinitions(definitions).withProvisionedThroughput(new
          ProvisionedThroughputDescription().withReadCapacityUnits(1000L)
          .withWriteCapacityUnits(1000L));
  return description;
}
 
開發者ID:awslabs,項目名稱:emr-dynamodb-connector,代碼行數:22,代碼來源:DynamoDBRecordReaderTest.java

示例9: toKeySchema

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
private static List<KeySchemaElement> toKeySchema(String tableName, IndexDescription index) {
    if ( null == index.getHashKey() ) {
        throw new NullPointerException(
            "Table ["+tableName+"] index ["+index.getIndexName()+"] contains null hashKey"
            );
    }
    if ( null != index.getRangeKey() ) {
        return Arrays.asList(
            new KeySchemaElement()
            .withAttributeName(index.getHashKey().getAttrName())
            .withKeyType(KeyType.HASH),
            new KeySchemaElement()
            .withAttributeName(index.getRangeKey().getAttrName())
            .withKeyType(KeyType.RANGE));
    }
    return Collections.singletonList(
            new KeySchemaElement()
            .withAttributeName(index.getHashKey().getAttrName())
            .withKeyType(KeyType.HASH));
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:21,代碼來源:DdbSchema.java

示例10: setUp

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Before
public void setUp() {
    // Unique table for each run
    tableName = "table" + String.valueOf(tableCount++);
    dynamoDB.getDynamoDbClient().createTable(
        new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(new KeySchemaElement("id", "HASH"))
            .withAttributeDefinitions(
                new AttributeDefinition("id", "S")
            )
            .withProvisionedThroughput(
                new ProvisionedThroughput(1L, 1L)
            )
    );

    locker = new DynamoDbLocker(
        new DynamoDB(dynamoDB.getDynamoDbClient()),
        tableName,
        Clock.systemUTC()
    );
}
 
開發者ID:vvondra,項目名稱:fleet-cron,代碼行數:23,代碼來源:DynamoDbLockerTest.java

示例11: testExecute

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Test
public void testExecute() {
    command.execute();
    List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("name"));
    assertEquals("FULL_DESCRIBE_TABLE", ddbClient.describeTableRequest.getTableName());
    assertEquals("FULL_DESCRIBE_TABLE", exchange.getIn().getHeader(DdbConstants.TABLE_NAME));
    assertEquals("ACTIVE", exchange.getIn().getHeader(DdbConstants.TABLE_STATUS));
    assertEquals(new Date(AmazonDDBClientMock.NOW), exchange.getIn().getHeader(DdbConstants.CREATION_DATE));
    assertEquals(100L, exchange.getIn().getHeader(DdbConstants.ITEM_COUNT));
    assertEquals(keySchema,
            exchange.getIn().getHeader(DdbConstants.KEY_SCHEMA));
    assertEquals(20L, exchange.getIn().getHeader(DdbConstants.READ_CAPACITY));
    assertEquals(10L, exchange.getIn().getHeader(DdbConstants.WRITE_CAPACITY));
    assertEquals(1000L, exchange.getIn().getHeader(DdbConstants.TABLE_SIZE));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:DescribeTableCommandTest.java

示例12: describeTable

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Override
public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest) {
    this.describeTableRequest = describeTableRequest;
    String tableName = describeTableRequest.getTableName();
    if ("activeTable".equals(tableName)) {
        return tableWithStatus(TableStatus.ACTIVE);
    } else if ("creatibleTable".equals(tableName) && createTableRequest != null) {
        return tableWithStatus(TableStatus.ACTIVE);
    } else if ("FULL_DESCRIBE_TABLE".equals(tableName)) {
        return new DescribeTableResult().withTable(new TableDescription()
                .withTableName(tableName)
                .withTableStatus(TableStatus.ACTIVE)
                .withCreationDateTime(new Date(NOW))
                .withItemCount(100L)
                .withKeySchema(new KeySchemaElement().withAttributeName("name"))
                .withProvisionedThroughput(new ProvisionedThroughputDescription()
                        .withReadCapacityUnits(20L)
                        .withWriteCapacityUnits(10L))
                .withTableSizeBytes(1000L));
    }
    throw new ResourceNotFoundException(tableName + " is missing");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:AmazonDDBClientMock.java

示例13: getTableSchema

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
@Override
public CreateTableRequest getTableSchema() {
    return super.getTableSchema()
        .withAttributeDefinitions(
            new AttributeDefinition()
                .withAttributeName(Constants.JANUSGRAPH_HASH_KEY)
                .withAttributeType(ScalarAttributeType.S),
            new AttributeDefinition()
                .withAttributeName(Constants.JANUSGRAPH_RANGE_KEY)
                .withAttributeType(ScalarAttributeType.S))
        .withKeySchema(
            new KeySchemaElement()
                .withAttributeName(Constants.JANUSGRAPH_HASH_KEY)
                .withKeyType(KeyType.HASH),
            new KeySchemaElement()
                .withAttributeName(Constants.JANUSGRAPH_RANGE_KEY)
                .withKeyType(KeyType.RANGE));
}
 
開發者ID:awslabs,項目名稱:dynamodb-janusgraph-storage-backend,代碼行數:19,代碼來源:DynamoDbStore.java

示例14: createIdentityTable

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
/**
 * Used to create the Identity Table. This function only needs to be called
 * once.
 */
protected void createIdentityTable() throws DataAccessException {
    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(10L)
            .withWriteCapacityUnits(5L);

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
            .add(new AttributeDefinition().withAttributeName(ATTRIBUTE_USERNAME).withAttributeType("S"));

    ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
    tableKeySchema.add(new KeySchemaElement().withAttributeName(ATTRIBUTE_USERNAME).withKeyType(KeyType.HASH));

    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(USER_TABLE)
            .withProvisionedThroughput(provisionedThroughput)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(tableKeySchema);

    try {
        ddb.createTable(createTableRequest);
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to create table: " + USER_TABLE, e);
    }
}
 
開發者ID:awslabs,項目名稱:amazon-cognito-developer-authentication-sample,代碼行數:29,代碼來源:UserAuthentication.java

示例15: createDeviceTable

import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; //導入依賴的package包/類
/**
 * Used to create the device table. This function only needs to be called
 * once.
 */
protected void createDeviceTable() throws DataAccessException {
    ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
            .withReadCapacityUnits(10L)
            .withWriteCapacityUnits(5L);

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions.add(new AttributeDefinition().withAttributeName(
            ATTRIBUTE_UID).withAttributeType("S"));

    ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
    tableKeySchema.add(new KeySchemaElement().withAttributeName(ATTRIBUTE_UID)
            .withKeyType(KeyType.HASH));

    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(DEVICE_TABLE)
            .withProvisionedThroughput(provisionedThroughput)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(tableKeySchema);

    try {
        ddb.createTable(createTableRequest);
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to create table: " + DEVICE_TABLE, e);
    }
}
 
開發者ID:awslabs,項目名稱:amazon-cognito-developer-authentication-sample,代碼行數:30,代碼來源:DeviceAuthentication.java


注:本文中的com.amazonaws.services.dynamodbv2.model.KeySchemaElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。