use of org.apache.geode.cache.query.internal.index.CompactMapRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testMapKeyIndexCreation_2_NonCompactType.
@Test
public void testMapKeyIndexCreation_2_NonCompactType() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "pf.positions['key1','key2','key3']", "/portfolios pf");
assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.positions['key1','key2','key3']");
assertTrue(i1 instanceof CompactMapRangeIndex);
CompactMapRangeIndex mri = (CompactMapRangeIndex) i1;
Object[] mapKeys = mri.getMapKeysForTesting();
assertEquals(mapKeys.length, 3);
Set<String> keys = new HashSet<String>();
keys.add("key1");
keys.add("key2");
keys.add("key3");
for (Object key : mapKeys) {
keys.remove(key);
}
assertTrue(keys.isEmpty());
String[] patterns = mri.getPatternsForTesting();
assertEquals(patterns.length, 3);
Set<String> patternsSet = new HashSet<String>();
patternsSet.add("index_iter1.positions['key1']");
patternsSet.add("index_iter1.positions['key2']");
patternsSet.add("index_iter1.positions['key3']");
for (String ptrn : patterns) {
patternsSet.remove(ptrn);
}
assertTrue(patternsSet.isEmpty());
assertEquals(mri.getIndexedExpression(), "pf.positions['key1','key2','key3']");
}
use of org.apache.geode.cache.query.internal.index.CompactMapRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testMapKeyIndexCreation_1_NonCompactType.
@Test
public void testMapKeyIndexCreation_1_NonCompactType() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL, "pf.positions[*]", "/portfolios pf");
assertEquals(i1.getCanonicalizedIndexedExpression(), "index_iter1.positions[*]");
assertTrue(i1 instanceof CompactMapRangeIndex);
}
Aggregations