当前位置: 首页>>代码示例>>Java>>正文


Java ScanRequest.withExclusiveStartKey方法代码示例

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.ScanRequest.withExclusiveStartKey方法的典型用法代码示例。如果您正苦于以下问题:Java ScanRequest.withExclusiveStartKey方法的具体用法?Java ScanRequest.withExclusiveStartKey怎么用?Java ScanRequest.withExclusiveStartKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.dynamodbv2.model.ScanRequest的用法示例。


在下文中一共展示了ScanRequest.withExclusiveStartKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scan

import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
private Stream<Entry> scan(SecretEventStream.Filter<Entry> filter, Converters converters) {
    ScanRequest scanRequest = new ScanRequest();
    scanRequest.withConsistentRead(true);
    scanRequest.withTableName(tableName);

    FilterGenerator filterGenerator = new FilterGenerator();
    FilterGenerator.Filter generated = filterGenerator.process(filter.parsedAttributeCondition.get(), converters);

    if(!generated.expressionAttributeNames.isEmpty()) {
        scanRequest.withExpressionAttributeNames(generated.expressionAttributeNames);
    }

    if (!generated.expressionAttributeValues.isEmpty()) {
        scanRequest.withExpressionAttributeValues(generated.expressionAttributeValues);
    }

    scanRequest.withFilterExpression(generated.filterExpression);

    ScanResult result = client.scan(scanRequest);

    List<Map<String, AttributeValue>> results = new ArrayList<>();
    results.addAll(result.getItems());

    while (result.getLastEvaluatedKey() != null) {
        scanRequest = scanRequest.withExclusiveStartKey(result.getLastEvaluatedKey());

        result = client.scan(scanRequest);

        results.addAll(result.getItems());
    }

    Stream<Entry> typedResult = results.stream().map(this::fromMap);

    if (filter.reverse) {
        typedResult = Lists.reverse(typedResult.collect(Collectors.toCollection(LinkedList::new))).stream();
    }

    return typedResult;
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:40,代码来源:GenericDynamoDB.java

示例2: run

import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
@Override
public void run() {
    Map<String, AttributeValue> exclusiveStartKey = null;
    ScanRequest scanRequest = new ScanRequest().withTableName(tableName).withAttributesToGet(attributesToGet)
            .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withTotalSegments(numOfSegments).withSegment(segmentNum);
    boolean scanNumLimitReached = false;
    while (!scanNumLimitReached) {
        scanRequest.withExclusiveStartKey(exclusiveStartKey);
        ScanResult scanResult = dynamoDBClient.scan(scanRequest);
        if(!isRunningOnDDBLocal) {
            // DDB Local does not support rate limiting
            tableReadRateLimiter.adjustRateWithConsumedCapacity(scanResult.getConsumedCapacity());
        }

        for (Map<String, AttributeValue> item : scanResult.getItems()) {
            checkItemViolationAndAddDeleteRequest(item);
            itemsScanned.addAndGet(1);
            itemScannedByThread += 1;
            scanNumLimitReached = isScanNumberLimitReached();
            if(scanNumLimitReached) {
                break;
            }
        }

        if (deleteViolationAfterFound) {
            sendDeleteViolations();
        }
        PrintHelper.printScanProgress(itemsScanned.get(), itemScannedByThread, violationFoundByThread, violationDeleteByThread);

        if (null == (exclusiveStartKey = scanResult.getLastEvaluatedKey())) {
            break;
        }
    }
    return;
}
 
开发者ID:awslabs,项目名称:dynamodb-online-index-violation-detector,代码行数:36,代码来源:TableReader.java

示例3: readPageFromTable

import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
/**
 * Reads a page from a standard DynamoDB table.
 * @param <P> type of object
 * @param appid the app identifier (name)
 * @param p a {@link Pager}
 * @return the last row key of the page, or null.
 */
public static <P extends ParaObject> List<P> readPageFromTable(String appid, Pager p) {
	Pager pager = (p != null) ? p : new Pager();
	ScanRequest scanRequest = new ScanRequest().
			withTableName(getTableNameForAppid(appid)).
			withLimit(pager.getLimit()).
			withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);

	if (!StringUtils.isBlank(pager.getLastKey())) {
		scanRequest = scanRequest.withExclusiveStartKey(Collections.
				singletonMap(Config._KEY, new AttributeValue(pager.getLastKey())));
	}

	ScanResult result = getClient().scan(scanRequest);
	LinkedList<P> results = new LinkedList<>();
	for (Map<String, AttributeValue> item : result.getItems()) {
		P obj = fromRow(item);
		if (obj != null) {
			results.add(obj);
		}
	}

	if (result.getLastEvaluatedKey() != null) {
		pager.setLastKey(result.getLastEvaluatedKey().get(Config._KEY).getS());
	} else if (!results.isEmpty()) {
		// set last key to be equal to the last result - end reached.
		pager.setLastKey(results.peekLast().getId());
	}
	return results;
}
 
