use of com.amazonaws.services.simpledb.model.BatchDeleteAttributesRequest in project siena by mandubian.
the class SdbPersistenceManager method deleteByKeys.
@Override
public <T> int deleteByKeys(Class<T> clazz, Iterable<?> keys) {
List<DeletableItem> doList = new ArrayList<DeletableItem>();
int nb = 0;
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
for (Object key : keys) {
doList.add(SdbMappingUtils.createDeletableItemFromKey(clazz, key));
nb++;
}
try {
checkDomain(domain);
int len = doList.size() > MAX_ITEMS_PER_CALL ? MAX_ITEMS_PER_CALL : doList.size();
for (int i = 0; i < doList.size(); i += len) {
int sz = i + len;
if (sz > doList.size()) {
sz = doList.size();
}
sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(domain, doList.subList(i, sz)));
}
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
return nb;
}
use of com.amazonaws.services.simpledb.model.BatchDeleteAttributesRequest in project camel by apache.
the class BatchDeleteAttributesCommand method execute.
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");
}
use of com.amazonaws.services.simpledb.model.BatchDeleteAttributesRequest in project siena by mandubian.
the class SdbPersistenceManager method delete.
@Override
public int delete(Iterable<?> models) {
Map<String, List<DeletableItem>> doMap = new HashMap<String, List<DeletableItem>>();
int nb = 0;
for (Object obj : models) {
Class<?> clazz = obj.getClass();
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
List<DeletableItem> doList = doMap.get(domain);
if (doList == null) {
doList = new ArrayList<DeletableItem>();
doMap.put(domain, doList);
}
doList.add(SdbMappingUtils.createDeletableItem(obj));
nb++;
}
try {
for (String domain : doMap.keySet()) {
checkDomain(domain);
List<DeletableItem> doList = doMap.get(domain);
int len = doList.size() > MAX_ITEMS_PER_CALL ? MAX_ITEMS_PER_CALL : doList.size();
for (int i = 0; i < doList.size(); i += len) {
int sz = i + len;
if (sz > doList.size()) {
sz = doList.size();
}
sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(domain, doList.subList(i, sz)));
}
}
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
return nb;
}
Aggregations