com.impetus.kundera.query.Query.iterate()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中com.impetus.kundera.query.Query.iterate方法的一些代码示例,展示了Query.iterate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.iterate方法的具体详情如下:
包路径:com.impetus.kundera.query.Query
类名称:Query
方法名:iterate

Query.iterate介绍

[英]Iterates over result.
[中]迭代结果。

代码示例

代码示例来源:origin: Impetus/Kundera

@Override
public Iterator<X> iterate()
{
  return ((com.impetus.kundera.query.Query)query).iterate();
}

代码示例来源:origin: Impetus/Kundera

/**
 * Assert book scrolling.
 * 
 * @param queryClause
 *            the query clause
 * @param expected
 *            the expected
 * @return the list
 */
private List<Book> assertBookScrolling(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause, Book.class);
  int count = 0;
  Iterator<Book> bookItr = query.iterate();
  List<Book> books = new ArrayList<Book>();
  while (bookItr.hasNext())
  {
    Book book = bookItr.next();
    Assert.assertNotNull(book);
    count++;
    books.add(book);
  }
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
  return books;
}

代码示例来源:origin: Impetus/Kundera

@Test
public void chunkScrollTest() throws Exception
{
  //without where clause
  int chunkSize = 50;
  Query query = (Query) em.createQuery("Select p from PersonHBase p", PersonHBase.class);
  query.setFetchSize(1000);
  Iterator<PersonHBase> iter = query.iterate();
  IResultIterator<PersonHBase> iIter = (IResultIterator<PersonHBase>) iter;
  assertScrolling(chunkSize, iIter);
  
  //with where clause
  String name = "vivek";
  query = (Query) em.createQuery("Select p from PersonHBase p where p.personName = '"+name+"'", PersonHBase.class);
  query.setFetchSize(1000);
  iter = query.iterate();
  iIter = (IResultIterator<PersonHBase>) iter;
  assertScrolling(chunkSize, iIter);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause, HbaseToken.class);
  int count = 0;
  Iterator<HbaseToken> tokens = query.iterate();
  while (tokens.hasNext())
  {
    HbaseToken token = tokens.next();
    Assert.assertNotNull(token);
    Assert.assertNotNull(token.getClient());
    Assert.assertEquals(2, token.getClient().getTokens().size());
    count++;
  }
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause, MongoToken.class);
  int count = 0;
  Iterator<MongoToken> tokens = query.iterate();
  while (tokens.hasNext())
  {
    MongoToken token = tokens.next();
    Assert.assertNotNull(token);
    Assert.assertNotNull(token.getClient());
    Assert.assertEquals(2, token.getClient().getTokens().size());
    count++;
  }
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause, CouchDBToken.class);
  int count = 0;
  Iterator<CouchDBToken> tokens = query.iterate();
  while (tokens.hasNext())
  {
    CouchDBToken token = tokens.next();
    Assert.assertNotNull(token);
    Assert.assertNotNull(token.getClient());
    Assert.assertEquals(2, token.getClient().getTokens().size());
    count++;
  }
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  Iterator<PrimeUser> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize != null && fetchSize == 0 ? 0:available);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int expectedCount)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonCouchDB> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || expectedCount < fetchSize ? expectedCount : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonMongo> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause,
      Token.class);
  
  int count=0;
  Iterator<Token> tokens = query.iterate();
  while(tokens.hasNext())
  {
    Token token = tokens.next();
    Assert.assertNotNull(token);
    Assert.assertNotNull(token.getClient());
    Assert.assertEquals(2, token.getClient().getTokens().size());
    count++;
  }
  
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  com.impetus.kundera.query.Query query = (com.impetus.kundera.query.Query) em.createQuery(queryClause,
      Token.class);
  
  int count=0;
  Iterator<Token> tokens = query.iterate();
  while(tokens.hasNext())
  {
    Token token = tokens.next();
    Assert.assertNotNull(token);
    Assert.assertNotNull(token.getClient());
    Assert.assertEquals(2, token.getClient().getTokens().size());
    count++;
  }
  
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  Iterator<CassandraPrimeUser> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize?available:fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonHBase> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonRDBMS> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnTokenScroll(String queryClause, int expected)
{
  Query query = (Query) em.createQuery(queryClause, RDBMSToken.class);
  int count = 0;
  Iterator<RDBMSToken> tokens = query.iterate();
  while (tokens.hasNext())
  {
    RDBMSToken token = tokens.next();
    Assert.assertNotNull(token);
    RDBMSTokenClient client = token.getClient();
    Assert.assertNotNull(client);
    Assert.assertEquals("tokenClient1", client.getClientName());
    // Assert.assertEquals(2, client.getTokens().size());
    count++;
  }
  Assert.assertTrue(count > 0);
  Assert.assertTrue(count == expected);
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  try
  {
  Iterator<PersonCassandra> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize?available:fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
  }catch(UnsupportedOperationException e)
  { 
    Assert.assertEquals("Iteration not supported over native queries",e.getMessage());
  }
  
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  try
  {
  Iterator<PersonCassandra> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize != null && fetchSize == 0 ? 0:available);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
  }catch(UnsupportedOperationException e)
  { 
    Assert.assertEquals("Iteration not supported over native queries",e.getMessage());
  }
  
}

代码示例来源:origin: Impetus/Kundera

Iterator<Book> iter = query.iterate();

代码示例来源:origin: Impetus/Kundera

@Test
public void testIteratorWithOneFilter()
{
  Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
  HBaseClient client = (HBaseClient) clients.get("hbaseTest");
  Filter filter = new PrefixFilter(Bytes.toBytes("100" + "_"));
  client.setFilter(new KeyOnlyFilter());
  client.addFilter("city_similarity", filter);
  String query2 = "select u from CitySimilarity u";
  com.impetus.kundera.query.Query queryObject = (com.impetus.kundera.query.Query) em
      .createQuery(query2);
  queryObject.setFetchSize(10);
  Iterator<CitySimilarity> resultIterator = queryObject.iterate();
  CitySimilarity cityS = null;
  int counter = 0;
  while (resultIterator.hasNext())
  {
    counter++;
    cityS = resultIterator.next();
    Assert.assertNotNull(cityS);
    Assert.assertNotNull(cityS.getId());
    Assert.assertNull(cityS.getBookInfo());
  }
  Assert.assertEquals(2, counter);
}

代码示例来源:origin: Impetus/Kundera

@Test
public void testIterator()
{
  String query2 = "select u from CitySimilarity u";
  com.impetus.kundera.query.Query queryObject = (com.impetus.kundera.query.Query) em
      .createQuery(query2);
  queryObject.setFetchSize(10);
  Iterator<CitySimilarity> resultIterator = queryObject.iterate();
  CitySimilarity cityS = null;
  int counter = 0;
  while (resultIterator.hasNext())
  {
    counter++;
    cityS = resultIterator.next();
    Assert.assertNotNull(cityS);
    Assert.assertNotNull(cityS.getId());
    Assert.assertNotNull(cityS.getBookInfo());
    Assert.assertNotNull(cityS.getBookInfo().getBookId());
  }
  Assert.assertEquals(2, counter);
}

相关文章