Search in sources :

Example 1 with Employee

use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.

the class MapPredicateTest method pagePredicate.

@TimeStep(prob = 0.2)
public void pagePredicate(ThreadState state) {
    double maxSalary = state.randomDouble() * Employee.MAX_SALARY;
    Predicate predicate = Predicates.lessThan("salary", maxSalary);
    SalaryComparator salaryComparator = new SalaryComparator();
    PagingPredicate pagingPredicate = new PagingPredicate(predicate, salaryComparator, pageSize);
    Collection<Employee> employees;
    List<Employee> employeeList;
    do {
        employees = map.values(pagingPredicate);
        employeeList = fillListWithQueryResultSet(employees);
        Employee nextEmployee;
        Employee currentEmployee;
        for (int i = 0; i < employeeList.size() - 1; i++) {
            currentEmployee = employeeList.get(i);
            nextEmployee = employeeList.get(i + 1);
            // check the order & max salary
            assertTrue(format(baseAssertMessage, currentEmployee.getSalary(), predicate), currentEmployee.getSalary() <= nextEmployee.getSalary() && nextEmployee.getSalary() < maxSalary);
        }
        pagingPredicate.nextPage();
    } while (!employees.isEmpty());
    state.operationCounter.pagePredicateCount++;
}
Also used : PagingPredicate(com.hazelcast.query.PagingPredicate) Employee(com.hazelcast.simulator.tests.map.helpers.Employee) SqlPredicate(com.hazelcast.query.SqlPredicate) PagingPredicate(com.hazelcast.query.PagingPredicate) Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 2 with Employee

use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.

the class MapPredicateTest method initMap.

private void initMap() {
    Streamer<Integer, Employee> streamer = StreamerFactory.getInstance(map);
    for (int i = 0; i < keyCount; i++) {
        Employee employee = new Employee(i);
        streamer.pushEntry(employee.getId(), employee);
    }
    streamer.await();
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee)

Example 3 with Employee

use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.

the class MapPredicateTest method predicateBuilder.

@TimeStep(prob = 0.2)
public void predicateBuilder(ThreadState state) {
    long startMs = System.currentTimeMillis();
    int age = state.randomInt(Employee.MAX_AGE);
    String name = Employee.getRandomName();
    // TODO: Still broken because it relies on reflection which is dog slow, so we need an explicit AgeNamePredicate
    EntryObject entryObject = new PredicateBuilder().getEntryObject();
    Predicate agePredicate = entryObject.get("age").lessThan(age);
    Predicate ageNamePredicate = entryObject.get("name").equal(name).and(agePredicate);
    Collection<Employee> employees = map.values(ageNamePredicate);
    for (Employee emp : employees) {
        String assertMessage = format(baseAssertMessage, emp, ageNamePredicate);
        assertTrue(assertMessage, emp.getAge() < age);
        assertTrue(assertMessage, emp.getName().equals(name));
    }
    state.operationCounter.predicateBuilderCount++;
    updateStats(state, startMs);
}
Also used : EntryObject(com.hazelcast.query.EntryObject) Employee(com.hazelcast.simulator.tests.map.helpers.Employee) PredicateBuilder(com.hazelcast.query.PredicateBuilder) SqlPredicate(com.hazelcast.query.SqlPredicate) PagingPredicate(com.hazelcast.query.PagingPredicate) Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 4 with Employee

use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.

the class MapReduceTest method modifyMapEntry.

@TimeStep(prob = 0.25)
public void modifyMapEntry(ThreadState state) {
    Employee employee = map.get(state.randomInt(keyCount));
    employee.randomizeProperties();
    map.put(employee.getId(), employee);
    state.operationCounter.modifyMapEntry++;
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 5 with Employee

use of com.hazelcast.simulator.tests.map.helpers.Employee in project hazelcast-simulator by hazelcast.

the class PagingPredicateTest method globalPrepare.

@Prepare(global = true)
public void globalPrepare() {
    if (useIndex) {
        map.addIndex("salary", true);
    }
    Streamer<Integer, Employee> streamer = StreamerFactory.getInstance(map);
    for (int i = 0; i < keyCount; i++) {
        Employee employee = new Employee(i);
        streamer.pushEntry(employee.getId(), employee);
    }
    streamer.await();
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

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