Search in sources :

Example 6 with Employee

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);
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee) SqlPredicate(com.hazelcast.query.SqlPredicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 7 with Employee

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++;
    }
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 8 with Employee

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++;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) JobTracker(com.hazelcast.mapreduce.JobTracker) Employee(com.hazelcast.simulator.tests.map.helpers.Employee) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Aggregations

Employee (com.hazelcast.simulator.tests.map.helpers.Employee)8 TimeStep (com.hazelcast.simulator.test.annotations.TimeStep)6 SqlPredicate (com.hazelcast.query.SqlPredicate)3 PagingPredicate (com.hazelcast.query.PagingPredicate)2 Predicate (com.hazelcast.query.Predicate)2 IMap (com.hazelcast.core.IMap)1 JobTracker (com.hazelcast.mapreduce.JobTracker)1 EntryObject (com.hazelcast.query.EntryObject)1 PredicateBuilder (com.hazelcast.query.PredicateBuilder)1 Prepare (com.hazelcast.simulator.test.annotations.Prepare)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1