use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method createData.
private void createData(Region region, int numEntries) {
for (int i = 0; i < numEntries; i++) {
Portfolio p = new Portfolio(i);
region.put("" + i, p);
}
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method testHashIndexOnNonSequentialHashForReplicatedRegion.
/**
* Tests that hash index on non sequential hashes for replicated region
*
* @throws Exception
*/
@Test
public void testHashIndexOnNonSequentialHashForReplicatedRegion() throws Exception {
createReplicatedRegion("portfolios");
for (int i = 0; i < 100; i++) {
Portfolio p = new Portfolio(i);
p.shortID = (short) i;
region.put("" + i, p);
}
for (int i = 200; i < 300; i++) {
Portfolio p = new Portfolio(i);
p.shortID = (short) i;
region.put("" + i, p);
}
for (int i = 500; i < 600; i++) {
Portfolio p = new Portfolio(i);
p.shortID = (short) i;
region.put("" + i, p);
}
helpTestHashIndexForQuery("Select * FROM /portfolios p where p.ID != 1");
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method testHashIndexWithORQueryForLocalRegion.
/**
* Tests that hash index with And query for local region
*
* @throws Exception
*/
@Test
public void testHashIndexWithORQueryForLocalRegion() throws Exception {
createLocalRegion("portfolios");
int numEntries = 200;
int numIds = 100;
for (int i = 0; i < numEntries; i++) {
Portfolio p = new Portfolio(i % (numIds));
p.shortID = (short) i;
region.put("" + i, p);
}
helpTestHashIndexForQuery("SELECT * FROM /portfolios p WHERE p.ID = 1 OR p.ID = 2", "p.ID", "/portfolios p");
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method helpTestHashIndexRemoveFromCommonKeyQuery.
private void helpTestHashIndexRemoveFromCommonKeyQuery() throws Exception {
int numEntries = 200;
int numIds = 100;
for (int i = 0; i < numEntries; i++) {
Portfolio p = new Portfolio(i % (numIds));
p.shortID = (short) i;
region.put("" + i, p);
}
Portfolio p2 = new Portfolio(10000);
region.put("2", p2);
p2.ID = 1000;
region.put("2", p2);
SelectResults noIndexResult = (SelectResults) qs.newQuery("Select * FROM /portfolios p where p.ID = 2").execute();
region.clear();
index = (HashIndex) qs.createHashIndex("idHash", "p.ID", "/portfolios p");
for (int i = 0; i < numEntries; i++) {
Portfolio p = new Portfolio(i % (numIds));
p.shortID = (short) i;
region.put("" + i, p);
}
p2 = new Portfolio(10000);
region.put("2", p2);
p2.ID = 1000;
region.put("2", p2);
SelectResults results = (SelectResults) qs.newQuery("Select * FROM /portfolios p where p.ID = 2").execute();
assertEquals(numEntries / numIds - 1, results.size());
assertEquals(noIndexResult.size(), results.size());
assertTrue(observer.indexUsed);
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method testHashIndexEqualsForMultipleResultQueryOnReplicatedRegion.
/**
* Tests that hash index is used and that it returns the correct number of results on replicated
* region
*
* @throws Exception
*/
@Test
public void testHashIndexEqualsForMultipleResultQueryOnReplicatedRegion() throws Exception {
createReplicatedRegion("portfolios");
// Create the data
int numEntries = 200;
int numIds = 100;
for (int i = 0; i < numEntries; i++) {
Portfolio p = new Portfolio(i % (numIds));
p.shortID = (short) i;
region.put("" + i, p);
}
helpTestHashIndexForQuery("Select * FROM /portfolios p where p.ID = 1");
}
Aggregations