本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.QueryResult类的典型用法代码示例。如果您正苦于以下问题:Java QueryResult类的具体用法?Java QueryResult怎么用?Java QueryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryResult类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了QueryResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: query
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
private QueryOutcome query(Object hk, QuerySpec querySpec, PageIterator pageIterator) {
if ( null == _convertMarker ) {
throw new IllegalStateException("Index must first be initialized with ConvertMarker");
}
if ( pageIterator.getPageSize() <= 0 ) {
return new QueryOutcome(new QueryResult());
}
ItemCollection<QueryOutcome> itemCollection =
maybeBackoff(true, () ->
_query.query(withMarker(querySpec.withHashKey(_hkName, hk), pageIterator, hk)));
if ( null != itemCollection ) {
Iterator<Page<Item, QueryOutcome>> iterator = itemCollection.pages().iterator();
if ( iterator.hasNext() ) {
QueryOutcome outcome = maybeBackoff(true, () -> iterator.next().getLowLevelResult());
QueryResult result = outcome.getQueryResult();
if ( null != pageIterator.getMarker() && null != result.getItems() && result.getItems().size() > 0 ) {
pageIterator.setPrevMarker(toMarker(result.getItems().get(0), true));
} else {
pageIterator.setPrevMarker(null);
}
Map<String,AttributeValue> lastKey = result.getLastEvaluatedKey();
if ( null != lastKey && ! lastKey.isEmpty() ) {
pageIterator.setMarker(toMarker(lastKey, true));
} else {
pageIterator.setMarker(null);
}
return outcome;
}
}
pageIterator.setPrevMarker(null);
pageIterator.setMarker(null);
return new QueryOutcome(new QueryResult());
}
开发者ID:Distelli,项目名称:java-persistence,代码行数:35,代码来源:DdbIndex.java
示例2: testDeleteSecretMaliciousResults
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Test
public void testDeleteSecretMaliciousResults() {
QueryRequest request = constructQueryRequest(SECRET_NAME);
// Result contains entries that do no match the filter in the request (i.e. items for secret2). So it should be
// considered malicious.
QueryResult maliciousResult = constructQueryResult(true);
when(mockDynamoDBClient.query(request)).thenReturn(maliciousResult);
// Call the delete secret method.
boolean consideredMalicious = false;
try {
dynamoDB.delete(new SecretIdentifier(SECRET_NAME));
} catch (PotentiallyMaliciousDataException e) {
consideredMalicious = true;
}
assertTrue(consideredMalicious);
// Verify nothing was actually deleted because the malicious check failed.
verify(mockDynamoDBClient, times(1)).query(request);
verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET_NAME, 1));
verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET_NAME, 2));
verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET2_NAME, 1));
}
开发者ID:schibsted,项目名称:strongbox,代码行数:25,代码来源:GenericDynamoDBTest.java
示例3: find
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
/**
*
* @param targetClass <code>Map</code> or entity class with getter/setter method.
* @param queryRequest
* @return
*/
public <T> List<T> find(final Class<T> targetClass, final QueryRequest queryRequest) {
final QueryResult queryResult = dynamoDB.query(queryRequest);
final List<T> res = toList(targetClass, queryResult);
if (N.notNullOrEmpty(queryResult.getLastEvaluatedKey()) && N.isNullOrEmpty(queryRequest.getExclusiveStartKey())) {
final QueryRequest newQueryRequest = queryRequest.clone();
QueryResult newQueryResult = queryResult;
while (N.notNullOrEmpty(newQueryResult.getLastEvaluatedKey())) {
newQueryRequest.setExclusiveStartKey(newQueryResult.getLastEvaluatedKey());
newQueryResult = dynamoDB.query(newQueryRequest);
res.addAll(toList(targetClass, newQueryResult));
}
}
return res;
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:24,代码来源:DynamoDBExecutor.java
示例4: query
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
/**
*
* @param targetClass
* @param queryRequest
* @return
* @see #find(Class, QueryRequest)
*/
public DataSet query(final Class<?> targetClass, final QueryRequest queryRequest) {
if (targetClass == null || Map.class.isAssignableFrom(targetClass)) {
final QueryResult queryResult = dynamoDB.query(queryRequest);
final List<Map<String, AttributeValue>> items = queryResult.getItems();
if (N.notNullOrEmpty(queryResult.getLastEvaluatedKey()) && N.isNullOrEmpty(queryRequest.getExclusiveStartKey())) {
final QueryRequest newQueryRequest = queryRequest.clone();
QueryResult newQueryResult = queryResult;
while (N.notNullOrEmpty(newQueryResult.getLastEvaluatedKey())) {
newQueryRequest.setExclusiveStartKey(newQueryResult.getLastEvaluatedKey());
newQueryResult = dynamoDB.query(newQueryRequest);
items.addAll(newQueryResult.getItems());
}
}
return extractData(items, 0, items.size());
} else {
return N.newDataSet(find(targetClass, queryRequest));
}
}
开发者ID:landawn,项目名称:AbacusUtil,代码行数:29,代码来源:DynamoDBExecutor.java
示例5: queryTable
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public RetryResult<QueryResult> queryTable(
String tableName, DynamoDBQueryFilter dynamoDBQueryFilter, Map<String, AttributeValue>
exclusiveStartKey, long limit, Reporter reporter) {
final QueryRequest queryRequest = new QueryRequest()
.withTableName(tableName)
.withExclusiveStartKey(exclusiveStartKey)
.withKeyConditions(dynamoDBQueryFilter.getKeyConditions())
.withLimit(Ints.checkedCast(limit))
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);
RetryResult<QueryResult> retryResult = getRetryDriver().runWithRetry(
new Callable<QueryResult>() {
@Override
public QueryResult call() {
log.debug("Executing DynamoDB query: " + queryRequest);
return dynamoDB.query(queryRequest);
}
}, reporter, PrintCounter.DynamoDBReadThrottle);
return retryResult;
}
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:21,代码来源:DynamoDBClient.java
示例6: accountGetAccountByToken
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public Account accountGetAccountByToken(String token) {
Condition hashKeyCondition = new Condition();
hashKeyCondition.withComparisonOperator(ComparisonOperator.EQ).withAttributeValueList(new AttributeValue().withS(token));
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("accountToken", hashKeyCondition);
QueryRequest queryRequest = new QueryRequest();
queryRequest.withTableName("accountsv2");
queryRequest.withIndexName("accountToken-index");
queryRequest.withKeyConditions(keyConditions);
QueryResult result = dynamoDB.query(queryRequest);
for(Map<String, AttributeValue> item : result.getItems()) {
Account mappedItem = mapper.marshallIntoObject(Account.class, item);
// Only want the First one
return mappedItem;
}
return null;
}
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:24,代码来源:AmazonDynamoDBDAO.java
示例7: execute
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Override
public void execute() {
QueryResult result = ddbClient.query(new QueryRequest()
.withTableName(determineTableName())
.withAttributesToGet(determineAttributeNames())
.withConsistentRead(determineConsistentRead())
.withExclusiveStartKey(determineStartKey())
.withKeyConditions(determineKeyConditions())
.withExclusiveStartKey(determineStartKey())
.withLimit(determineLimit())
.withScanIndexForward(determineScanIndexForward()));
Map tmp = new HashMap<>();
tmp.put(DdbConstants.ITEMS, result.getItems());
tmp.put(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
tmp.put(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
tmp.put(DdbConstants.COUNT, result.getCount());
addToResults(tmp);
}
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:QueryCommand.java
示例8: query
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public QueryResult query(final QueryRequest request, final int permitsToConsume) throws BackendException {
setUserAgent(request);
QueryResult result;
timedReadThrottle(QUERY, request.getTableName(), permitsToConsume);
final Timer.Context apiTimerContext = getTimerContext(QUERY, request.getTableName());
try {
result = client.query(request);
} catch (Exception e) {
throw processDynamoDbApiException(e, QUERY, request.getTableName());
} finally {
apiTimerContext.stop();
}
meterConsumedCapacity(QUERY, result.getConsumedCapacity());
measureItemCount(QUERY, request.getTableName(), result.getCount());
return result;
}
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:17,代码来源:DynamoDbDelegate.java
示例9: getSlice
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Override
public Map<StaticBuffer, EntryList> getSlice(final List<StaticBuffer> keys, final SliceQuery query, final StoreTransaction txh) throws BackendException {
log.debug("Entering getSliceMultiSliceQuery table:{} keys:{} query:{} txh:{}",
getTableName(),
encodeForLog(keys),
encodeForLog(query),
txh);
final Map<StaticBuffer, EntryList> resultMap = Maps.newHashMapWithExpectedSize(keys.size());
final List<QueryWorker> queryWorkers = Lists.newLinkedList();
for (StaticBuffer hashKey : keys) {
final QueryWorker queryWorker = buildQueryWorker(hashKey, query);
queryWorkers.add(queryWorker);
resultMap.put(hashKey, EntryList.EMPTY_LIST);
}
final List<QueryResultWrapper> results = client.getDelegate().parallelQuery(queryWorkers);
for (QueryResultWrapper resultWrapper : results) {
final StaticBuffer titanKey = resultWrapper.getTitanKey();
final QueryResult dynamoDBResult = resultWrapper.getDynamoDBResult();
final EntryList entryList = createEntryListFromItems(dynamoDBResult.getItems(), query);
resultMap.put(titanKey, entryList);
}
log.debug("Exiting getSliceMultiSliceQuery table:{} keys:{} query:{} txh:{} returning:{}",
getTableName(),
encodeForLog(keys),
encodeForLog(query),
txh,
resultMap.size());
return resultMap;
}
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:36,代码来源:DynamoDbStore.java
示例10: next
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Override
public QueryResultWrapper next() throws BackendException {
final Query backoff = new ExponentialBackoff.Query(request, delegate, permitsToConsume);
final QueryResult result = backoff.runWithBackoff();
final ConsumedCapacity consumedCapacity = result.getConsumedCapacity();
if (null != consumedCapacity) {
permitsToConsume = Math.max((int) (consumedCapacity.getCapacityUnits() - 1.0), 1);
totalCapacityUnits += consumedCapacity.getCapacityUnits();
}
if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) {
request.setExclusiveStartKey(result.getLastEvaluatedKey());
} else {
markComplete();
}
// a update returned count
returnedCount += result.getCount();
// b update scanned count
scannedCount += result.getScannedCount();
// c add scanned finalItemList
finalItemList.addAll(result.getItems());
return new QueryResultWrapper(titanKey, result);
}
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:25,代码来源:QueryWorker.java
示例11: hasNext
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Override
public boolean hasNext() {
if (closed) {
return false;
}
if (currentIterator.hasNext()) {
return true;
}
// Loop until the query finds a new result.
// This is necessary because even if the query worker has a next page it might have no results.
while (queryWorker.hasNext() && !currentIterator.hasNext()) {
try {
final QueryResultWrapper resultWrapper = queryWorker.next();
final QueryResult queryResult = resultWrapper.getDynamoDBResult();
currentIterator = buildRecordIteratorFromQueryResult(queryResult);
} catch (BackendException e) {
throw new RuntimeException(e);
}
}
return currentIterator.hasNext();
}
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:23,代码来源:MultiRecordIterator.java
示例12: queryUntilDone
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public static List<Map<String, AttributeValue>> queryUntilDone(
AmazonDynamoDB dynamoClient, QueryRequest qr, int backoffMillis)
throws Exception {
List<Map<String, AttributeValue>> output = new ArrayList<>();
Map<String, AttributeValue> lastKeyEvaluated = null;
do {
int queryAttempts = 0;
QueryResult result = null;
do {
try {
result = dynamoClient.query(qr).withLastEvaluatedKey(
lastKeyEvaluated);
output.addAll(result.getItems());
} catch (ProvisionedThroughputExceededException e) {
LOG.warn(String
.format("Provisioned Throughput Exceeded - Retry Attempt %s",
queryAttempts));
Thread.sleep(2 ^ queryAttempts * backoffMillis);
queryAttempts++;
}
} while (queryAttempts < 10 && result == null);
if (result == null) {
throw new Exception(String.format(
"Unable to execute Query after %s attempts",
queryAttempts));
}
lastKeyEvaluated = result.getLastEvaluatedKey();
} while (lastKeyEvaluated != null);
return output;
}
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:39,代码来源:DynamoUtils.java
示例13: findRepliesForAThread
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
private static void findRepliesForAThread(String forumName, String threadSubject) {
String replyId = forumName + "#" + threadSubject;
Condition hashKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS(replyId));
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("Id", hashKeyCondition);
QueryRequest queryRequest = new QueryRequest()
.withTableName(tableName)
.withKeyConditions(keyConditions);
QueryResult result = client.query(queryRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
printItem(item);
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:21,代码来源:LowLevelQuery.java
示例14: findRepliesForAThreadSpecifyOptionalLimit
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
private static void findRepliesForAThreadSpecifyOptionalLimit(String forumName, String threadSubject) {
Map<String, AttributeValue> lastEvaluatedKey = null;
do {
QueryRequest queryRequest = new QueryRequest()
.withTableName(tableName)
.withKeyConditions(makeReplyKeyConditions(forumName, threadSubject))
.withLimit(1)
.withExclusiveStartKey(lastEvaluatedKey);
QueryResult result = client.query(queryRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
printItem(item);
}
lastEvaluatedKey = result.getLastEvaluatedKey();
} while (lastEvaluatedKey != null);
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:18,代码来源:LowLevelQuery.java
示例15: findRepliesInLast15DaysWithConfig
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
private static void findRepliesInLast15DaysWithConfig(String forumName, String threadSubject) {
long twoWeeksAgoMilli = (new Date()).getTime() - (15L*24L*60L*60L*1000L);
Date twoWeeksAgo = new Date();
twoWeeksAgo.setTime(twoWeeksAgoMilli);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String twoWeeksAgoStr = df.format(twoWeeksAgo);
Condition rangeKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.GT.toString())
.withAttributeValueList(new AttributeValue().withS(twoWeeksAgoStr));
Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject);
keyConditions.put("ReplyDateTime", rangeKeyCondition);
QueryRequest queryRequest = new QueryRequest().withTableName(tableName)
.withKeyConditions(keyConditions)
.withProjectionExpression("Message, ReplyDateTime, PostedBy");
QueryResult result = client.query(queryRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
printItem(item);
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:26,代码来源:LowLevelQuery.java
示例16: findRepliesUsingAFilterExpression
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
private static void findRepliesUsingAFilterExpression(String forumName, String threadSubject) {
Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject);
Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>();
expressionAttributeValues.put(":val", new AttributeValue().withS("User B"));
QueryRequest queryRequest = new QueryRequest()
.withTableName(tableName)
.withKeyConditions(keyConditions)
.withFilterExpression("PostedBy = :val")
.withExpressionAttributeValues(expressionAttributeValues)
.withProjectionExpression("Message, ReplyDateTime, PostedBy");
QueryResult result = client.query(queryRequest);
for (Map<String, AttributeValue> item : result.getItems()) {
printItem(item);
}
}
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:20,代码来源:LowLevelQuery.java
示例17: run
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public void run() {
QueryRequest queryRequest = DynamoDBUtil.copyQueryRequest(geoQueryRequest.getQueryRequest());
long hashKey = S2Manager.generateHashKey(range.getRangeMin(), config.getHashKeyLength());
List<QueryResult> queryResults = dynamoDBManager.queryGeohash(queryRequest, hashKey, range);
for (QueryResult queryResult : queryResults) {
if (isInterrupted()) {
return;
}
// getQueryResults() returns a synchronized list.
geoQueryResult.getQueryResults().add(queryResult);
List<Map<String, AttributeValue>> filteredQueryResult = filter(queryResult.getItems(), geoQueryRequest);
// getItem() returns a synchronized list.
geoQueryResult.getItem().addAll(filteredQueryResult);
}
}
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:21,代码来源:GeoDataManager.java
示例18: getFromMSS
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public static DynamoEntry getFromMSS(String parameter)
{
dynamoDB = new AmazonDynamoDBClient(new ProfileCredentialsProvider().getCredentials());
dynamoDB.setRegion(Region.getRegion(Regions.EU_WEST_1));
HashMap<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("Parameter", new Condition().withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue(parameter)));
QueryRequest queryRequest = new QueryRequest();
queryRequest.setKeyConditions(keyConditions);
queryRequest.withTableName("MSS");
QueryResult result = dynamoDB.query(queryRequest);
//se houver um pedido ja tratado no MSS getCount > 0, caso contrario nao existe
if(result.getCount() == 0)
return null;
else
{
//vamos buscar o rank
Map<String, AttributeValue> queryResult = result.getItems().get(0);
String rank = "";
boolean runningState = false;
for (Map.Entry<String, AttributeValue> entry : queryResult.entrySet())
{
if(entry.getKey().equals("Rank"))
rank = entry.getValue().getN();
else if(entry.getKey().equals("Running"))
runningState = entry.getValue().getBOOL();
}
DynamoEntry rankResult = new DynamoEntry(new BigInteger(rank), runningState);
return rankResult;
}
}
开发者ID:carlosfaria94,项目名称:CloudPrime,代码行数:36,代码来源:DynamoEntry.java
示例19: getEntryDynamo
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
public static synchronized QueryResult getEntryDynamo(String parameter, AmazonDynamoDBClient dynamoDB) {
HashMap<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("Parameter", new Condition().withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue(parameter)));
QueryRequest queryRequest = new QueryRequest();
queryRequest.setKeyConditions(keyConditions);
queryRequest.withTableName("MSS");
QueryResult result = dynamoDB.query(queryRequest);
return result;
}
开发者ID:carlosfaria94,项目名称:CloudPrime,代码行数:13,代码来源:InstTool.java
示例20: run
import com.amazonaws.services.dynamodbv2.model.QueryResult; //导入依赖的package包/类
@Override
public void run() {
try {
FileInputStream logFile = new FileInputStream("logIntermedio.txt");
BufferedReader bufReader = new BufferedReader(new InputStreamReader(logFile));
String line;
while ((line = bufReader.readLine()) != null) {
String[] parts = line.split(":");
if (parts[0].equals(threadID)) {
AmazonDynamoDBClient dynamoDB = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
dynamoDB.setRegion(Region.getRegion(Regions.EU_WEST_1));
String[] parameterParts = parts[1].split("=");
String parameter = parameterParts[1];
QueryResult result = getEntryDynamo(parameter, dynamoDB);
if (result.getCount() == 0) // se a query nao retornar nada significa que nao temos nada no dynamo sobre este parametro
{
putDynamo(parameter, metricas.i_count, metricas.b_count, metricas.fieldLoadCount,
metricas.loadCount, dynamoDB, true, threadID, null);
} else { //caso contrario vamos buscar as metricas que temos para atualiza las
Map<String, AttributeValue> queryResult = result.getItems().get(0);
// runningValue fica a true se Running estiver a true, se ja estiver a false entao ja temos as metricas finais para este parametro portanto nao atualizamos o dynamo
boolean runningValue = queryResult.values().contains(new AttributeValue().withBOOL(true));
if (runningValue) {
putDynamo(parameter, metricas.i_count, metricas.b_count, metricas.fieldLoadCount,
metricas.loadCount, dynamoDB, true, threadID, result);
}
}
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:carlosfaria94,项目名称:CloudPrime,代码行数:41,代码来源:InstTool.java
注:本文中的com.amazonaws.services.dynamodbv2.model.QueryResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论