本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.PrimaryKey类的典型用法代码示例。如果您正苦于以下问题:Java PrimaryKey类的具体用法?Java PrimaryKey怎么用?Java PrimaryKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrimaryKey类属于com.amazonaws.services.dynamodbv2.document包,在下文中一共展示了PrimaryKey类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
// Conditional delete (will fail)
DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
.withPrimaryKey(new PrimaryKey("year", 2015, "title", "The Big New Movie"))
.withConditionExpression("info.rating <= :val")
.withValueMap(new ValueMap()
.withNumber(":val", 5.0));
System.out.println("Attempting a conditional delete...");
try {
table.deleteItem(deleteItemSpec);
System.out.println("DeleteItem succeeded");
} catch (Exception e) {
e.printStackTrace();
System.out.println("DeleteItem failed");
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:27,代码来源:MoviesItemOps06.java
示例2: removeRelation
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
@Override
public Void removeRelation(Group group, String relationHashKey, String relationRangeKey) {
Table table = dynamoDB.getTable(groupGraphTableName);
final PrimaryKey key = new PrimaryKey(
GroupStorage.SUBJECT_KEY, relationHashKey,
GroupStorage.OBJECT_RELATION_KEY, relationRangeKey
);
DynamoDbCommand<DeleteItemOutcome> cmd = new DynamoDbCommand<>("removeRelation",
() -> table.deleteItem(key),
() -> {
throw new RuntimeException("removeRelation");
},
dynamodbGraphWriteHystrix,
metrics);
final DeleteItemOutcome deleteItemOutcome = cmd.execute();
logger.info("{} /dynamodb_remove_item_result=[{}]",
kvp("op", "removeRelation",
"appkey", group.getKey(),
"hash_key", relationHashKey,
"range_key", relationRangeKey,
"result", "ok"),
deleteItemOutcome.getDeleteItemResult().toString());
return null;
}
开发者ID:dehora,项目名称:outland,代码行数:31,代码来源:DefaultGroupStorage.java
示例3: updateItem
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
boolean updateItem(String key, long currentTimeMillis, int expiredIntervalMillis, Context context) {
AmazonDynamoDB client = createDynamoDBClient(cc);
String functionName = context.getFunctionName();
try {
long sec = currentTimeMillis - expiredIntervalMillis;
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable(TABLE_NAME);
Map<String, String> expressionAttributeNames = new HashMap<>();
expressionAttributeNames.put("#created_time", COL_CREATED_TIME);
Map<String, Object> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":now", currentTimeMillis);
expressionAttributeValues.put(":expired", sec);
table.updateItem(new PrimaryKey(COL_FUNCTION_NAME, functionName, COL_KEY, key), "set #created_time = :now", // UpdateExpression
"#created_time < :expired", // ConditionExpression
expressionAttributeNames, expressionAttributeValues);
return true;
} catch (ConditionalCheckFailedException e) {
return false;
} finally {
client.shutdown();
}
}
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:30,代码来源:LambdaLock.java
示例4: toPrimaryKey
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
private PrimaryKey toPrimaryKey(IndexKey key) {
PrimaryKey pk = new PrimaryKey()
.addComponent(_hkName, key.getHashKey());
if ( null != _rkName ) {
pk.addComponent(_rkName, key.getRangeKey());
}
return pk;
}
开发者ID:Distelli,项目名称:java-persistence,代码行数:9,代码来源:DdbIndex.java
示例5: handleRequest
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
@Override
public String handleRequest(Book request, Context context) {
Item outcome = DynamoDBUtil.getTable().getItem(new PrimaryKey("id", request.getId()));
if (null != outcome) {
return outcome.toJSONPretty();
}
return null;
}
开发者ID:arun-gupta,项目名称:serverless,代码行数:10,代码来源:BookGetOne.java
示例6: main
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
final Map<String, Object> infoMap = new HashMap<String, Object>();
infoMap.put("plot", "Nothing happens at all.");
infoMap.put("rating", 0.0);
Item item = new Item()
.withPrimaryKey(new PrimaryKey("year", year, "title", title))
.withMap("info", infoMap);
// Attempt a conditional write. We expect this to fail.
PutItemSpec putItemSpec = new PutItemSpec()
.withItem(item)
.withConditionExpression("attribute_not_exists(#yr) and attribute_not_exists(title)")
.withNameMap(new NameMap()
.with("#yr", "year"));
System.out.println("Attempting a conditional write...");
try {
table.putItem(putItemSpec);
System.out.println("PutItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
} catch (ConditionalCheckFailedException e) {
e.printStackTrace(System.err);
System.out.println("PutItem failed");
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:36,代码来源:MoviesItemOps02.java
示例7: main
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
public static void main(String[] args) {
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
client.setEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
// Conditional update (will fail)
UpdateItemSpec updateItemSpec = new UpdateItemSpec()
.withPrimaryKey(new PrimaryKey("year", 2015, "title", "The Big New Movie"))
.withUpdateExpression("remove info.actors[0]")
.withConditionExpression("size(info.actors) > :num")
.withValueMap(new ValueMap().withNumber(":num", 3));
System.out.println("Attempting a conditional update...");
try {
table.updateItem(updateItemSpec);
System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
} catch (ConditionalCheckFailedException e) {
e.printStackTrace();
System.out.println("UpdateItem failed");
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:30,代码来源:MoviesItemOps05.java
示例8: truncate
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
@Override
public void truncate() {
getAll()
.parallelStream()
.forEach(p -> table.deleteItem(new PrimaryKey("id", p.getId())));
}
开发者ID:BackendButters,项目名称:AwsCommons,代码行数:7,代码来源:AbstractDynamoTable.java
示例9: delete
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
@Override
public void delete(final String id) {
table.deleteItem(new PrimaryKey("id", id));
}
开发者ID:BackendButters,项目名称:AwsCommons,代码行数:5,代码来源:AbstractDynamoTable.java
示例10: createEventId
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
protected PrimaryKey createEventId(ILoggingEvent event) {
return new PrimaryKey(primaryKey, UUID.randomUUID().toString());
}
开发者ID:trautonen,项目名称:logback-ext,代码行数:4,代码来源:DynamoDbAppender.java
示例11: handleRequest
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
@Override
public String handleRequest(Book request, Context context) {
DeleteItemOutcome outcome = DynamoDBUtil.getTable().deleteItem(new PrimaryKey("id", request.getId()));
String result = "Item deleted: " + outcome.getDeleteItemResult().getSdkHttpMetadata().getHttpStatusCode();
return result;
}
开发者ID:arun-gupta,项目名称:serverless,代码行数:10,代码来源:BookDelete.java
示例12: setPrimaryKey
import com.amazonaws.services.dynamodbv2.document.PrimaryKey; //导入依赖的package包/类
private void setPrimaryKey(FilterLeaf leaf, PrimaryKey pk) {
}
开发者ID:fineoio,项目名称:drill-dynamo-adapter,代码行数:4,代码来源:DynamoQueryBuilder.java
注:本文中的com.amazonaws.services.dynamodbv2.document.PrimaryKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论