本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.Item.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getString方法的具体用法?Java Item.getString怎么用?Java Item.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.document.Item
的用法示例。
在下文中一共展示了Item.getString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Override
public void transform(Item scoreItem, DynamoDB dynamodb) {
String playerName = scoreItem.getString(PLAYER_NAME);
int score = scoreItem.getInt(SCORE);
int gameLength = scoreItem.getInt(GAME_LENGTH);
/*
* The XSpec API allows you to use DynamoDB's expression language
* to execute expressions on the service-side.
*
* https://java.awsblog.com/post/TxBG87QOQZRZJF/-DynamoDB-XSpec-API
*/
Table viewTable = dynamodb.getTable(PLAYER_STATS_TABLE_NAME);
UpdateItemExpressionSpec incrementTotalOrder = new ExpressionSpecBuilder()
.addUpdate(N(TOTAL_SCORE).add(score))
.addUpdate(N(TOTAL_GAMEPLAY).add(gameLength))
.addUpdate(N(TOTAL_GAMES).add(1))
.buildForUpdate();
viewTable.updateItem(PLAYER_NAME, playerName, incrementTotalOrder);
}
示例2: readOwningType
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
public String readOwningType(final String identity)
{
final Table table = dynamoDBConnection.getDynamoDB().getTable(getTableName());
final Item item = table.getItem("_id", generateItemId(identity));
if (item != null)
{
return item.getString(DynamoDBUtils.FIELD_NAME_OWNING_ACTOR_TYPE);
}
return null;
}
示例3: monitorScanners
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
private void monitorScanners() {
boolean incomplete = true;
while (incomplete) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
incomplete = false;
for (int i = 0; i < totalSegments; i++) {
Item item = functionTrackerTable.getItem(SEGMENT, i);
if (item != null) {
String status = item.getString(STATUS);
if (!status.equals(STATUS_DONE)) {
incomplete = true;
}
if (status.equals(STATUS_INCOMPLETE)) {
String startScoreId = item.getString(LAST_SCORE_ID);
invokeScannerOnSegment(i, startScoreId);
}
} else {
incomplete = true;
break;
}
}
}
}
示例4: next
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Override
public MAVLinkRecord next() {
Item item = itemIterator.next();
return new MAVLinkRecord(item.getString(ATTR_DEVICE_ID), new Date(item.getLong(ATTR_TIME)), item.getInt(ATTR_MSG_ID), item.getMap(ATTR_MESSAGE));
}
示例5: deleteAllFromSharedTable
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
/**
* Deletes all objects in a shared table, which belong to a given appid, by scanning the GSI.
* @param appid app id
*/
public static void deleteAllFromSharedTable(String appid) {
if (StringUtils.isBlank(appid) || !isSharedAppid(appid)) {
return;
}
Pager pager = new Pager(50);
List<WriteRequest> allDeletes = new LinkedList<>();
Page<Item, QueryOutcome> items;
// read all phase
do {
items = queryGSI(appid, pager);
if (items == null) {
break;
}
for (Item item : items) {
String key = item.getString(Config._KEY);
// only delete rows which belong to the given appid
if (StringUtils.startsWith(key, appid.trim())) {
logger.debug("Preparing to delete '{}' from shared table, appid: '{}'.", key, appid);
pager.setLastKey(item.getString(Config._ID));
allDeletes.add(new WriteRequest().withDeleteRequest(new DeleteRequest().
withKey(Collections.singletonMap(Config._KEY, new AttributeValue(key)))));
}
}
} while (items.iterator().hasNext());
// delete all phase
final int maxItems = 20;
int batchSteps = (allDeletes.size() > maxItems) ? (allDeletes.size() / maxItems) + 1 : 1;
List<WriteRequest> reqs = new LinkedList<>();
Iterator<WriteRequest> it = allDeletes.iterator();
String tableName = getTableNameForAppid(appid);
for (int i = 0; i < batchSteps; i++) {
while (it.hasNext() && reqs.size() < maxItems) {
reqs.add(it.next());
}
if (reqs.size() > 0) {
logger.info("Deleting {} items belonging to app '{}', from shared table (page {}/{})...",
reqs.size(), appid, i + 1, batchSteps);
batchWrite(Collections.singletonMap(tableName, reqs));
}
reqs.clear();
}
}