geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [22/50] [abbrv] geode git commit: GEODE-2579: ClassCastException cannot cast CompiledIn to CompiledJunction
Date Mon, 13 Mar 2017 17:42:49 GMT
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/e94e2332
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/e94e2332
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/e94e2332

Branch: refs/heads/GEODE-2290
Commit: e94e233287a3741de975479af3eebae692778642
Parents: 47697d4
Author: Jason Huynh <huynhja@gmail.com>
Authored: Fri Mar 3 09:20:11 2017 -0800
Committer: Jason Huynh <huynhja@gmail.com>
Committed: Tue Mar 7 11:29:44 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/e94e2332/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/e94e2332/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;


Mime
View raw message