use of org.apache.ignite.util.GridCommandHandlerIndexingUtils.Organization in project ignite by apache.
the class GridCommandHandlerIndexingCheckSizeTest method queryEntities.
/**
* Creating {@link QueryEntity}'s with filling functions.
*
* @return {@link QueryEntity}'s with filling functions.
*/
private Map<QueryEntity, Function<Random, Object>> queryEntities() {
Map<QueryEntity, Function<Random, Object>> qryEntities = new HashMap<>();
qryEntities.put(personEntity(), rand -> new Person(rand.nextInt(), valueOf(rand.nextLong())));
qryEntities.put(organizationEntity(), rand -> new Organization(rand.nextInt(), valueOf(rand.nextLong())));
return qryEntities;
}
use of org.apache.ignite.util.GridCommandHandlerIndexingUtils.Organization in project ignite by apache.
the class GridCommandHandlerIndexingCheckSizeTest method addColumnAndIdx.
/**
* Adding the "address" column and index for {@link Person} and
* {@link Organization}, with new entries added for each of them.
*
* @param node Node.
* @param cacheName Cache name.
* @param addCnt How many entries add to table.
*/
private void addColumnAndIdx(IgniteEx node, String cacheName, int addCnt) {
IgniteCache<Object, Object> cache = node.cache(cacheName);
cache.query(new SqlFieldsQuery("alter table Person add column orgAddr varchar")).getAll();
cache.query(new SqlFieldsQuery("alter table Organization add column addr varchar")).getAll();
cache.query(new SqlFieldsQuery("create index p_o_addr on Person (orgAddr)")).getAll();
cache.query(new SqlFieldsQuery("create index o_addr on Organization (addr)")).getAll();
int key = node.cachex(cacheName).size();
try (IgniteDataStreamer<Object, Object> streamer = node.dataStreamer(cacheName)) {
ThreadLocalRandom rand = ThreadLocalRandom.current();
for (int i = 0; i < addCnt; i++) {
streamer.addData(key++, new Person(rand.nextInt(), valueOf(rand.nextLong())).orgAddr(valueOf(rand.nextLong())));
streamer.addData(key++, new Organization(rand.nextInt(), valueOf(rand.nextLong())).addr(valueOf(rand.nextLong())));
}
streamer.flush();
}
}
Aggregations