List of usage examples for com.amazonaws.services.dynamodbv2.model BatchGetItemRequest BatchGetItemRequest
public BatchGetItemRequest(java.util.Map<String, KeysAndAttributes> requestItems)
From source file:com.dell.doradus.db.s3.DynamoDBService2.java
License:Apache License
@Override public List<DColumn> getColumns(String storeName, String rowKey, Collection<String> columnNames) { Timer t = new Timer(); String namespace = getTenant().getName(); String key = storeName + "_" + rowKey; List<DColumn> list = new ArrayList<>(); List<Map<String, AttributeValue>> keys = new ArrayList<>(); for (String col : columnNames) { keys.add(getPrimaryKey(key, col)); if (keys.size() >= 100) { KeysAndAttributes x = new KeysAndAttributes().withKeys(keys); Map<String, KeysAndAttributes> map = new HashMap<>(); map.put(namespace, x);/*from www. j a va2s . c o m*/ BatchGetItemResult result = m_client.batchGetItem(new BatchGetItemRequest(map)); if (result.getUnprocessedKeys().size() > 0) throw new RuntimeException("Could not process all items"); list.addAll(fromItems(result.getResponses().get(namespace))); keys.clear(); } } if (keys.size() > 0) { KeysAndAttributes x = new KeysAndAttributes().withKeys(keys); Map<String, KeysAndAttributes> map = new HashMap<>(); map.put(namespace, x); BatchGetItemResult result = m_client.batchGetItem(new BatchGetItemRequest(map)); if (result.getUnprocessedKeys().size() > 0) throw new RuntimeException("Could not process all items"); list.addAll(fromItems(result.getResponses().get(namespace))); keys.clear(); } m_logger.debug("get columns for {} in {}", namespace, t); return list; }