Package com.amazonaws.services.dynamodbv2.model

Examples of com.amazonaws.services.dynamodbv2.model.WriteRequest


                final List<WriteRequest> writeRequests =
                    new ArrayList<WriteRequest>(numPut + numDel);
                // Put requests for a single table
                if (itemsToPut != null) {
                    for (Item item: itemsToPut) {
                        writeRequests.add(new WriteRequest()
                            .withPutRequest(new PutRequest()
                                .withItem(toAttributeValues(item))));
                    }
                }
                // Delete requests for a single table
                if (pksToDelete != null) {
                    for (PrimaryKey pkToDelete: pksToDelete) {
                        writeRequests.add(new WriteRequest()
                            .withDeleteRequest(new DeleteRequest()
                                .withKey(toAttributeValueMap(pkToDelete))));
                    }
                }
                requestItems.put(tableWriteItems.getTableName(), writeRequests);
View Full Code Here


    }

    List<WriteRequest> reqs = new ArrayList<WriteRequest>();
    for (ParaObject object : objects) {
      if (object != null) {
        reqs.add(new WriteRequest().withDeleteRequest(new DeleteRequest().
            withKey(Collections.singletonMap(Config._KEY, new AttributeValue(object.getId())))));
      }
    }
    batchWrite(Collections.singletonMap(appid, reqs));
    logger.debug("DAO.deleteAll() {}", objects.size());
View Full Code Here

          object.setUpdated(Utils.timestamp());
        }
        object.setAppid(appid);
        Map<String, AttributeValue> row = toRow(object, null);
        setRowKey(object.getId(), row);
        reqs.add(new WriteRequest().withPutRequest(new PutRequest().withItem(row)));
        j++;
      }
      batchWrite(Collections.singletonMap(appid, reqs));
      reqs.clear();
      j = 0;
View Full Code Here

            AttributeTransformer.Parameters<?> parameters =
                toParameters(attributeValues, clazz, config);

            requestItems.get(tableName).add(
                new WriteRequest().withPutRequest(
                    new PutRequest().withItem(
                        transformAttributes(parameters))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

      AttributeValue geohashValue = new AttributeValue().withN(Long.toString(geohash));
      putRequest.getItem().put(config.getGeohashAttributeName(), geohashValue);
      AttributeValue geoJsonValue = new AttributeValue().withS(geoJson);
      putRequest.getItem().put(config.getGeoJsonAttributeName(), geoJsonValue);     
     
      WriteRequest writeRequest = new WriteRequest(putRequest);
      writeRequests.add(writeRequest);
    }
    Map<String, List<WriteRequest>> requestItems = new HashMap<String, List<WriteRequest>>();
    requestItems.put(config.getTableName(), writeRequests);
    batchItemRequest.setRequestItems(requestItems);
View Full Code Here

          object.setTimestamp(Utils.timestamp());
        }
        object.setAppid(appid);
        Map<String, AttributeValue> row = toRow(object, null);
        setRowKey(object.getId(), row);
        reqs.add(new WriteRequest().withPutRequest(new PutRequest().withItem(row)));
        j++;
      }
      batchWrite(Collections.singletonMap(appid, reqs));
      reqs.clear();
      j = 0;
View Full Code Here

    }

    List<WriteRequest> reqs = new ArrayList<WriteRequest>();
    for (ParaObject object : objects) {
      if (object != null) {
        reqs.add(new WriteRequest().withDeleteRequest(new DeleteRequest().
            withKey(Collections.singletonMap(Config._KEY, new AttributeValue(object.getId())))));
      }
    }
    batchWrite(Collections.singletonMap(appid, reqs));
    logger.debug("DAO.deleteAll() {}", objects.size());
View Full Code Here

            AttributeTransformer.Parameters<?> parameters =
                toParameters(attributeValues, clazz, tableName, config);

            requestItems.get(tableName).add(
                new WriteRequest().withPutRequest(
                    new PutRequest().withItem(
                        transformAttributes(parameters))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, toDelete, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {

            HashMap<String, List<WriteRequest>> batch =
                    new HashMap<String, List<WriteRequest>>();

            int i = 0;

            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < MAX_ITEMS_PER_BATCH ) {

                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();

                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();

                while ( writeRequestIter.hasNext() && i++ < MAX_ITEMS_PER_BATCH ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }
           
            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.WriteRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.