use of com.spaceprogram.simplejpa.ItemAndAttributes in project simplejpa by appoxy.
the class ConcurrentRetriever method getSerially.
private static List<ItemAndAttributes> getSerially(List<SdbItem> items) throws AmazonClientException {
List<ItemAndAttributes> ret = new ArrayList<ItemAndAttributes>();
for (SdbItem item : items) {
// logger.fine("item=" + item.getIdentifier());
List<Attribute> atts = item.getAttributes();
ret.add(new ItemAndAttributes(item, atts));
}
return ret;
}
use of com.spaceprogram.simplejpa.ItemAndAttributes in project simplejpa by appoxy.
the class ConcurrentRetriever method getParallel.
private static List<ItemAndAttributes> getParallel(List<SdbItem> items, Executor executor, EntityManagerSimpleJPA em) throws InterruptedException, ExecutionException {
CompletionService<ItemAndAttributes> ecs = new ExecutorCompletionService<ItemAndAttributes>(executor);
for (SdbItem item : items) {
Callable callable = new GetAttributes(item, em);
ecs.submit(callable);
}
List<ItemAndAttributes> ret = new ArrayList<ItemAndAttributes>();
int n = items.size();
for (int i = 0; i < n; ++i) {
ItemAndAttributes r = ecs.take().get();
if (r != null) {
ret.add(r);
}
}
return ret;
}
Aggregations