ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ira...@apache.org
Subject ignite git commit: IGNITE-8693 SQL JOIN between PARTITIONED and REPLICATED cache fails - Fixes #4120.
Date Mon, 04 Jun 2018 22:26:12 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 9c2b1e755 -> bc35ce0cd


IGNITE-8693 SQL JOIN between PARTITIONED and REPLICATED cache fails - Fixes #4120.

Signed-off-by: Ivan Rakov <irakov@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc35ce0c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc35ce0c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc35ce0c

Branch: refs/heads/master
Commit: bc35ce0cdf0698a730637e77f08aadf9a295f759
Parents: 9c2b1e7
Author: Ilya Lantukh <ilantukh@gridgain.com>
Authored: Tue Jun 5 01:24:37 2018 +0300
Committer: Ivan Rakov <irakov@apache.org>
Committed: Tue Jun 5 01:24:37 2018 +0300

----------------------------------------------------------------------
 .../h2/twostep/GridReduceQueryExecutor.java     |  15 ++
 .../QueryJoinWithDifferentNodeFiltersTest.java  | 163 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite2.java         |   3 +
 3 files changed, 181 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bc35ce0c/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 20bf32c..cd76bc1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -452,6 +452,21 @@ public class GridReduceQueryExecutor {
         List<Integer> cacheIds, int[] parts) {
         GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(0));
 
+        // If the first cache is not partitioned, find it (if it's present) and move it to
index 0.
+        if (!cctx.isPartitioned()) {
+            for (int cacheId = 1; cacheId < cacheIds.size(); cacheId++) {
+                GridCacheContext<?, ?> currCctx = cacheContext(cacheIds.get(cacheId));
+
+                if (currCctx.isPartitioned()) {
+                    Collections.swap(cacheIds, 0, cacheId);
+
+                    cctx = currCctx;
+
+                    break;
+                }
+            }
+        }
+
         Map<ClusterNode, IntArray> map = stableDataNodesMap(topVer, cctx, parts);
 
         Set<ClusterNode> nodes = map.keySet();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bc35ce0c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java
new file mode 100644
index 0000000..47666b9
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class QueryJoinWithDifferentNodeFiltersTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE_NAME = "cache";
+
+    /** */
+    private static final String CACHE_NAME_2 = "cache2";
+
+    /** */
+    private static final int NODE_COUNT = 4;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setCacheConfiguration(
+            new CacheConfiguration<>(CACHE_NAME)
+                .setBackups(1)
+                .setCacheMode(CacheMode.REPLICATED)
+                .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(Integer.class, Organization.class),
+            new CacheConfiguration<>(CACHE_NAME_2)
+                .setNodeFilter(new TestFilter())
+                .setBackups(1)
+                .setCacheMode(CacheMode.PARTITIONED)
+                .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
+                .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                .setIndexedTypes(Integer.class, Person.class)
+            );
+
+        if (getTestIgniteInstanceName(0).equals(igniteInstanceName) || getTestIgniteInstanceName(1).equals(igniteInstanceName))
+            cfg.setUserAttributes(F.asMap("DATA", "true"));
+
+        if ("client".equals(igniteInstanceName))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+
+        U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "snapshot", false));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "snapshot", false));
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testSize() throws Exception {
+        startGrids(NODE_COUNT);
+
+        Ignite client = startGrid("client");
+
+        client.cluster().active(true);
+
+        IgniteCache<Object, Object> cache = client.cache(CACHE_NAME);
+        IgniteCache<Object, Object> cache2 = client.cache(CACHE_NAME_2);
+
+        int size = 100;
+
+        for (int i = 0; i < size; i++) {
+            cache.put(i, new Organization(i, "Org-" + i));
+            cache2.put(i, new Person(i, i, "Person-" + i));
+        }
+
+        info(cache2.query(new SqlFieldsQuery("select * from \"cache\".Organization r, \"cache2\".Person
p where p.orgId=r.orgId")).getAll().toString());
+    }
+
+    /**
+     *
+     */
+    private static class Organization {
+        /** */
+        @SuppressWarnings("unused") @QuerySqlField(index = true) private int orgId;
+
+        /** */
+        @SuppressWarnings("unused") private String orgName;
+
+        /**
+         *
+         */
+        public Organization(int orgId, String orgName) {
+            this.orgId = orgId;
+            this.orgName = orgName;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Person {
+        /** */
+        @SuppressWarnings("unused") @QuerySqlField(index = true) private int personId;
+
+        /** */
+        @SuppressWarnings("unused") @QuerySqlField(index = true) private int orgId;
+
+        /** */
+        @SuppressWarnings("unused") private String name;
+
+        /**
+         *
+         */
+        public Person(int personId, int orgId, String name) {
+            this.personId = personId;
+            this.orgId = orgId;
+            this.name = name;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestFilter implements IgnitePredicate<ClusterNode> {
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode clusterNode) {
+            return clusterNode.attribute("DATA") != null;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/bc35ce0c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
index 5b888ce..1b76283 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.QueryJoinWithDifferentNodeFiltersTest;
 import org.apache.ignite.internal.processors.cache.CacheScanPartitionQueryFallbackSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheCrossCacheJoinRandomTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheObjectKeyIndexingSelfTest;
@@ -104,6 +105,8 @@ public class IgniteCacheQuerySelfTestSuite2 extends TestSuite {
         suite.addTestSuite(IgniteCacheGroupsSqlSegmentedIndexMultiNodeSelfTest.class);
         suite.addTestSuite(IgniteCacheGroupsSqlDistributedJoinSelfTest.class);
 
+        suite.addTestSuite(QueryJoinWithDifferentNodeFiltersTest.class);
+
         return suite;
     }
 }


Mime
View raw message