当前位置: 首页>>代码示例>>Java>>正文


Java KeyType类代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.KeyType的典型用法代码示例。如果您正苦于以下问题:Java KeyType类的具体用法?Java KeyType怎么用?Java KeyType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyType类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了KeyType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructCreateTableRequest

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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.KeyType; //导入依赖的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.KeyType; //导入依赖的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: createHashAndSortTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例5: deploy

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例6: getTableDescription

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例7: toKeySchema

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例8: getTableSchema

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例9: createIdentityTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例10: createDeviceTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的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

示例11: recordSizeViolation

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的package包/类
/** For GSI Violation value, should store them with their attribute type */
protected void recordSizeViolation(AttributeValue keyValue, int size, KeyType keyType) {
    if (keyType == KeyType.HASH) {
        if (recordGsiValueInViolationRecord) {
            violationRecord.setGSIHashKey(AttributeValueConverter.toStringWithAttributeType(keyValue));
        }
        violationRecord.setGSIHashKeyViolationType(SIZE_VIOLATION);
        violationRecord.setGSIHashKeyViolationDesc("Max Bytes Allowed: " + MAX_HASH_KEY_SIZE + " Found: " + size);
    } else if (keyType == KeyType.RANGE) {
        if (recordGsiValueInViolationRecord) {
            violationRecord.setGSIRangeKey(AttributeValueConverter.toStringWithAttributeType(keyValue));
        }
        violationRecord.setGSIRangeKeyViolationType(SIZE_VIOLATION);
        violationRecord.setGSIRangeKeyViolationDesc("Max Bytes Allowed: " + MAX_RANGE_KEY_SIZE + " Found: " + size);
    }
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:17,代码来源:ViolationChecker.java

示例12: createTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的package包/类
public void createTable() {
  List<KeySchemaElement> keySchema = new ArrayList<>();

  keySchema.add(
      new KeySchemaElement()
          .withAttributeName(sequenceNumber.getAttributeName())
          .withKeyType(KeyType.HASH)
  );

  ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput();
  provisionedThroughput.setReadCapacityUnits(10L);
  provisionedThroughput.setWriteCapacityUnits(10L);

  CreateTableRequest request = new CreateTableRequest()
      .withTableName("example_table")
      .withKeySchema(keySchema)
      .withAttributeDefinitions(singleton(sequenceNumber))
      .withProvisionedThroughput(provisionedThroughput);

  client.createTable(request);
}
 
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:22,代码来源:DynamoExample.java

示例13: createTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的package包/类
private CreateTableResult createTable() throws Exception {
  List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
  AttributeDefinition attributeDefinition = new AttributeDefinition()
    .withAttributeName(TEST_ATTRIBUTE)
    .withAttributeType(ScalarAttributeType.S);
  attributeDefinitions.add(attributeDefinition);

  String tableName = TEST_TABLE_NAME;

  List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
  KeySchemaElement keySchemaElement = new KeySchemaElement()
    .withAttributeName(TEST_ATTRIBUTE)
    .withKeyType(KeyType.HASH);

  ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
    .withReadCapacityUnits(UNITS)
    .withWriteCapacityUnits(UNITS);

  CreateTableResult result = dynamoDb.createTable(attributeDefinitions, tableName, keySchema, provisionedThroughput);

  return result;
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:23,代码来源:AmazonDynamoDBStubTest.java

示例14: createTable

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的package包/类
/**
 * Create a table with the given hashKey as row id
 * 
 * @param tableName
 * @param primaryKey
 */
public static void createTable(String tableName, String primaryKey) {
	ArrayList<KeySchemaElement> ks = new ArrayList<KeySchemaElement>();
	ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();

	ks.add(new KeySchemaElement().withAttributeName(primaryKey)
			.withKeyType(KeyType.HASH));
	attributeDefinitions.add(new AttributeDefinition().withAttributeName(
			primaryKey).withAttributeType("S"));

	CreateTableRequest request = new CreateTableRequest()
			.withTableName(tableName).withKeySchema(ks)
			.withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT);

	request.setAttributeDefinitions(attributeDefinitions);
	try {
		DynamoDbHandler.CLIENT.createTable(request);
	} catch (ResourceInUseException e) {
		//System.err.println("Table '" + tableName + "' already exists");
	}
}
 
开发者ID:raethlein,项目名称:ColumnStoreUnifier,代码行数:27,代码来源:DynamoDbQueryHandler.java

示例15: init

import com.amazonaws.services.dynamodbv2.model.KeyType; //导入依赖的package包/类
protected void init() throws Exception {
    List<AttributeDefinition> attributes = new ArrayList<AttributeDefinition>() {
        {
            add(new AttributeDefinition().withAttributeName(InventoryModel.AGGREGATOR).withAttributeType(
                    "S"));
            add(new AttributeDefinition().withAttributeName(InventoryModel.SHARD_ID).withAttributeType(
                    "S"));
        }
    };

    List<KeySchemaElement> key = new ArrayList<KeySchemaElement>() {
        {
            add(new KeySchemaElement().withAttributeName(InventoryModel.AGGREGATOR).withKeyType(
                    KeyType.HASH));
            add(new KeySchemaElement().withAttributeName(InventoryModel.SHARD_ID).withKeyType(
                    KeyType.RANGE));
        }
    };

    DynamoUtils.initTable(dynamoClient, InventoryModel.TABLE_NAME,
            InventoryModel.READ_CAPACITY, InventoryModel.WRITE_CAPACITY, attributes, key, null);

    online = true;
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:25,代码来源:InventoryModel.java


注:本文中的com.amazonaws.services.dynamodbv2.model.KeyType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。