本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ScanResult类的典型用法代码示例。如果您正苦于以下问题:Java ScanResult类的具体用法?Java ScanResult怎么用?Java ScanResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScanResult类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了ScanResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpTables
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
private void dumpTables() {
for (String table : client.listTables().getTableNames()) {
ScanResult scanResult;
Map<String, AttributeValue> lastKey = null;
do {
scanResult = client.scan(new ScanRequest().withTableName(table).withExclusiveStartKey(lastKey));
lastKey = scanResult.getLastEvaluatedKey();
for (Map<String, AttributeValue> map : scanResult.getItems()) {
for (Map.Entry<String, AttributeValue> item : map.entrySet()) {
System.out.print("item.put(\"");
System.out.print(item.getKey());
System.out.print("\", b642Av(\"");
System.out.print(Base64.encodeAsString(AttributeValueMarshaller.marshall(item.getValue()).array()));
System.out.println("\"));");
}
System.out.print("ddb.putItem(new PutItemRequest(\"");
System.out.print(table);
System.out.println("\", item));");
System.out.println("item.clear();");
System.out.println();
}
} while (lastKey != null);
}
}
示例2: getAll
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* Gets all.
*
* @return the all
*/
public Collection<Ticket> getAll() {
final Collection<Ticket> tickets = new ArrayList<>();
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
metadata.forEach(r -> {
final ScanRequest scan = new ScanRequest(r.getProperties().getStorageName());
LOGGER.debug("Scanning table with request [{}]", scan);
final ScanResult result = this.amazonDynamoDBClient.scan(scan);
LOGGER.debug("Scanned table with result [{}]", scan);
tickets.addAll(result.getItems()
.stream()
.map(DynamoDbTicketRegistryFacilitator::deserializeTicket)
.collect(Collectors.toList()));
});
return tickets;
}
示例3: locate
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
@Override
public PropertySource<?> locate(final Environment environment) {
final AmazonDynamoDBClient amazonDynamoDBClient = getAmazonDynamoDbClient(environment);
createSettingsTable(amazonDynamoDBClient, false);
final ScanRequest scan = new ScanRequest(TABLE_NAME);
LOGGER.debug("Scanning table with request [{}]", scan);
final ScanResult result = amazonDynamoDBClient.scan(scan);
LOGGER.debug("Scanned table with result [{}]", scan);
final Properties props = new Properties();
result.getItems()
.stream()
.map(DynamoDbCloudConfigBootstrapConfiguration::retrieveSetting)
.forEach(p -> props.put(p.getKey(), p.getValue()));
return new PropertiesPropertySource(getClass().getSimpleName(), props);
}
示例4: scanTable
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
public RetryResult<ScanResult> scanTable(
String tableName, DynamoDBQueryFilter dynamoDBQueryFilter, Integer segment, Integer
totalSegments, Map<String, AttributeValue> exclusiveStartKey, long limit, Reporter reporter) {
final ScanRequest scanRequest = new ScanRequest(tableName)
.withExclusiveStartKey(exclusiveStartKey)
.withLimit(Ints.checkedCast(limit))
.withSegment(segment)
.withTotalSegments(totalSegments)
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);
if (dynamoDBQueryFilter != null) {
Map<String, Condition> scanFilter = dynamoDBQueryFilter.getScanFilter();
if (!scanFilter.isEmpty()) {
scanRequest.setScanFilter(scanFilter);
}
}
RetryResult<ScanResult> retryResult = getRetryDriver().runWithRetry(new Callable<ScanResult>() {
@Override
public ScanResult call() {
log.debug("Executing DynamoDB scan: " + scanRequest);
return dynamoDB.scan(scanRequest);
}
}, reporter, PrintCounter.DynamoDBReadThrottle);
return retryResult;
}
示例5: fetchPage
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
@Override
protected PageResults<Map<String, AttributeValue>> fetchPage(RequestLimit lim) {
// Read from DynamoDB
RetryResult<ScanResult> retryResult = context.getClient().scanTable(tableName, null, segment,
context.getSplit().getTotalSegments(), lastEvaluatedKey, lim.items, context.getReporter());
ScanResult result = retryResult.result;
int retries = retryResult.retries;
double consumedCapacityUnits = 0.0;
if (result.getConsumedCapacity() != null) {
consumedCapacityUnits = result.getConsumedCapacity().getCapacityUnits();
}
return new PageResults<>(result.getItems(), result.getLastEvaluatedKey(), consumedCapacityUnits,
retries);
}
示例6: getHashNumberRangeKeyItems
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
private ScanResult getHashNumberRangeKeyItems(String[] hashKeys, String hashType) {
List<Map<String, AttributeValue>> items = new ArrayList<>();
for (String key : hashKeys) {
for (Integer i = 0; i < NUM_RANGE_KEYS_PER_HASH_KEY; i++) {
Map<String, AttributeValue> item = new HashMap<>();
if (hashType.equals("S")) {
item.put("hashKey", new AttributeValue(key));
} else {
item.put("hashKey", new AttributeValue().withN(key));
}
item.put("rangeKey", new AttributeValue().withN("0" + i.toString()));
items.add(item);
}
}
return new ScanResult().withScannedCount(items.size()).withItems(items).withConsumedCapacity
(new ConsumedCapacity().withCapacityUnits(1d));
}
示例7: scan
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
public ScanResult scan(final ScanRequest request, final int permitsToConsume) throws BackendException {
setUserAgent(request);
ScanResult result;
timedReadThrottle(SCAN, request.getTableName(), permitsToConsume);
final Timer.Context apiTimerContext = getTimerContext(SCAN, request.getTableName());
try {
result = client.scan(request);
} catch (Exception e) {
throw processDynamoDbApiException(e, SCAN, request.getTableName());
} finally {
apiTimerContext.stop();
}
meterConsumedCapacity(SCAN, result.getConsumedCapacity());
measureItemCount(SCAN, request.getTableName(), result.getCount());
return result;
}
示例8: next
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
@SuppressFBWarnings(value = "IT_NO_SUCH_ELEMENT",
justification = "https://github.com/awslabs/dynamodb-janusgraph-storage-backend/issues/222")
@Override
public ScanResult next() {
final Scan backoff = new Scan(request, delegate, lastConsumedCapacity);
ScanResult result = null;
try {
result = backoff.runWithBackoff(); //this will be non-null or runWithBackoff throws
} catch (BackendException e) {
throw new BackendRuntimeException(e);
}
if (result.getConsumedCapacity() != null) {
lastConsumedCapacity = result.getConsumedCapacity().getCapacityUnits().intValue();
}
if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) {
hasNext = true;
request.setExclusiveStartKey(result.getLastEvaluatedKey());
} else {
hasNext = false;
}
return result;
}
示例9: listUsers
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* Returns the list of usernames stored in the identity table.
*
* @return list of existing usernames in DynamoDB table
*/
public List<String> listUsers() {
List<String> users = new ArrayList<String>(1000);
ScanResult result = ddb.scan(new ScanRequest().withTableName(USER_TABLE).withLimit(1000));
for (Map<String, AttributeValue> item : result.getItems()) {
String s = "";
for (Entry<String, AttributeValue> entry : item.entrySet()) {
s += " ** " + entry.getKey() + " = " + entry.getValue().getS();
}
users.add(s);
}
return users;
}
开发者ID:awslabs,项目名称:amazon-cognito-developer-authentication-sample,代码行数:23,代码来源:UserAuthentication.java
示例10: listDevices
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* @return the list of device ID (UID) stored in the identity table.
*/
public List<String> listDevices() {
List<String> devices = new ArrayList<String>(1000);
ScanResult result = ddb.scan(new ScanRequest().withTableName(DEVICE_TABLE).withLimit(1000));
for (Map<String, AttributeValue> item : result.getItems()) {
String s = "";
for (Entry<String, AttributeValue> entry : item.entrySet()) {
s += " ** " + entry.getKey() + " = " + entry.getValue().getS();
}
devices.add(s);
}
return devices;
}
开发者ID:awslabs,项目名称:amazon-cognito-developer-authentication-sample,代码行数:21,代码来源:DeviceAuthentication.java
示例11: runWithBackoff
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* begins a scan with an exponential back off if throttled.
*/
public ScanResult runWithBackoff() {
ScanResult result = null;
boolean interrupted = false;
try {
do {
try {
result = client.scan(request);
} catch (Exception e) {
try {
Thread.sleep(exponentialBackoffTime);
} catch (InterruptedException ie) {
interrupted = true;
} finally {
exponentialBackoffTime *= 2;
}
continue;
}
} while (result == null);
return result;
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
示例12: getLandUnits
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
@Override
public List<LandUnit> getLandUnits(Long userId) {
List<LandUnit> retval = new ArrayList<LandUnit>();
try {
/*
* Scan items for movies with user id attribute.
*/
Map<String, Condition> scanFilter = new HashMap<String, Condition>();
Condition condition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withN(userId.toString()));
scanFilter.put(LandUnit.USER_ID_ATTR_NAME, condition);
ScanRequest scanRequest =
new ScanRequest(LANDUNIT_DYNAMO_DB_TABLE_NAME).withScanFilter(scanFilter);
ScanResult scanResult = dynamoDB.scan(scanRequest);
LOG.debug("DDB Scan Result: " + scanResult);
retval = mapItemsToLandUnit(scanResult.getItems());
} catch (Exception e) {
LOG.error("Unable to retrieve land units from DDB " + e.getMessage());
}
return retval;
}
示例13: getDictionaryEntry
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* Generate a list of attribute names found in the Aggregator's dynamo
* table. Assumes that all Items in the Aggregator table are of the same
* structure.
*
* @param dynamoClient
* Dynamo DB Client to use for connection to Dynamo DB.
* @param dynamoTable
* The Dynamo Table for the Aggregator
* @return A list of attribute names from the Dynamo table
* @throws Exception
*/
public static List<String> getDictionaryEntry(
final AmazonDynamoDB dynamoClient, final String dynamoTable)
throws Exception {
// get a list of all columns in the table, with keys first
List<String> columns = new ArrayList<>();
List<KeySchemaElement> keys = dynamoClient.describeTable(dynamoTable)
.getTable().getKeySchema();
for (KeySchemaElement key : keys) {
columns.add(key.getAttributeName());
}
ScanResult scan = dynamoClient.scan(new ScanRequest()
.withTableName(dynamoTable).withSelect(Select.ALL_ATTRIBUTES)
.withLimit(1));
List<Map<String, AttributeValue>> scannedItems = scan.getItems();
for (Map<String, AttributeValue> map : scannedItems) {
for (String s : map.keySet()) {
if (!columns.contains(s))
columns.add(s);
}
}
return columns;
}
示例14: getDictionaryEntry
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
/**
* Generate a list of attribute names found in the Aggregator's dynamo
* table. Assumes that all Items in the Aggregator table are of the same
* structure.
*
* @param dynamoClient Dynamo DB Client to use for connection to Dynamo DB.
* @param dynamoTable The Dynamo Table for the Aggregator
* @return A list of attribute names from the Dynamo table
* @throws Exception
*/
protected List<String> getDictionaryEntry() throws Exception {
// get a list of all columns in the table, with keys first
List<String> columns = new ArrayList<>();
List<KeySchemaElement> keys = dynamoClient.describeTable(this.tableName).getTable().getKeySchema();
for (KeySchemaElement key : keys) {
columns.add(key.getAttributeName());
}
ScanResult scan = dynamoClient.scan(new ScanRequest().withTableName(this.tableName).withSelect(
Select.ALL_ATTRIBUTES).withLimit(1));
List<Map<String, AttributeValue>> scannedItems = scan.getItems();
for (Map<String, AttributeValue> map : scannedItems) {
for (String s : map.keySet()) {
if (!columns.contains(s))
columns.add(s);
}
}
return columns;
}
示例15: findProductsForPriceLessThanZero
import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入依赖的package包/类
private static void findProductsForPriceLessThanZero() {
Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>();
expressionAttributeValues.put(":pr", new AttributeValue().withN("100"));
ScanRequest scanRequest = new ScanRequest()
.withTableName(tableName)
.withFilterExpression("Price < :pr")
.withExpressionAttributeValues(expressionAttributeValues)
.withProjectionExpression("Id, Title, ProductCategory, Price");
ScanResult result = client.scan(scanRequest);
System.out.println("Scan of " + tableName + " for items with a price less than 100.");
for (Map<String, AttributeValue> item : result.getItems()) {
System.out.println("");
printItem(item);
}
}