geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [03/50] incubator-geode git commit: GEODE-90: IN SET Query using Index throws IllegalArgumentException
Date Fri, 24 Jul 2015 23:15:26 GMT
GEODE-90: IN SET Query using Index throws IllegalArgumentException

Add iterated object instead of the collection of objects to query results
Reviewed by Anil, Kirk


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

Branch: refs/heads/feature/GEODE-86
Commit: 5e1460df69cf3a83330b46b06dc8b859fe396cb5
Parents: 1f64628
Author: Jason Huynh <jhuynh@Jason-Huynh-MacBook-Pro.local>
Authored: Thu Jul 9 15:04:50 2015 -0700
Committer: Jason Huynh <jhuynh@Jason-Huynh-MacBook-Pro.local>
Committed: Mon Jul 13 10:16:59 2015 -0700

----------------------------------------------------------------------
 .../query/internal/index/AbstractIndex.java     |  4 +--
 .../internal/index/RangeIndexAPIJUnitTest.java  | 32 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5e1460df/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
index 2ab3dd8..6c0d0bf 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/query/internal/index/AbstractIndex.java
@@ -2012,7 +2012,7 @@ public abstract class AbstractIndex implements IndexProtocol
                     ok = QueryUtils.applyCondition(iterOp, context);
                   }
                   if (ok) {
-                    applyProjection(projAttrib, context, result, value,
+                    applyProjection(projAttrib, context, result, val,
                         intermediateResults, isIntersection);
                     if (limit != -1 && result.size() == limit) {
                       return;
@@ -2035,7 +2035,7 @@ public abstract class AbstractIndex implements IndexProtocol
                   ok = QueryUtils.applyCondition(iterOp, context);
                 }
                 if (ok) {
-                  applyProjection(projAttrib, context, result, value,
+                  applyProjection(projAttrib, context, result, val,
                       intermediateResults, isIntersection);
                   if (this.verifylimit(result, limit, context)) {
                     return;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5e1460df/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/RangeIndexAPIJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/RangeIndexAPIJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/RangeIndexAPIJUnitTest.java
index 9d9c09f..b9f6ff8 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/RangeIndexAPIJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/RangeIndexAPIJUnitTest.java
@@ -23,12 +23,16 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.query.AmbiguousNameException;
 import com.gemstone.gemfire.cache.query.CacheUtils;
+import com.gemstone.gemfire.cache.query.Index;
 import com.gemstone.gemfire.cache.query.IndexType;
 import com.gemstone.gemfire.cache.query.NameResolutionException;
+import com.gemstone.gemfire.cache.query.Query;
 import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.TypeMismatchException;
 import com.gemstone.gemfire.cache.query.data.Portfolio;
 import com.gemstone.gemfire.cache.query.internal.CompiledIteratorDef;
@@ -38,6 +42,7 @@ import com.gemstone.gemfire.cache.query.internal.QCompiler;
 import com.gemstone.gemfire.cache.query.internal.QueryExecutionContext;
 import com.gemstone.gemfire.cache.query.internal.RuntimeIterator;
 import com.gemstone.gemfire.cache.query.internal.parse.OQLLexerTokenTypes;
+import com.gemstone.gemfire.pdx.PdxInstance;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
 /**
@@ -364,8 +369,33 @@ public class RangeIndexAPIJUnitTest {
       assertTrue( results.contains(region.get(new Integer(i))));      
       ++i;      
     }
-    
   }  
+ 
+  @Test 
+  public void testQueryRVMapMultipleEntries() throws Exception {
+    Cache cache = CacheUtils.getCache();
+    QueryService queryService = CacheUtils.getCache().getQueryService();
+    CacheUtils.createRegion("TEST_REGION", null);
+    queryService.createIndex("tr.nested.id.index", "nested.id", "/TEST_REGION, nested IN
nested_values");
+    Query queryInSet = queryService.newQuery("SELECT DISTINCT tr.id FROM /TEST_REGION tr,
tr.nested_values nested WHERE nested.id IN SET ('1')");
+    Query queryEquals = queryService.newQuery("SELECT DISTINCT tr.id FROM /TEST_REGION tr,
nested IN nested_values WHERE nested.id='1'");
+
+    Object[] nested = new Object[] {
+            cache.createPdxInstanceFactory("nested_1").writeString("id", "1").create(),
+            cache.createPdxInstanceFactory("nested_2").writeString("id", "1").create(),
+            cache.createPdxInstanceFactory("nested_3").writeString("id", "1").create(),
+            cache.createPdxInstanceFactory("nested_4").writeString("id", "4").create()
+    };
+
+    PdxInstance record = cache.createPdxInstanceFactory("root").writeString("id", "2").writeObjectArray("nested_values",
nested).create();
+
+    cache.getRegion("TEST_REGION").put("100", record);
+    Index index = cache.getQueryService().getIndex(cache.getRegion("TEST_REGION"), "mdf.testRegion.nested.id");
+    SelectResults queryResults = (SelectResults) queryEquals.execute();
+    SelectResults inSetQueryResults = (SelectResults) queryInSet.execute();
+    assertEquals(queryResults.size(), inSetQueryResults.size());
+    assertTrue(inSetQueryResults.size() > 0);
+  }
 
   private void bindIterators(ExecutionContext context, String string) throws AmbiguousNameException,
TypeMismatchException, NameResolutionException {
     QCompiler compiler = new QCompiler();


Mime
View raw message