List of usage examples for com.amazonaws.services.simpledb.model BatchPutAttributesRequest BatchPutAttributesRequest
public BatchPutAttributesRequest(String domainName, java.util.List<ReplaceableItem> items)
From source file:org.teiid.resource.adapter.simpledb.SimpleDBConnectionImpl.java
License:Open Source License
private void executeBatch(String domainName, List<ReplaceableItem> insertItems) { if (!insertItems.isEmpty()) { BatchPutAttributesRequest request = new BatchPutAttributesRequest(domainName, insertItems); this.client.batchPutAttributes(request); }/*from w w w. j a v a 2 s.c o m*/ }
From source file:org.teiid.resource.adpter.simpledb.SimpleDbAPIClass.java
License:Open Source License
/** * Performs update on given domain and items * @param domainName/*from w w w .j a v a 2 s . c om*/ * @param items */ public void performUpdate(String domainName, Map<String, Map<String, String>> items) { List<ReplaceableItem> itemsList = new ArrayList<ReplaceableItem>(); for (Map.Entry<String, Map<String, String>> item : items.entrySet()) { ReplaceableItem it = new ReplaceableItem(item.getKey()); List<ReplaceableAttribute> attributesList = new ArrayList<ReplaceableAttribute>(); for (Map.Entry<String, String> attribute : item.getValue().entrySet()) { attributesList.add(new ReplaceableAttribute(attribute.getKey(), attribute.getValue(), true)); } it.setAttributes(attributesList); itemsList.add(it); } BatchPutAttributesRequest req = new BatchPutAttributesRequest(domainName, itemsList); client.batchPutAttributes(req); }
From source file:siena.sdb.SdbPersistenceManager.java
License:Apache License
@Override public int insert(Iterable<?> objects) { Map<String, List<ReplaceableItem>> doMap = new HashMap<String, List<ReplaceableItem>>(); int nb = 0;/*from w w w . j a v a 2 s. c o m*/ for (Object obj : objects) { Class<?> clazz = obj.getClass(); String domain = SdbMappingUtils.getDomainName(clazz, prefix); List<ReplaceableItem> doList = doMap.get(domain); if (doList == null) { doList = new ArrayList<ReplaceableItem>(); doMap.put(domain, doList); } doList.add(SdbMappingUtils.createItem(obj)); nb++; } try { for (String domain : doMap.keySet()) { checkDomain(domain); List<ReplaceableItem> 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.batchPutAttributes(new BatchPutAttributesRequest(domain, doList.subList(i, sz))); } } } catch (AmazonClientException ex) { throw new SienaException(ex); } return nb; }
From source file:siena.sdb.SdbPersistenceManager.java
License:Apache License
public <T> int update(Iterable<T> models) { Map<String, List<ReplaceableItem>> doMap = new HashMap<String, List<ReplaceableItem>>(); int nb = 0;//w ww . ja va2s . c om for (Object obj : models) { Class<?> clazz = obj.getClass(); String domain = SdbMappingUtils.getDomainName(clazz, prefix); List<ReplaceableItem> doList = doMap.get(domain); if (doList == null) { doList = new ArrayList<ReplaceableItem>(); doMap.put(domain, doList); } doList.add(SdbMappingUtils.createItem(obj)); nb++; } try { for (String domain : doMap.keySet()) { checkDomain(domain); List<ReplaceableItem> 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.batchPutAttributes(new BatchPutAttributesRequest(domain, doList.subList(i, sz))); } } } catch (AmazonClientException ex) { throw new SienaException(ex); } return nb; }
From source file:wwutil.jsoda.SimpleDBService.java
License:Mozilla Public License
public <T> void putObjs(Class<T> modelClass, List<T> dataObjs) throws Exception { String modelName = jsoda.getModelName(modelClass); int offset = 0; String table = jsoda.getModelTable(modelName); while (offset < dataObjs.size()) { List<ReplaceableItem> items = buildPutItems(dataObjs, modelName, offset); offset += items.size();/*w w w. j av a2 s . com*/ sdbClient.batchPutAttributes(new BatchPutAttributesRequest(table, items)); } }