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


Java AttributeDefinition類代碼示例

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


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

示例1: constructCreateTableRequest

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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.AttributeDefinition; //導入依賴的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.AttributeDefinition; //導入依賴的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.AttributeDefinition; //導入依賴的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.AttributeDefinition; //導入依賴的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: checkTableSchemaType

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的package包/類
void checkTableSchemaType(TableDescription tableDescription, Table table) throws MetaException {
  List<FieldSchema> tableSchema = table.getSd().getCols();

  for (FieldSchema fieldSchema : tableSchema) {
    for (AttributeDefinition definition : tableDescription.getAttributeDefinitions()) {
      validateKeySchema(definition.getAttributeName(), definition.getAttributeType(),
          fieldSchema);
    }

    // Check for each field type
    if (HiveDynamoDBTypeFactory.getTypeObjectFromHiveType(fieldSchema.getType()) == null) {
      throw new MetaException("The hive type " + fieldSchema.getType() + " is not supported in "
          + "DynamoDB");
    }
  }
}
 
開發者ID:awslabs,項目名稱:emr-dynamodb-connector,代碼行數:17,代碼來源:DynamoDBStorageHandler.java

示例7: getTableDescription

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例8: setUp

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例9: getTableSchema

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例10: createIdentityTable

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例11: createDeviceTable

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例12: createTable

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例13: createTable

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例14: init

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的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

示例15: createTable

import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; //導入依賴的package包/類
/**
 * Creates a table in AWS DynamoDB.
 * @param appid name of the {@link com.erudika.para.core.App}
 * @param readCapacity read capacity
 * @param writeCapacity write capacity
 * @return true if created
 */
public static boolean createTable(String appid, long readCapacity, long writeCapacity) {
	if (StringUtils.isBlank(appid)) {
		return false;
	} else if (StringUtils.containsWhitespace(appid)) {
		logger.warn("DynamoDB table name contains whitespace. The name '{}' is invalid.", appid);
		return false;
	} else if (existsTable(appid)) {
		logger.warn("DynamoDB table '{}' already exists.", appid);
		return false;
	}
	try {
		String table = getTableNameForAppid(appid);
		getClient().createTable(new CreateTableRequest().withTableName(table).
				withKeySchema(new KeySchemaElement(Config._KEY, KeyType.HASH)).
				withAttributeDefinitions(new AttributeDefinition(Config._KEY, ScalarAttributeType.S)).
				withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
		logger.info("Created DynamoDB table '{}'.", table);
	} catch (Exception e) {
		logger.error(null, e);
		return false;
	}
	return true;
}
 
開發者ID:Erudika,項目名稱:para,代碼行數:31,代碼來源:AWSDynamoUtils.java


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