use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.
the class MapPredicateTest method sqlString.
@TimeStep(prob = 0.2)
public void sqlString(ThreadState state) {
long startMs = System.currentTimeMillis();
boolean active = state.randomBoolean();
int age = state.randomInt(Employee.MAX_AGE);
SqlPredicate predicate = new SqlPredicate("active=" + active + " AND age >" + age);
Collection<Employee> employees = map.values(predicate);
for (Employee emp : employees) {
String assertMessage = format(baseAssertMessage, emp, predicate);
assertTrue(assertMessage, emp.isActive() == active);
assertTrue(assertMessage, emp.getAge() > age);
}
state.operationCounter.sqlStringCount++;
updateStats(state, startMs);
}
use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.
the class MapPredicateTest method updateEmployee.
@TimeStep(prob = 0.3)
public void updateEmployee(ThreadState state) {
Integer key = state.randomInt(keyCount);
Employee employee = map.get(key);
if (employee != null) {
employee.randomizeProperties();
map.put(key, employee);
state.operationCounter.updateEmployeeCount++;
}
}
use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.
the class MapReduceTest method mapReduce.
@TimeStep(prob = 0.5)
public void mapReduce(ThreadState state) throws Exception {
JobTracker tracker = targetInstance.getJobTracker(Thread.currentThread().getName() + name);
KeyValueSource<Integer, Employee> source = KeyValueSource.fromMap(map);
Job<Integer, Employee> job = tracker.newJob(source);
ICompletableFuture<Map<Integer, Set<Employee>>> future = job.mapper(new ModIdMapper(2)).combiner(new RangeIdCombinerFactory(10, 30)).reducer(new IdReducerFactory(10, 20, 30)).submit();
Map<Integer, Set<Employee>> result = future.get();
for (Set<Employee> set : result.values()) {
for (Employee employee : set) {
assertTrue(employee.getId() % 2 == 0);
assertTrue(employee.getId() >= 10 && employee.getId() <= 30);
assertTrue(employee.getId() != 10);
assertTrue(employee.getId() != 20);
assertTrue(employee.getId() != 30);
}
}
state.operationCounter.mapReduce++;
}
Aggregations