You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tl...@apache.org on 2021/04/29 09:24:05 UTC

[ignite] branch master updated: IGNITE-14660 fix flaky test GridSubqueryJoinOptimizerSelfTest#testOptimizationAppliedToUnion (#9052)

This is an automated email from the ASF dual-hosted git repository.

tledkov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 08f75dd  IGNITE-14660 fix flaky test GridSubqueryJoinOptimizerSelfTest#testOptimizationAppliedToUnion (#9052)
08f75dd is described below

commit 08f75ddf6f18d56b89583d496c07ba510f98a09c
Author: korlov42 <ko...@gridgain.com>
AuthorDate: Thu Apr 29 12:23:43 2021 +0300

    IGNITE-14660 fix flaky test GridSubqueryJoinOptimizerSelfTest#testOptimizationAppliedToUnion (#9052)
---
 .../h2/GridSubqueryJoinOptimizerSelfTest.java      | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridSubqueryJoinOptimizerSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridSubqueryJoinOptimizerSelfTest.java
index de2bcd3..03b3638 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridSubqueryJoinOptimizerSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridSubqueryJoinOptimizerSelfTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.query.h2;
 
+import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
 import org.apache.ignite.IgniteCache;
@@ -34,6 +36,9 @@ import org.junit.Test;
  */
 public class GridSubqueryJoinOptimizerSelfTest extends GridCommonAbstractTest {
     /** */
+    private static final Comparator<List<?>> ROW_COMPARATOR = new RowComparator();
+
+    /** */
     private static final String CACHE_NAME = "cache";
 
     /** */
@@ -641,10 +646,14 @@ public class GridSubqueryJoinOptimizerSelfTest extends GridCommonAbstractTest {
 
         List<List<?>> exp = cache.query(new SqlFieldsQuery(sql)).getAll();
 
+        exp.sort(ROW_COMPARATOR);
+
         optimizationEnabled(true);
 
         List<List<?>> act = cache.query(new SqlFieldsQuery(sql).setEnforceJoinOrder(true)).getAll();
 
+        act.sort(ROW_COMPARATOR);
+
         Assert.assertEquals("Result set mismatch", exp, act);
 
         String plan = cache.query(new SqlFieldsQuery("explain " + sql)).getAll().get(0).get(0).toString();
@@ -696,4 +705,49 @@ public class GridSubqueryJoinOptimizerSelfTest extends GridCommonAbstractTest {
 
         GridTestUtils.setFieldValue(GridSubqueryJoinOptimizer.class, "optimizationEnabled", null);
     }
+
+    /** */
+    @SuppressWarnings("ComparatorNotSerializable")
+    private static class RowComparator implements Comparator<List<?>> {
+        /** {@inheritDoc} */
+        @Override public int compare(List<?> o1, List<?> o2) {
+            if (o1 == null && o2 == null)
+                return 0;
+
+            if (o1 == null)
+                return 1;
+
+            if (o2 == null)
+                return -1;
+
+            Iterator<?> i1 = o1.iterator(), i2 = o2.iterator();
+            while (i1.hasNext() && i2.hasNext()) {
+                Object e1 = i1.next(), e2 = i2.next();
+
+                if (e1 == null && e2 == null)
+                    continue;
+
+                if (e1 == null)
+                    return 1;
+
+                if (e2 == null)
+                    return -1;
+
+                checkComparable(e1);
+                checkComparable(e2);
+
+                int res = ((Comparable<Object>)e1).compareTo(e2);
+                if (res != 0)
+                    return res;
+            }
+
+            return Integer.signum(o1.size() - o2.size());
+        }
+
+        /** */
+        private void checkComparable(Object o) {
+            if (!(o instanceof Comparable))
+                throw new RuntimeException(o.getClass().getSimpleName() + " is not comparable");
+        }
+    }
 }