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


Java ScanResult.getItems方法代码示例

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


在下文中一共展示了ScanResult.getItems方法的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);

    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-encryption-java,代码行数:26,代码来源:TransformerHolisticTests.java

示例2: 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);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:17,代码来源:ScanRecordReadRequest.java

示例3: 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

示例4: 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

示例5: 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;
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:36,代码来源:DynamoUtils.java

示例6: 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;
}
 
开发者ID:awslabs,项目名称:amazon-kinesis-aggregators,代码行数:30,代码来源:DynamoDataStore.java

示例7: 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);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:20,代码来源:LowLevelScan.java

示例8: handleRequest

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的package包/类
@Override
public String handleRequest(Book request, Context context) {
	ScanRequest scanRequest = new ScanRequest().withTableName("Books");
	ScanResult result = DynamoDBUtil.getClient().scan(scanRequest);
    System.out.println("-- books listing start --");
	for (Map<String, AttributeValue> item : result.getItems()){
	    System.out.println(item);
	}
    System.out.println("-- books listing end --");
    return result.getItems().toString();
}
 
开发者ID:arun-gupta,项目名称:serverless,代码行数:12,代码来源:BookGetAll.java

示例9: call

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的package包/类
@Override
public Void call() {
    final ScanResult scanResult = result.getScanResult();
    final List<Map<String, AttributeValue>> items = scanResult.getItems();
    final Iterator<Map<String, AttributeValue>> it = items.iterator();
    boolean interrupted = false;
    try {
        do {
            try {
                Map<String, AttributeValue> item = it.next();
                DynamoDBEntryWithSize entryWithSize = new DynamoDBEntryWithSize(
                        item,
                        ItemSizeCalculator.calculateItemSizeInBytes(item));
                queue.put(entryWithSize);
            } catch (InterruptedException e) {
                interrupted = true;
                LOGGER.warn("interrupted when writing item to queue: "
                        + e.getMessage());
            }
        } while (it.hasNext());
    } finally {
        if (interrupted) {
            Thread.currentThread().interrupt();
        }
    }
    return null;
}
 
开发者ID:awslabs,项目名称:dynamodb-import-export-tool,代码行数:28,代码来源:BlockingQueueWorker.java

示例10: run

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的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

示例11: getItem

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的package包/类
@Override
  public List<Map<String, AttributeValue>> getItem(String tableName, Map<String, Condition> conditions) {
      ScanRequest scanRequest = new ScanRequest(tableName).withScanFilter(conditions);
      ScanResult scanResult = dynamoDBClient.scan(scanRequest);
      int count = scanResult.getCount();
      if (count == 0) {
      	return Collections.emptyList();
      }
      
LOG.info("Successful by getting items from " + tableName
		+ " based on conditions: " + conditions.toString() + ": " + count + " items");
      return scanResult.getItems();
  }
 
开发者ID:dgks0n,项目名称:milton-aws,代码行数:14,代码来源:DynamoDBServiceImpl.java

示例12: scanTable

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的package包/类
/**
 * Returns the the result of the scanned table with the applied filters. The
 * filters are connected via the conditionalOperator. It can either be AND
 * or OR.
 * 
 * @param tableName
 *            The table to be scanned.
 * @param filters
 *            A list with Filter objects.
 * @param conditionalOperator
 *            AND | OR - Conditional clauses in DynamoDb can either have AND
 *            or OR connectors, no mix.
 * @return
 */
public static List<Row> scanTable(String tableName, Filter[] filters,
		String conditionalOperator) {
	Map<String, Condition> scanFilter = new HashMap<>();

	for (Filter filter : filters) {
		scanFilter.put(
				filter.getAttribute().getName(),
				new Condition().withComparisonOperator(
						filter.getComparisonOperator())
						.withAttributeValueList(
								new AttributeValue().withS(filter
										.getAttribute().getValue())));
	}

	ScanResult scanResult;

	if (filters.length == 1) {
		scanResult = DynamoDbHandler.CLIENT.scan(new ScanRequest(tableName)
				.withScanFilter(scanFilter));
	} else {
		scanResult = DynamoDbHandler.CLIENT.scan(new ScanRequest(tableName)
				.withConditionalOperator(conditionalOperator)
				.withScanFilter(scanFilter));
	}

	ArrayList<Row> items = new ArrayList<>();
	List<Attribute> attributes = null;
	for (Map<String, AttributeValue> result : scanResult.getItems()) {
		attributes = new ArrayList<>();
		for (String key : result.keySet()) {
			attributes.add(new Attribute(key, result.get(key).getS()));
		}
		items.add(new Row(attributes));
	}

	return items;
}
 
开发者ID:raethlein,项目名称:ColumnStoreUnifier,代码行数:52,代码来源:DynamoDbQueryHandler.java

示例13: readPageFromTable

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的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

示例14: getRows

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的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

示例15: getRows

import com.amazonaws.services.dynamodbv2.model.ScanResult; //导入方法依赖的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


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