當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。