本文整理汇总了Java中com.amazonaws.services.simpledb.model.SelectResult.getNextToken方法的典型用法代码示例。如果您正苦于以下问题:Java SelectResult.getNextToken方法的具体用法?Java SelectResult.getNextToken怎么用?Java SelectResult.getNextToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.simpledb.model.SelectResult
的用法示例。
在下文中一共展示了SelectResult.getNextToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPagedItems
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public PagedDatabaseResult getPagedItems(String tableName, Object token, String minRange, String maxRange, String instanceId, String jobId) {
List<Item> ret = new ArrayList<Item>();
String whereClause = null;
if (minRange != null && maxRange != null) {
whereClause = " Timestamp between '" + minRange + "' and '" + maxRange + "' ";
} else if (minRange != null) {
whereClause = " Timestamp >= '" + minRange + "' ";
} else if (maxRange != null) {
whereClause = " Timestamp < '" + maxRange + "' ";
} else {
whereClause = "";
}
SelectRequest request = new SelectRequest("SELECT * from `" + tableName + "`" + whereClause).withConsistentRead(true);
String nextToken = (String) token;
request.withNextToken(nextToken);
SelectResult result = db.select(request);
for (com.amazonaws.services.simpledb.model.Item item : result.getItems()) {
ret.add(resultToItem(item));
}
nextToken = result.getNextToken();
return new PagedDatabaseResult(ret, result.getNextToken());
}
示例2: findAll
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
@Override
public ImmutableSet<CassandraInstance> findAll(String ring) {
List<CassandraInstance> instances = Lists.newArrayList();
String nextToken = null;
do {
SelectRequest request = new SelectRequest(String.format(ALL_QUERY, domain(ring)))
.withNextToken(nextToken);
SelectResult result = client.select(request);
for (Item item : result.getItems()) {
instances.add(transform(item));
}
nextToken = result.getNextToken();
} while (nextToken != null);
return ImmutableSet.copyOf(instances);
}
示例3: internalQuery
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
private<T> List<T> internalQuery(Class<T> dataClass, SelectRequest selectRequest) throws WPBIOException
{
List<T> result = new ArrayList<T>();
try
{
SelectResult selectResult = null;
do
{
if (selectResult != null)
{
selectRequest.setNextToken(selectResult.getNextToken());
}
selectResult = sdbClient.select(selectRequest);
List<Item> items = selectResult.getItems();
for(Item item: items)
{
T t = copyAttributesToInstance(dataClass, item.getAttributes());
result.add(t);
}
} while (selectResult.getNextToken() != null);
} catch (Exception e)
{
throw new WPBIOException("cannot get all records " + dataClass.getSimpleName(), e);
}
return result;
}
示例4: getAllItems
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
@Override
public List<ImmutablePair<String, List<Attribute>>> getAllItems() {
if (!initialised) {
throw new IllegalStateException("The optimistic persister has not been initialised");
}
// 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;
}
示例5: executeDirect
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
protected void executeDirect(String sql, String next) throws TranslatorException {
SelectResult result = connection.performSelect(sql, next);
this.nextToken = result.getNextToken();
this.listIterator = result.getItems().iterator();
}
示例6: domainToCSV
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
private void domainToCSV(String domainPrefix, File csvFile) {
log.info("Storing data from SDB domains starting with " + domainPrefix
+ " to file " + csvFile);
Set<String> attributes = null;
List<String> domains = getDbClient().listDomains().getDomainNames();
int c = 0;
for (String domainName : domains) {
if (domainName.startsWith(domainPrefix)) {
c++;
log.info("Exporting from " + domainName + " (" + c + "/"
+ domains.size() + ")");
long domainCount = getDbClient().domainMetadata(
new DomainMetadataRequest(domainName)).getItemCount();
if (domainCount < MIN_RESULTS) {
log.info("Ignoring " + domainName + ", less than "
+ MIN_RESULTS + " entries.");
continue;
}
if (attributes == null) {
attributes = getSdbAttributes(getDbClient(), domainName,
MIN_RESULTS);
}
long total = 0;
String select = "select * from `" + domainName + "` limit 2500";
String nextToken = null;
SelectResult res;
do {
res = getDbClient().select(
new SelectRequest(select).withNextToken(nextToken)
.withConsistentRead(false));
for (Item i : res.getItems()) {
Map<String, Object> csvEntry = new HashMap<String, Object>();
csvEntry.put("_key", i.getName());
for (String attr : attributes) {
csvEntry.put(attr, "");
}
for (Attribute a : i.getAttributes()) {
csvEntry.put(a.getName(), a.getValue());
}
CSVExport.writeToFile(csvEntry, csvFile);
}
nextToken = res.getNextToken();
total += res.getItems().size();
log.info("Exported " + total + " of " + domainCount);
} while (nextToken != null);
log.info("Finished exporting from " + domainName);
}
}
CSVExport.closeWriter(csvFile);
}
示例7: getSdbAttributes
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
private static Set<String> getSdbAttributes(AmazonSimpleDBClient client,
String domainName, int sampleSize) {
if (!client.listDomains().getDomainNames().contains(domainName)) {
throw new IllegalArgumentException("SimpleDB domain '" + domainName
+ "' not accessible from given client instance");
}
int domainCount = client.domainMetadata(
new DomainMetadataRequest(domainName)).getItemCount();
if (domainCount < sampleSize) {
throw new IllegalArgumentException("SimpleDB domain '" + domainName
+ "' does not have enough entries for accurate sampling.");
}
int avgSkipCount = domainCount / sampleSize;
int processedCount = 0;
String nextToken = null;
Set<String> attributeNames = new HashSet<String>();
Random r = new Random();
do {
int nextSkipCount = r.nextInt(avgSkipCount * 2) + 1;
SelectResult countResponse = client.select(new SelectRequest(
"select count(*) from `" + domainName + "` limit "
+ nextSkipCount).withNextToken(nextToken));
nextToken = countResponse.getNextToken();
processedCount += Integer.parseInt(countResponse.getItems().get(0)
.getAttributes().get(0).getValue());
SelectResult getResponse = client.select(new SelectRequest(
"select * from `" + domainName + "` limit 1")
.withNextToken(nextToken));
nextToken = getResponse.getNextToken();
processedCount++;
if (getResponse.getItems().size() > 0) {
for (Attribute a : getResponse.getItems().get(0)
.getAttributes()) {
attributeNames.add(a.getName());
}
}
} while (domainCount > processedCount);
return attributeNames;
}
示例8: getNextToken
import com.amazonaws.services.simpledb.model.SelectResult; //导入方法依赖的package包/类
private String getNextToken(String query, boolean consistentRead) {
LOGGER.debug("Get next token for query: " + query);
Assert.isTrue(query.contains("limit"), "Only queries with limit have a next token!");
final SelectResult selectResult = getDB().select(new SelectRequest(query, consistentRead));
return selectResult.getNextToken();
}