albertogpz commented on a change in pull request #6279:
URL: https://github.com/apache/geode/pull/6279#discussion_r623766912
##########
File path:
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java
##########
@@ -338,7 +341,302 @@ public void
testNullMapValuesInIndexOnLocalRegionForCompactMap() throws Exceptio
SelectResults result = (SelectResults) qs
.newQuery("select * from " + SEPARATOR + "portfolio p where
p.positions['SUN'] = null")
.execute();
- assertEquals(1, result.size());
+ assertEquals(2, result.size());
+ }
+
+ @Test
+ public void testQueriesForValueInMapFieldWithoutIndex() throws Exception {
+ region =
+
CacheUtils.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("portfolio");
+ qs = CacheUtils.getQueryService();
+ testQueriesForValueInMapField(region, qs);
+ }
+
+ @Test
+ public void testQueriesForValueInMapFieldWithCompactMapIndexWithOneKey()
throws Exception {
+ region =
+
CacheUtils.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("portfolio");
+ qs = CacheUtils.getQueryService();
+
+ keyIndex1 = qs.createIndex(INDEX_NAME, "positions['SUN']", SEPARATOR +
"portfolio ");
+ assertThat(keyIndex1).isInstanceOf(CompactRangeIndex.class);
+ testQueriesForValueInMapField(region, qs);
+
+ long keys = ((CompactRangeIndex)
keyIndex1).internalIndexStats.getNumberOfKeys();
+ long mapIndexKeys =
+ ((CompactRangeIndex)
keyIndex1).internalIndexStats.getNumberOfMapIndexKeys();
+ long values =
+ ((CompactRangeIndex) keyIndex1).internalIndexStats.getNumberOfValues();
+ long uses =
+ ((CompactRangeIndex) keyIndex1).internalIndexStats.getTotalUses();
+
+ // The number of keys must be equal to the number of different values the
+ // positions map takes in region entries for the 'SUN' key:
+ // ("nothing", "more"). null or UNDEFINED not included
+ assertThat(keys).isEqualTo(2);
+ // mapIndexKeys must be zero because the index used is a range index and
not a map index
+ assertThat(mapIndexKeys).isEqualTo(0);
+ // The number of values must be equal to the number of region entries
+ assertThat(values).isEqualTo(7);
+ // The index must be used in every query
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]