List of usage examples for com.amazonaws.services.simpledb.model DeletableItem DeletableItem
public DeletableItem(String name, java.util.List<Attribute> attributes)
From source file:org.teiid.resource.adapter.simpledb.SimpleDBConnectionImpl.java
License:Open Source License
/** * Removes item with given ItemName from domain * @param domainName//from ww w . j av a2s . com * @param itemName */ @Override public int performDelete(String domainName, String selectExpression) throws TranslatorException { try { List<DeletableItem> deleteItems = new ArrayList<DeletableItem>(); int count = 0; String nextToken = null; do { SelectResult result = performSelect(selectExpression, nextToken); nextToken = result.getNextToken(); Iterator<Item> iter = result.getItems().iterator(); while (iter.hasNext()) { Item item = iter.next(); deleteItems.add(new DeletableItem(item.getName(), null)); count++; if (count % 25 == 0) { BatchDeleteAttributesRequest request = new BatchDeleteAttributesRequest(domainName, deleteItems); this.client.batchDeleteAttributes(request); deleteItems.clear(); } } // http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API_BatchDeleteAttributes.html // 25 limit we may need to batch; but if batch atomicity is gone if (!deleteItems.isEmpty()) { BatchDeleteAttributesRequest request = new BatchDeleteAttributesRequest(domainName, deleteItems); this.client.batchDeleteAttributes(request); } } while (nextToken != null); return count; } catch (AmazonServiceException e) { throw new TranslatorException(e); } catch (AmazonClientException e) { throw new TranslatorException(e); } }