本文整理汇总了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;
}
示例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);
}
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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));
}
示例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()
);
}
示例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));
}
示例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");
}
示例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));
}
示例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