private void initMap() { MapStreamer<Integer, Employee> streamer = MapStreamerFactory.getInstance(map); for (int i = 0; i < keyCount; i++) { Employee employee = new Employee(i); streamer.pushEntry(employee.getId(), employee); } streamer.await(); }
private void updateEmployee() { Integer key = randomInt(keyCount); Employee employee = map.get(key); if (employee != null) { employee.randomizeProperties(); map.put(key, employee); operationCounter.updateEmployeeCount++; } }
private void sqlString() { boolean active = getRandom().nextBoolean(); int age = randomInt(Employee.MAX_AGE); SqlPredicate predicate = new SqlPredicate("active=" + active + " AND age >" + age); Collection<Employee> employees = map.values(predicate); for (Employee emp : employees) { assertTrue(basename + ": " + emp + " not matching " + predicate, emp.isActive() == active); assertTrue(basename + ": " + emp + " not matching " + predicate, emp.getAge() > age); } operationCounter.sqlStringCount++; }
private void pagingPredicate() { double maxSal = getRandom().nextDouble() * Employee.MAX_SALARY; Predicate predicate = Predicates.lessThan("salary", maxSal); PagingPredicate pagingPredicate = new PagingPredicate(predicate, pageSize); Collection<Employee> employees; do { employees = map.values(pagingPredicate); for (Employee emp : employees) { assertTrue( basename + ": " + emp + " not matching " + predicate, emp.getSalary() < maxSal); } pagingPredicate.nextPage(); } while (!employees.isEmpty()); operationCounter.pagePredicateCount++; }
private void predicateBuilder() { int age = 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) { assertTrue(basename + ": " + emp + " not matching " + ageNamePredicate, emp.getAge() < age); assertTrue( basename + ": " + emp + " not matching " + ageNamePredicate, emp.getName().equals(name)); } operationCounter.predicateBuilderCount++; }