Repository: incubator-geode Updated Branches: refs/heads/develop 4a9e23a7e -> cf3fea30f
GEODE-1675: Fixed reevaluation with map range index non tuples Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/cf3fea30 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/cf3fea30 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/cf3fea30 Branch: refs/heads/develop Commit: cf3fea30f49e9b4874a8091b587dde33b79208e6 Parents: 8c7932e Author: Jason Huynh <huyn...@gmail.com> Authored: Tue Sep 20 15:12:37 2016 -0700 Committer: Jason Huynh <huyn...@gmail.com> Committed: Wed Sep 21 16:21:03 2016 -0700 ---------------------------------------------------------------------- .../geode/cache/query/internal/index/CompactRangeIndex.java | 3 ++- .../internal/index/MapRangeIndexMaintenanceJUnitTest.java | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cf3fea30/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java index d5dd5a6..c99da56 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java @@ -984,7 +984,8 @@ public class CompactRangeIndex extends AbstractIndex { if (key != null) { right = key.evaluate(context); - if(null != right && indexInfo._getIndex() instanceof CompactMapRangeIndex){ + //This next check is for map queries with In Clause, in those cases the reevaluation creates a tuple. In other cases it does not + if(null != right && indexInfo._getIndex() instanceof CompactMapRangeIndex && right instanceof Object[]){ right = ((Object[])right)[0]; } } else { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cf3fea30/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java index f79e10b..b651272 100644 --- a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java @@ -393,7 +393,7 @@ public class MapRangeIndexMaintenanceJUnitTest{ } @Test - public void updatingAMapFieldSameKeysShouldUpdateCorrectly() throws Exception { + public void updatingAMapFieldSameKeysSameValuesShouldUpdateCorrectly() throws Exception { //Create Partition Region AttributesFactory af = new AttributesFactory(); af.setScope(Scope.LOCAL); @@ -414,12 +414,13 @@ public class MapRangeIndexMaintenanceJUnitTest{ Portfolio p2 = new Portfolio(1, 1); HashMap map2 = new HashMap(); p2.positions = map2; - map2.put("NEW_KEY", 1); + map2.put("SUN", 1); + map2.put("IBM", 2); region.put(1, p2); SelectResults results = (SelectResults) qs.newQuery("select * from /portfolio p where p.positions['SUN'] = 1 OR p.positions['IBM'] = 2") .execute(); - assertEquals(0, results.size()); + assertEquals(1, results.size()); } @Test @@ -500,7 +501,7 @@ public class MapRangeIndexMaintenanceJUnitTest{ @Test - public void testUpdateWithSameKeysDifferentValuesShouldRetainIndexMappings() throws Exception { + public void updatingWithSameKeysDifferentValuesShouldRetainIndexMappings() throws Exception { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.LOCAL);