开发者ID:Erudika,项目名称:para,代码行数:37,代码来源:AWSDynamoUtils.java

示例4: all

import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
private Stream<Entry> all() {
    ScanRequest scanRequest = new ScanRequest();
    scanRequest.withConsistentRead(true);
    scanRequest.withTableName(tableName);

    ScanResult result = client.scan(scanRequest);

    List<Map<String, AttributeValue>> results = new ArrayList<>();
    results.addAll(result.getItems());

    while (result.getLastEvaluatedKey() != null) {
        scanRequest = scanRequest.withExclusiveStartKey(result.getLastEvaluatedKey());

        result = client.scan(scanRequest);

        results.addAll(result.getItems());
    }


    return results.stream().map(this::fromMap);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:22,代码来源:GenericDynamoDB.java

示例5: getPagedItems

import com.amazonaws.services.dynamodbv2.model.ScanRequest; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
@SuppressWarnings("unchecked")
@Override
public PagedDatabaseResult getPagedItems(String tableName, Object nextToken, String minRange,
        String maxRange, String instanceId, String jobId) {
    List<Item> ret = new ArrayList<Item>();
    Map<String, AttributeValue> lastKeyEvaluated = (Map<String, AttributeValue>) nextToken;
    ScanRequest scanRequest = new ScanRequest().withTableName(tableName);
    Map<String, Condition> conditions = new HashMap<String, Condition>();
    if (jobId != null) {
        Condition jobIdCondition = new Condition();
        jobIdCondition.withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(new AttributeValue().withS(jobId));

        conditions.put(DatabaseKeys.JOB_ID_KEY.getShortKey(), jobIdCondition);
    }
    if (StringUtils.isNotBlank(instanceId)) {
        // add a filter
        Condition filter = new Condition();
        filter.withComparisonOperator(ComparisonOperator.EQ).withAttributeValueList(
                new AttributeValue().withS(instanceId));
        scanRequest.addScanFilterEntry(DatabaseKeys.INSTANCE_ID_KEY.getShortKey(), filter);
    }
    Condition rangeKeyCondition = new Condition();
    if (minRange != null && maxRange != null) {
        rangeKeyCondition.withComparisonOperator(ComparisonOperator.BETWEEN.toString())
                .withAttributeValueList(new AttributeValue().withS(minRange))
                .withAttributeValueList(new AttributeValue().withS(maxRange));

    } else if (minRange != null) {
        rangeKeyCondition.withComparisonOperator(ComparisonOperator.GE.toString())
                .withAttributeValueList(new AttributeValue().withS(minRange));
    } else if (maxRange != null) {
        rangeKeyCondition.withComparisonOperator(ComparisonOperator.LT.toString())
                .withAttributeValueList(new AttributeValue().withS(maxRange));
    } else {
        rangeKeyCondition = null;
    }
    if (rangeKeyCondition != null) {
        conditions.put(DatabaseKeys.REQUEST_NAME_KEY.getShortKey(), rangeKeyCondition);
    }
    scanRequest.withScanFilter(conditions);
    scanRequest.withExclusiveStartKey(lastKeyEvaluated);

    ScanResult result = dynamoDb.scan(scanRequest);
    for (Map<String, AttributeValue> item : result.getItems()) {
        ret.add(getItemFromResult(item));
    }
    return new PagedDatabaseResult(ret, result.getLastEvaluatedKey());
}
 
开发者ID:intuit,项目名称:Tank,代码行数:53,代码来源:AmazonDynamoDatabaseDocApi.java


注:本文中的com.amazonaws.services.dynamodbv2.model.ScanRequest.withExclusiveStartKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。