You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by js...@apache.org on 2017/03/13 17:43:00 UTC

[33/50] [abbrv] geode git commit: GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction

*  AbstractGroupOrRangeJunction does not incorrectly cast when creating junction with in clause
*  In clause will be handled like a compiled comparison


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

Branch: refs/heads/GEODE-2290
Commit: d63512fdcedd3353ed6d3e9bf7b5449ac5abd88d
Parents: 9852f64
Author: Jason Huynh <hu...@gmail.com>
Authored: Fri Mar 3 09:20:11 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../internal/AbstractGroupOrRangeJunction.java  |  2 +-
 .../geode/cache/query/QueryJUnitTest.java       | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d63512fd/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
index a499346..5ed4d86 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java
@@ -68,7 +68,7 @@ public abstract class AbstractGroupOrRangeJunction extends AbstractCompiledValue
     this.completeExpansion = completeExpansion;
     this.indpndntItr = indpnds;
     if (iterOp != null) {
-      if (iterOp instanceof CompiledComparison) {
+      if (iterOp instanceof CompiledComparison || iterOp instanceof CompiledIn) {
         int finalSize = 1 + oldGJ._operands.length;
         this._operands = new CompiledValue[finalSize];
         System.arraycopy(oldGJ._operands, 0, this._operands, 0, finalSize - 1);

http://git-wip-us.apache.org/repos/asf/geode/blob/d63512fd/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
index 7333212..f08eef5 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/QueryJUnitTest.java
@@ -26,6 +26,7 @@ package org.apache.geode.cache.query;
 import static org.junit.Assert.*;
 import static org.junit.runners.MethodSorters.*;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -34,6 +35,8 @@ import java.util.Set;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.query.internal.index.IndexProtocol;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
@@ -308,6 +311,55 @@ public class QueryJUnitTest {
     }
   }
 
+  @Test
+  public void creatingACompiledJunctionWithACompiledInClauseDoesNotThrowException()
+      throws Exception {
+    Cache cache = CacheUtils.getCache();
+    RegionFactory<Integer, Portfolio> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    Region regionA = rf.create("regionA");
+    Region regionB = rf.create("regionB");
+
+    for (int i = 1; i <= 100; i++) {
+      regionA.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+      regionB.put(Integer.toString(i), new TestUserObject("" + i, "" + i, "" + i, "" + i));
+    }
+    QueryService qs = CacheUtils.getQueryService();
+
+    Index regionAUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionA ");
+    Index regionBUserCodeIndex = (IndexProtocol) qs.createIndex("regionAUserCodeIndex",
+        IndexType.FUNCTIONAL, "userId", "/regionB ");
+
+    Index regionAUserNameIndex = (IndexProtocol) qs.createIndex("regionAUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionA ");
+    Index regionBUserNameIndex = (IndexProtocol) qs.createIndex("regionBUserNameIndex",
+        IndexType.FUNCTIONAL, "userName", "/regionB ");
+
+    Query query = qs.newQuery(
+        "select regionB.userId,regionA.professionCode,regionB.postCode,regionB.userName from /regionA regionA,/regionB regionB where regionA.userId = regionB.userId and regionA.professionCode in Set('1','2','3') and regionB.postCode = '1' and regionB.userId='1'");
+    SelectResults results = (SelectResults) query.execute();
+    assertTrue(results.size() > 0);
+  }
+
+  public static class TestUserObject implements Serializable {
+    public String professionCode;
+    public String userId;
+    public String postCode;
+    public String userName;
+
+    public TestUserObject() {
+
+    }
+
+    public TestUserObject(final String professionCode, final String userId, final String postCode,
+        final String userName) {
+      this.professionCode = professionCode;
+      this.userId = userId;
+      this.postCode = postCode;
+      this.userName = userName;
+    }
+  }
+
   private class QueryRunnable implements Runnable {
     private Query q;
     private Object[] params;