List of usage examples for com.amazonaws.services.simpledb.model SelectRequest SelectRequest
public SelectRequest()
From source file:com.zotoh.cloudapi.aws.SDB.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w w w. j a v a2 s.c om public Map<String, Set<KeyValuePair>> query(String query, boolean consistentRead) throws CloudException, InternalException { tstEStrArg("query-string", query); Map<String, Set<KeyValuePair>> rc = MP(); List<Item> lst; SelectRequest req; SelectResult res; String token = null; do { req = new SelectRequest().withSelectExpression(query).withConsistentRead(consistentRead); if (!isEmpty(token)) { req.setNextToken(token); } res = _svc.getCloud().getSDB().select(req); lst = res == null ? null : res.getItems(); if (lst != null) for (int i = 0; i < lst.size(); ++i) { final Item itm = lst.get(i); rc.put(itm.getName(), new HashSet<KeyValuePair>() { { addAll(toKPs(itm.getAttributes())); } }); } token = res.getNextToken(); } while (!isEmpty(token)); return Collections.unmodifiableMap(rc); }
From source file:org.apache.camel.component.aws.sdb.SelectCommand.java
License:Apache License
public void execute() { SelectRequest request = new SelectRequest().withSelectExpression(determineSelectExpression()) .withConsistentRead(determineConsistentRead()).withNextToken(determineNextToken()); log.trace("Sending request [{}] for exchange [{}]...", request, exchange); SelectResult result = this.sdbClient.select(request); log.trace("Received result [{}]", result); Message msg = getMessageForResponse(exchange); msg.setHeader(SdbConstants.ITEMS, result.getItems()); msg.setHeader(SdbConstants.NEXT_TOKEN, result.getNextToken()); }
From source file:squash.booking.lambdas.core.OptimisticPersister.java
License:Apache License
@Override public List<ImmutablePair<String, List<Attribute>>> getAllItems() { if (!initialised) { throw new IllegalStateException("The optimistic persister has not been initialised"); }/*from www. j a v a 2s .co m*/ // Query database to get items List<ImmutablePair<String, List<Attribute>>> items = new ArrayList<>(); AmazonSimpleDB client = getSimpleDBClient(); SelectRequest selectRequest = new SelectRequest(); // N.B. Think if results are paged, second and subsequent pages will always // be eventually-consistent only. This is currently used only to back up the // database - so being eventually-consistent is good enough - after all - // even if we were fully consistent, someone could still add a new booking // right after our call anyway. selectRequest.setConsistentRead(true); // Query all items in the domain selectRequest.setSelectExpression("select * from `" + simpleDbDomainName + "`"); String nextToken = null; do { SelectResult selectResult = client.select(selectRequest); selectResult.getItems().forEach(item -> { List<Attribute> attributes = new ArrayList<>(); item.getAttributes().stream() // Do not return the version attribute or inactive attributes .filter(attribute -> (!attribute.getName().equals(versionAttributeName) && !attribute.getValue().startsWith("Inactive"))) .forEach(attribute -> { attributes.add(attribute); }); items.add(new ImmutablePair<>(item.getName(), attributes)); }); nextToken = selectResult.getNextToken(); selectRequest.setNextToken(nextToken); } while (nextToken != null); return items; }