Search in sources :

Example 1 with CompactMapRangeIndex

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']");
}
Also used : DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) CompactMapRangeIndex(org.apache.geode.cache.query.internal.index.CompactMapRangeIndex) RangeIndex(org.apache.geode.cache.query.internal.index.RangeIndex) CompactMapRangeIndex(org.apache.geode.cache.query.internal.index.CompactMapRangeIndex) Index(org.apache.geode.cache.query.Index) CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) HashSet(java.util.HashSet) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with CompactMapRangeIndex

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);
}
Also used : DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) CompactMapRangeIndex(org.apache.geode.cache.query.internal.index.CompactMapRangeIndex) RangeIndex(org.apache.geode.cache.query.internal.index.RangeIndex) CompactMapRangeIndex(org.apache.geode.cache.query.internal.index.CompactMapRangeIndex) Index(org.apache.geode.cache.query.Index) CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Index (org.apache.geode.cache.query.Index)2 QueryService (org.apache.geode.cache.query.QueryService)2 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)2 CompactMapRangeIndex (org.apache.geode.cache.query.internal.index.CompactMapRangeIndex)2 CompactRangeIndex (org.apache.geode.cache.query.internal.index.CompactRangeIndex)2 RangeIndex (org.apache.geode.cache.query.internal.index.RangeIndex)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1