pavlukhin commented on a change in pull request #6917: IGNITE-12189 
Implementation correct limit for TextQuery
URL: https://github.com/apache/ignite/pull/6917#discussion_r341479189
 
 

 ##########
 File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java
 ##########
 @@ -120,28 +165,86 @@ public void testTextQueryWithKeepBinary() throws 
Exception {
         checkTextQuery(false, true);
     }
 
+    /**
+     * @throws Exception In case of error.
+     */
+    @Test
+    public void testTextQueryWithKeepBinaryLimited() throws Exception {
+        checkTextQuery(null, QUERY_LIMIT, false, true);
+    }
+
     /**
      * @throws Exception In case of error.
      */
     @Test
     public void testTextQuery() throws Exception {
-        checkTextQuery(false, true);
+        checkTextQuery(false, false);
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    @Test
+    public void testTextQueryLimited() throws Exception {
+        checkTextQuery(null, QUERY_LIMIT, false, false);
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    @Test
+    public void testTextQueryLimitedConcurrent() throws Exception {
+        final IgniteEx ignite = grid(0);
+
+        final String clause = "1*";
+
+        // 1. Populate cache with data, calculating expected count in parallel.
+        Set<Integer> exp = populateCache(ignite, false, MAX_ITEM_COUNT, 
(IgnitePredicate<Integer>)x -> String.valueOf(x).startsWith("1"));
+
+        ExecutorService executor = Executors.newFixedThreadPool(N_THREADS);
+
+        IntStream.range(0, N_THREADS).forEach((i) -> 
executor.submit(textQueryTask(ignite, clause, exp)));
+
+        executor.shutdown();
+        executor.awaitTermination(1, TimeUnit.MINUTES);
+
+        clearCache(ignite);
+    }
+
+    /**
+     * Creates Runnable for TextQuery
+     *
+     * @param ignite Ignite insance.
+     * @param clause Query clause.
+     * @param exp Expected results for validation.
+     * @return TextQuery and validation wrapped into Runnable functional 
interface.
+     */
+    @NotNull private Runnable textQueryTask(IgniteEx ignite, String clause, 
Set<Integer> exp) {
+        return () -> {
+            try {
+                TextQuery qry = new TextQuery<>(Person.class, clause);
+                validateQueryResults(ignite, qry, exp, false);
+            }
+            catch (Exception e) {
+                fail(e.getMessage());
+            }
+        };
     }
 
     /**
      * @param loc local query flag.
      * @param keepBinary keep binary flag.
      */
     private void checkTextQuery(boolean loc, boolean keepBinary) throws 
Exception {
-        checkTextQuery(null, loc, keepBinary);
+        checkTextQuery(null, 0, loc, keepBinary);
     }
 
     /**
      * @param clause Query clause.
      * @param loc local query flag.
      * @param keepBinary keep binary flag.
      */
-    private void checkTextQuery(String clause, boolean loc, boolean 
keepBinary) throws Exception {
+    private void checkTextQuery(String clause, int limit, boolean loc, boolean 
keepBinary) throws Exception {
 
 Review comment:
   Missing `@param limit Limit.` in javadoc.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to