use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexSetJUnitTest method testHashIndexContainsAllShouldReturnFalse.
@Test
public void testHashIndexContainsAllShouldReturnFalse() throws Exception {
int numEntries = 100;
setupHashIndexSet(numEntries);
assertEquals(numEntries, his.size());
portfolioSet.add(new Portfolio(numEntries + 1));
assertFalse(his.containsAll(portfolioSet));
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexSetJUnitTest method testGetByKeyMultipleCollisions.
@Test
public void testGetByKeyMultipleCollisions() throws Exception {
int numEntries = 20;
int keyToLookup = 1;
his = createHashIndexSet();
Map<Integer, Portfolio> collectionOfPorts1 = this.createPortfolioObjects(numEntries, 0);
Map<Integer, Portfolio> collectionOfPorts2 = this.createPortfolioObjects(numEntries, numEntries);
addPortfoliosToHashIndexSet(collectionOfPorts1, his);
addPortfoliosToHashIndexSet(collectionOfPorts2, his);
assertEquals(numEntries * 2, his.size());
Iterator iterator = his.get(keyToLookup);
int numIterated = 0;
while (iterator.hasNext()) {
numIterated++;
// verify that the returned values match what we lookedup
assertEquals(keyToLookup, ((Portfolio) iterator.next()).indexKey);
}
assertEquals(2, numIterated);
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexSetJUnitTest method testHashIndexSetAddWithNullKey.
@Test
public void testHashIndexSetAddWithNullKey() throws Exception {
int numEntries = 100;
setupHashIndexSet(numEntries);
assertEquals(numEntries, his.size());
his.add(null, new Portfolio(numEntries + 1));
assertEquals(numEntries + 1, his.size());
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexSetJUnitTest method createPortfolioObjects.
/**
* we are "indexed" on indexKey. Equality of portfolios is based on ID indexKeys are based on 0 ->
* numEntries IDs are startID -> startID + numEntries
*
* @param numToCreate how many portfolios to create
* @param startID the ID value to start incrementing from
*/
private Map<Integer, Portfolio> createPortfolioObjects(int numToCreate, int startID) {
Map<Integer, Portfolio> portfoliosMap = new HashMap<>();
IntStream.range(0, numToCreate).forEach(e -> {
Portfolio p = new Portfolio(e + startID);
p.indexKey = e;
portfoliosMap.put(p.indexKey, p);
});
return portfoliosMap;
}
use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.
the class HashIndexQueryIntegrationTest method testHashIndexWithAndQueryForLocalRegion.
/**
* Tests that hash index with comparison between float and integer
*
* @throws Exception
*/
// @Test
// public void testHashIndexQueryWithFloatVsIntegerCompareForLocalRegion() throws Exception {
// createLocalRegion("portfolios");
// int numEntries = 1000;
// 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.0f", "p.ID", "/portfolios
// p");
// }
/**
* Tests that hash index with comparison between float and integer
*
* @throws Exception
*/
// @Test
// public void testHashIndexNotEqualsWithFloatVsIntegerLocalRegion() throws Exception {
// createLocalRegion("portfolios");
// int numEntries = 1000;
// int numIds = 100;
// for (int i = 0; i < numEntries; i++) {
// Portfolio p = new Portfolio(i % (numIds));
// p.shortID = (short)i;
// region.put("" + i, p);
// }
// helpTestCRIndexForQuery("SELECT * FROM /portfolios p WHERE p.ID != 1.0f", "p.ID", "/portfolios
// p");
// }
/**
* Tests that hash index with And query for local region
*
* @throws Exception
*/
@Test
public void testHashIndexWithAndQueryForLocalRegion() 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 AND p.shortID > 0", "p.ID", "/portfolios p");
}
Aggregations