ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] AMashenkov commented on a change in pull request #6917: IGNITE-12189 Implementation correct limit for TextQuery
Date Tue, 08 Oct 2019 08:37:45 GMT
AMashenkov commented on a change in pull request #6917: IGNITE-12189 Implementation correct
limit for TextQuery
URL: https://github.com/apache/ignite/pull/6917#discussion_r332394278
 
 

 ##########
 File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java
 ##########
 @@ -212,86 +255,84 @@ private static void clearCache(IgniteEx ignite) {
      *
      * @throws IgniteCheckedException if failed.
      */
-    private static void validateQueryResults(IgniteEx ignite, Query qry, Set<Integer>
exp,
+    private static void validateQueryResults(IgniteEx ignite, TextQuery qry, Set<Integer>
exp,
         boolean keepBinary) throws IgniteCheckedException {
         IgniteCache<Integer, Person> cache = ignite.cache(PERSON_CACHE);
 
         if (keepBinary) {
             IgniteCache<Integer, BinaryObject> cache0 = cache.withKeepBinary();
 
             try (QueryCursor<Cache.Entry<Integer, BinaryObject>> cursor = cache0.query(qry))
{
-                Set<Integer> exp0 = new HashSet<>(exp);
-
-                List<Cache.Entry<Integer, ?>> all = new ArrayList<>();
-
-                for (Cache.Entry<Integer, BinaryObject> entry : cursor.getAll()) {
-                    all.add(entry);
-
-                    assertEquals(entry.getKey().toString(), entry.getValue().field("name"));
 
-                    assertEquals(entry.getKey(), entry.getValue().field("age"));
+                TestPair testPair = processExpectedWithBinary(exp, cursor);
 
-                    exp0.remove(entry.getKey());
-                }
-
-                checkForMissedKeys(ignite, exp0, all);
+                assertResult(ignite, qry, testPair);
             }
 
             try (QueryCursor<Cache.Entry<Integer, BinaryObject>> cursor = cache0.query(qry))
{
-                Set<Integer> exp0 = new HashSet<>(exp);
-
-                List<Cache.Entry<Integer, ?>> all = new ArrayList<>();
-
-                for (Cache.Entry<Integer, BinaryObject> entry : cursor.getAll()) {
-                    all.add(entry);
 
-                    assertEquals(entry.getKey().toString(), entry.getValue().field("name"));
+                TestPair testPair = processExpectedWithBinary(exp, cursor);
 
-                    assertEquals(entry.getKey(), entry.getValue().field("age"));
-
-                    exp0.remove(entry.getKey());
-                }
-
-                checkForMissedKeys(ignite, exp0, all);
+                assertResult(ignite, qry, testPair);
             }
         }
         else {
             try (QueryCursor<Cache.Entry<Integer, Person>> cursor = cache.query(qry))
{
-                Set<Integer> exp0 = new HashSet<>(exp);
 
-                List<Cache.Entry<Integer, ?>> all = new ArrayList<>();
+                TestPair testPair = processExpected(exp, cursor);
 
-                for (Cache.Entry<Integer, Person> entry : cursor.getAll()) {
-                    all.add(entry);
+                assertResult(ignite, qry, testPair);
 
-                    assertEquals(entry.getKey().toString(), entry.getValue().name);
+            }
 
-                    assertEquals(entry.getKey(), Integer.valueOf(entry.getValue().age));
+            try (QueryCursor<Cache.Entry<Integer, Person>> cursor = cache.query(qry))
{
 
-                    exp0.remove(entry.getKey());
-                }
+                TestPair testPair = processExpected(exp, cursor);
 
-                checkForMissedKeys(ignite, exp0, all);
+                assertResult(ignite, qry, testPair);
             }
+        }
+    }
 
-            try (QueryCursor<Cache.Entry<Integer, Person>> cursor = cache.query(qry))
{
-                Set<Integer> exp0 = new HashSet<>(exp);
+    private static void assertResult(IgniteEx ignite, TextQuery qry,
+        TestPair testPair) throws IgniteCheckedException {
+        if (qry.getLimit() > 0){
+            assertTrue(testPair.all.size() <= QUERY_LIMIT);
 
 Review comment:
   Should be:
   ```
   if (qry.getLimit() > 0)
       assertTrue(testPair.all.size() <= QUERY_LIMIT);
   else 
       checkForMissedKeys(ignite, testPair.expected, testPair.all);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message