List of usage examples for com.amazonaws.services.dynamodbv2.document Item attributes
Map attributes
To view the source code for com.amazonaws.services.dynamodbv2.document Item attributes.
Click Source Link
From source file:com.github.sdmcraft.slingdynamo.impl.DynamoDBResourceProvider.java
License:Open Source License
/** * Gets the children./*from w w w . ja v a 2 s . c om*/ * * @param dbtable the dbtable * @param parent the parent * @param childIds the child ids * @param path the path * @param resolver the resolver * @return the children */ private List<Resource> getChildren(Table dbtable, int parent, Object[] childIds, String path, ResourceResolver resolver) { ScanFilter idFilter = new ScanFilter("parent").in(parent); ScanFilter childIdsFilter = new ScanFilter("child_id").in(childIds); ItemCollection<ScanOutcome> items = dbtable.scan(idFilter, childIdsFilter); Iterator<Item> itemItr = items.iterator(); List<Resource> children = new ArrayList<Resource>(); while (itemItr.hasNext()) { Item item = itemItr.next(); Iterable<Entry<String, Object>> attributes = item.attributes(); Iterator<Entry<String, Object>> attributesItr = attributes.iterator(); Map<String, Object> resourceProps = new HashMap<String, Object>(); while (attributesItr.hasNext()) { Entry<String, Object> attribute = attributesItr.next(); resourceProps.put(attribute.getKey(), attribute.getValue()); } ModifiableValueMapDecorator valueMap = new ModifiableValueMapDecorator(resourceProps); ResourceMetadata resourceMetadata = new ResourceMetadata(); resourceMetadata.setResolutionPath(path + '/' + resourceProps.get("child_id")); resourceMetadata.put("table", dbtable.getTableName()); children.add(new DynamoDBResource(resolver, resourceMetadata, valueMap, resourceType)); } return children; }
From source file:com.github.sdmcraft.slingdynamo.impl.DynamoDBResourceProvider.java
License:Open Source License
/** * Item to map./*w w w. ja v a2 s . com*/ * * @param item the item * @return the map */ private Map<String, Object> itemToMap(Item item) { Map<String, Object> resourceProps = new HashMap<String, Object>(); Iterable<Entry<String, Object>> attributes = item.attributes(); Iterator<Entry<String, Object>> attributesItr = attributes.iterator(); while (attributesItr.hasNext()) { Entry<String, Object> attribute = attributesItr.next(); resourceProps.put(attribute.getKey(), attribute.getValue()); } return resourceProps; }
From source file:io.fineo.drill.exec.store.dynamo.physical.DynamoRecordReader.java
License:Apache License
@Override public int next() { Stopwatch watch = Stopwatch.createStarted(); topLevelState.reset();// w w w . j av a2 s . com int count = 0; Page<Item, ?> page; while (resultIter.hasNext()) { page = resultIter.next(); for (Item item : page) { int rowCount = count++; for (Map.Entry<String, Object> attribute : item.attributes()) { String name = attribute.getKey(); Object value = attribute.getValue(); SchemaPath column = getSchemaPath(name); topLevelState.setColumn(column); handleTopField(rowCount, name, value, topLevelState); } } } topLevelState.setRowCount(count); LOG.debug("Took {} ms to get {} records", watch.elapsed(TimeUnit.MILLISECONDS), count); return count; }
From source file:jp.classmethod.aws.dynamodb.DynamoDbInternalUtils.java
License:Open Source License
/** * Copied from DynamoDB Document SDK InternalUtils.java * * Converts an <code>Item</code> into the low-level representation; * or null if the input is null./*www . j a v a2s .c o m*/ */ public static Map<String, AttributeValue> toAttributeValues(Item item) { if (item == null) { return null; } // row with multiple attributes Map<String, AttributeValue> result = new LinkedHashMap<String, AttributeValue>(); for (Map.Entry<String, Object> entry : item.attributes()) { result.put(entry.getKey(), toAttributeValue(entry.getValue())); } return result; }