Package org.infinispan.query

Examples of org.infinispan.query.ResultIterator


         public Void call() throws Exception {
            cache1.remove("1");   // cache will now be out of sync with the index
            searchManager = Search.getSearchManager(cache1);

            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).iterator(new FetchOptions().fetchMode(EAGER));
            assertFalse("Iterator should not have elements.", iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here


         public Void call() throws Exception {
            cache1.remove("1");   // cache will now be out of sync with the index
            searchManager = Search.getSearchManager(cache1);

            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).iterator();
            assertFalse(iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here

         public Void call() throws Exception {
            cache2.remove("2");   // cache will now be out of sync with the index
            searchManager = Search.getSearchManager(cache1);

            Query query = createQueryBuilder().keyword().onField("bar").matching("2").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).iterator(new FetchOptions().fetchMode(LAZY));
            assertFalse(iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here

         public Void call() throws Exception {
            cache1.remove("1");   // cache will now be out of sync with the index
            searchManager = Search.getSearchManager(cache1);

            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).projection(ProjectionConstants.VALUE, "bar")
                  .iterator(new FetchOptions().fetchMode(LAZY));
            assertTrue("Expected an element in iterator.", iterator.hasNext());
            Object[] projection = (Object[]) iterator.next();
            assertNull(projection[0]);
            assertEquals("1", projection[1]);
            return null;
         }
      });
View Full Code Here

      withTx(tm(), new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            cache.remove("1");   // cache will now be out of sync with the index
            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).iterator(new FetchOptions().fetchMode(EAGER));
            assertFalse(iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here

         public Void call() throws Exception {
            cache.remove("1");   // cache will now be out of sync with the index
            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            CacheQuery cacheQuery = searchManager.getQuery(query);
            assertEquals(1, cacheQuery.getResultSize());
            ResultIterator iterator = cacheQuery.iterator();
            assertFalse(iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here

      withTx(tm(), new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            cache.remove("1");   // cache will now be out of sync with the index
            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).iterator(new FetchOptions().fetchMode(LAZY));
            assertFalse(iterator.hasNext());
            try {
               iterator.next();
               fail("Expected NoSuchElementException");
            } catch (NoSuchElementException e) {
               // pass
            }
            return null;
View Full Code Here

      withTx(tm(), new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            cache.remove("1");   // cache will now be out of sync with the index
            Query query = createQueryBuilder().keyword().onField("bar").matching("1").createQuery();
            ResultIterator iterator = searchManager.getQuery(query).projection(ProjectionConstants.VALUE, "bar").iterator(new FetchOptions().fetchMode(LAZY));
            assertTrue(iterator.hasNext());
            Object[] projection = (Object[]) iterator.next();
            assertNull(projection[0]);
            assertEquals("1", projection[1]);
            return null;
         }
      });
View Full Code Here

      Query luceneQuery = queryParser.parse("Eats");

      CacheQuery cacheQuery = manager.getQuery(luceneQuery);

      int counter = 0;
      ResultIterator found = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY));
      try {
         while(found.hasNext()) {
            found.next();
            counter++;
        }
      }
      finally {
         found.close();
      }

      AssertJUnit.assertEquals(2, counter);
      StaticTestingErrorHandler.assertAllGood(cache1, cache2);
   }
View Full Code Here

      return cacheQuery;
   }

   private void assertQueryReturns(CacheQuery cacheQuery, Object[] expected) {
      assertQueryListContains(cacheQuery.list(), expected);
      final ResultIterator eagerIterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER));
      try {
         assertQueryIteratorContains(eagerIterator, expected);
      }
      finally {
         eagerIterator.close();
      }
      final ResultIterator lazyIterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY));
      try {
         assertQueryIteratorContains(lazyIterator, expected);
      }
      finally {
         lazyIterator.close();
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.query.ResultIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.