本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ScanRequest.setAttributesToGet方法的典型用法代码示例。如果您正苦于以下问题:Java ScanRequest.setAttributesToGet方法的具体用法?Java ScanRequest.setAttributesToGet怎么用?Java ScanRequest.setAttributesToGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.model.ScanRequest
的用法示例。
在下文中一共展示了ScanRequest.setAttributesToGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRows
import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
@Override
public List<String> getRows(String storeName, String continuationToken, int count) {
String tableName = storeToTableName(storeName);
ScanRequest scanRequest = new ScanRequest(tableName);
scanRequest.setAttributesToGet(Arrays.asList(ROW_KEY_ATTR_NAME)); // attributes to get
if (continuationToken != null) {
scanRequest.setExclusiveStartKey(makeDDBKey(continuationToken));
}
List<String> rowKeys = new ArrayList<>();
while (rowKeys.size() < count) {
ScanResult scanResult = scan(scanRequest);
List<Map<String, AttributeValue>> itemList = scanResult.getItems();
if (itemList.size() == 0) {
break;
}
for (Map<String, AttributeValue> attributeMap : itemList) {
AttributeValue rowAttr = attributeMap.get(ROW_KEY_ATTR_NAME);
rowKeys.add(rowAttr.getS());
if (rowKeys.size() >= count) {
break;
}
}
Map<String, AttributeValue> lastEvaluatedKey = scanResult.getLastEvaluatedKey();
if (lastEvaluatedKey == null) {
break;
}
scanRequest.setExclusiveStartKey(lastEvaluatedKey);
}
return rowKeys;
}
示例2: getRows
import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
@Override
public List<String> getRows(String storeName, String continuationToken, int count) {
Timer t = new Timer();
ScanRequest scanRequest = new ScanRequest(getTenant().getName());
scanRequest.setAttributesToGet(Arrays.asList("key")); // attributes to get
//if (continuationToken != null) {
// scanRequest.setExclusiveStartKey(getPrimaryKey(storeName + "_" + continuationToken, "\u007F"));
//} else {
// scanRequest.setExclusiveStartKey(getPrimaryKey(storeName + "_", "\0"));
//}
Set<String> rowKeys = new HashSet<>();
while (rowKeys.size() < count) {
ScanResult scanResult = m_client.scan(scanRequest);
List<Map<String, AttributeValue>> itemList = scanResult.getItems();
if (itemList.size() == 0) break;
for (Map<String, AttributeValue> attributeMap : itemList) {
AttributeValue rowAttr = attributeMap.get("key");
if(!rowAttr.getS().startsWith(storeName)) continue;
String name = rowAttr.getS().substring(storeName.length() + 1);
if(continuationToken != null && continuationToken.compareTo(name) >= 0) continue;
rowKeys.add(name);
}
Map<String, AttributeValue> lastEvaluatedKey = scanResult.getLastEvaluatedKey();
if (lastEvaluatedKey == null) break;
scanRequest.setExclusiveStartKey(getPrimaryKey(lastEvaluatedKey.get("key").getS(), "\u007F"));
}
List<String> list = new ArrayList<>(rowKeys);
Collections.sort(list);
m_logger.debug("get rows in {} in {}", storeName, t);
return list;
}
示例3: materializeMainSchemaTable
import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
@Override
protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) {
final List<String> attributeNames = columns.stream().map(col-> col.getName()).collect(Collectors.toList());
final ScanRequest scanRequest = new ScanRequest(table.getName());
scanRequest.setAttributesToGet(attributeNames);
if (maxRows > 0) {
scanRequest.setLimit(maxRows);
}
final ScanResult result = _dynamoDb.scan(scanRequest);
return new DynamoDbDataSet(columns, result);
}