@Override public <T, ID> void delete(Class<T> entityClass, Iterable<? extends ID> ids) { if (ids.iterator().hasNext()) { String domainName = getDomainName(entityClass); List<DeletableItem> deleteList = new ArrayList<DeletableItem>(); for (ID id : ids) { deleteList.add(new DeletableItem().withName((String) id)); } // max allowed batch size is 25 List<DeletableItem> batch = new ArrayList<DeletableItem>(MAX_BATCH_SIZE); for (int i = 0; i < deleteList.size(); i += MAX_BATCH_SIZE) { int batchIndex = ((i + MAX_BATCH_SIZE) < deleteList.size()) ? (i + MAX_BATCH_SIZE) : deleteList.size(); for (int j = i; j < batchIndex; j++) { batch.add(deleteList.get(j)); } LOGGER.debug(String.format("Batch size: %d", batch.size())); getDB().batchDeleteAttributes(new BatchDeleteAttributesRequest( domainName, batch)); batch.clear(); } } }
public void execute() { BatchDeleteAttributesRequest request = new BatchDeleteAttributesRequest() .withDomainName(determineDomainName()) .withItems(determineDeletableItems()); log.trace("Sending request [{}] for exchange [{}]...", request, exchange); this.sdbClient.batchDeleteAttributes(request); log.trace("Request sent"); }
@Override public BatchDeleteAttributesResult batchDeleteAttributes(BatchDeleteAttributesRequest batchDeleteAttributesRequest) throws AmazonServiceException, AmazonClientException { this.batchDeleteAttributesRequest = batchDeleteAttributesRequest; return new BatchDeleteAttributesResult(); }