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


Java ScanRequest.setAttributesToGet方法代码示例

本文整理汇总了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;
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:31,代码来源:DynamoDBService.java

示例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;
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:33,代码来源:DynamoDBService2.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:DynamoDbDataContext.java


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