use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class MapTransactionTest method testValues_shouldNotDeduplicateEntriesWhenGettingByPredicate.
@Test
public void testValues_shouldNotDeduplicateEntriesWhenGettingByPredicate() throws TransactionException {
final int nodeCount = 1;
final String mapName = randomMapName();
final Config config = getConfig();
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
final HazelcastInstance node = factory.newHazelcastInstance(config);
final IMap map = node.getMap(mapName);
final Employee emp = new Employee("name", 77, true, 10D);
map.put(1, emp);
node.executeTransaction(options, new TransactionalTask<Boolean>() {
public Boolean execute(TransactionalTaskContext context) throws TransactionException {
final TransactionalMap<Integer, Employee> txMap = context.getMap(mapName);
txMap.put(2, emp);
Collection<Employee> coll = txMap.values(Predicates.sql("age = 77"));
assertEquals(2, coll.size());
return true;
}
});
node.shutdown();
}
use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class IndexesTest method testAndWithSingleEntry.
@Test
public void testAndWithSingleEntry() {
Indexes indexes = Indexes.newBuilder(serializationService, copyBehavior, DEFAULT_IN_MEMORY_FORMAT).build();
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.HASH, "name"));
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.SORTED, "age"));
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.SORTED, "salary"));
for (int i = 0; i < 100; i++) {
Employee employee = new Employee(i + "Name", i % 80, (i % 2 == 0), 100 + (i % 1000));
indexes.putEntry(new QueryEntry(serializationService, toData(i), employee, newExtractor()), null, Index.OperationSource.USER);
}
int count = 10;
Set<String> ages = new HashSet<>(count);
for (int i = 0; i < count; i++) {
ages.add(String.valueOf(i));
}
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
PredicateBuilder predicate = entryObject.get("name").equal("0Name").and(entryObject.get("age").in(ages.toArray(new String[0])));
assertEquals(1, size(indexes.query(predicate, SKIP_PARTITIONS_COUNT_CHECK)));
}
Aggregations