当前位置: 首页>>代码示例>>Java>>正文


Java SelectResult.getNextToken方法代码示例

本文整理汇总了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());
}
 
开发者ID:intuit,项目名称:Tank,代码行数:27,代码来源:AmazonSimpleDatabase.java

示例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);
}
 
开发者ID:signal,项目名称:agathon,代码行数:20,代码来源:SdbCassandraInstanceDao.java

示例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;		
}
 
开发者ID:webpagebytes,项目名称:aws-cms-plugins,代码行数:29,代码来源:WPBAwsSdbAdminDataStorage.java

示例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;
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:43,代码来源:OptimisticPersister.java

示例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();        
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:6,代码来源:SimpleDBQueryExecution.java

示例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);
}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:55,代码来源:Master.java

示例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;
}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:49,代码来源:Master.java

示例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();
}
 
开发者ID:3pillarlabs,项目名称:spring-data-simpledb,代码行数:10,代码来源:SimpleDbTemplate.java


注:本文中的com.amazonaws.services.simpledb.model.SelectResult.getNextToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。