use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class QueryTraceJUnitTest method testTraceOnLocalRegionWithSmallTracePrefixNoComments.
@Test
public void testTraceOnLocalRegionWithSmallTracePrefixNoComments() throws Exception {
String prefix = "<trace> ";
// Create Partition Region
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
region = CacheUtils.createRegion("portfolio", af.create(), false);
if (region.size() == 0) {
for (int i = 1; i <= 100; i++) {
region.put(Integer.toString(i), new Portfolio(i, i));
}
}
assertEquals(100, region.size());
qs = CacheUtils.getQueryService();
keyIndex1 = (IndexProtocol) qs.createIndex(INDEX_NAME, IndexType.FUNCTIONAL, "ID", "/portfolio ");
assertTrue(keyIndex1 instanceof CompactRangeIndex);
Query query = qs.newQuery(prefix + queryStr);
assertTrue(((DefaultQuery) query).isTraced());
SelectResults results = (SelectResults) query.execute();
assertTrue(QueryObserverHolder.getInstance() instanceof IndexTrackingQueryObserver);
// The query should return all elements in region.
assertEquals(region.size(), results.size());
QueryObserverHolder.reset();
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testBug36591.
/**
* The Index maintenance has a bug as it does not re-evaluate the index maintenance collection in
* the IMQEvaluator when an entry gets modified & so the index resultset is messed up
*/
@Test
public void testBug36591() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode", "/portfolios.keys ks");
Region rgn = CacheUtils.getRegion("/portfolios");
rgn.put("4", new Portfolio(4));
rgn.put("5", new Portfolio(5));
CacheUtils.log(((CompactRangeIndex) i1).dump());
Query qr = qs.newQuery("Select distinct * from /portfolios.keys keys where keys.hashCode >= $1");
SelectResults sr = (SelectResults) qr.execute(new Object[] { new Integer(-1) });
assertEquals(6, sr.size());
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testIMQFailureAsMethodKeysNAInDummyQRegion.
/**
* Test the Index maiantenance as it may use the method keys() of QRegion instead of DummyQRegion
* while running an IndexMaintenanceQuery
*/
@Test
public void testIMQFailureAsMethodKeysNAInDummyQRegion() throws Exception {
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode", "/portfolios.keys() ks");
Region rgn = CacheUtils.getRegion("/portfolios");
rgn.put("4", new Portfolio(4));
rgn.put("5", new Portfolio(5));
CacheUtils.log(((CompactRangeIndex) i1).dump());
Query qr = qs.newQuery("Select distinct keys.hashCode from /portfolios.keys() keys where keys.hashCode >= $1");
SelectResults sr = (SelectResults) qr.execute(new Object[] { new Integer(-1) });
assertEquals(6, sr.size());
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testIndexCreationOnKeys.
@Test
public void testIndexCreationOnKeys() throws Exception {
// Task ID : ICM 9
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("kIndex", IndexType.FUNCTIONAL, "pf", "/portfolios.keys pf");
Index i2 = qs.createIndex("k1Index", IndexType.FUNCTIONAL, "key", "/portfolios.entries");
Index i3 = qs.createIndex("k2Index", IndexType.FUNCTIONAL, "pf", "/portfolios.keys.toArray pf");
// Index i4 = qs.createIndex("k3Index", IndexType.FUNCTIONAL,
// "pf","/portfolios.keys().toArray() pf");
Index i5 = qs.createIndex("k4Index", IndexType.FUNCTIONAL, "pf", "/portfolios.getKeys.asList pf");
// Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
// "pf","/portfolios.getKeys.asList() pf");
Index i6 = qs.createIndex("k5Index", IndexType.FUNCTIONAL, "pf", "/portfolios.getKeys.asSet() pf");
// Index i5 = qs.createIndex("k5Index", IndexType.FUNCTIONAL,
// "pf","/portfolios.getKeys.asSet pf");
CacheUtils.log(((CompactRangeIndex) i1).dump());
CacheUtils.log(((CompactRangeIndex) i2).dump());
CacheUtils.log(((CompactRangeIndex) i3).dump());
CacheUtils.log(((CompactRangeIndex) i5).dump());
CacheUtils.log(((CompactRangeIndex) i6).dump());
}
use of org.apache.geode.cache.query.internal.index.CompactRangeIndex in project geode by apache.
the class IndexCreationJUnitTest method testIndexCreationOnRegionEntry.
@Test
public void testIndexCreationOnRegionEntry() throws Exception {
// Task ID : ICM11
QueryService qs;
qs = CacheUtils.getQueryService();
Index i1 = qs.createIndex("r1Index", IndexType.FUNCTIONAL, "secId", "/portfolios.values['1'].positions.values");
qs.createIndex("r12Index", IndexType.FUNCTIONAL, "secId", "/portfolios['1'].positions.values");
CacheUtils.log(((CompactRangeIndex) i1).dump());
// CacheUtils.log(((RangeIndex)i2).dump());
}
Aggregations