use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method testQueryDuringAndAfterMigration.
@Test(timeout = MINUTE)
public void testQueryDuringAndAfterMigration() {
HazelcastInstance instance = nodeFactory.newHazelcastInstance(getTestConfig());
int count = 500;
IMap<String, Employee> map = instance.getMap("employees");
for (int i = 0; i < count; i++) {
map.put(String.valueOf(i), new Employee("joe" + i, i % 60, ((i & 1) == 1), (double) i));
}
nodeFactory.newInstances(getTestConfig(), 3);
final IMap<String, Employee> employees = instance.getMap("employees");
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
Collection<Employee> values = employees.values(Predicates.sql("active and name LIKE 'joe15%'"));
for (Employee employee : values) {
assertTrue(employee.isActive());
}
assertEquals(6, values.size());
}
}, 3);
}
use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method testQueryDuringAndAfterMigrationWithIndex.
@Test
public void testQueryDuringAndAfterMigrationWithIndex() {
Config config = getTestConfig();
HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
IMap<String, Employee> map = instance.getMap("employees");
map.addIndex(IndexType.HASH, "name");
map.addIndex(IndexType.HASH, "active");
int size = 500;
for (int i = 0; i < size; i++) {
map.put(String.valueOf(i), new Employee("joe" + i, i % 60, ((i & 1) == 1), (double) i));
}
nodeFactory.newInstances(config, 3);
final IMap<String, Employee> employees = instance.getMap("employees");
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
Collection<Employee> values = employees.values(Predicates.sql("active and name LIKE 'joe15%'"));
for (Employee employee : values) {
assertTrue(employee.isActive() && employee.getName().startsWith("joe15"));
}
assertEquals(6, values.size());
}
}, 3);
}
use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method testQueryWithIndexesWhileMigrating.
@Test
public void testQueryWithIndexesWhileMigrating() {
HazelcastInstance instance = nodeFactory.newHazelcastInstance(getTestConfig());
IMap<String, Employee> map = instance.getMap("employees");
map.addIndex(IndexType.SORTED, "age");
map.addIndex(IndexType.HASH, "active");
for (int i = 0; i < 500; i++) {
map.put("e" + i, new Employee("name" + i, i % 50, ((i & 1) == 1), (double) i));
}
assertEquals(500, map.size());
Set<Map.Entry<String, Employee>> entries = map.entrySet(Predicates.sql("active=true and age>44"));
assertEquals(30, entries.size());
nodeFactory.newInstances(getTestConfig(), 3);
long startNow = Clock.currentTimeMillis();
while ((Clock.currentTimeMillis() - startNow) < 10000) {
entries = map.entrySet(Predicates.sql("active=true and age>44"));
assertEquals(30, entries.size());
}
}
use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class QueryIndexingTest method assertFieldsAreNull.
private static void assertFieldsAreNull(Collection<Employee> matchingEmployees) {
for (Employee employee : matchingEmployees) {
assertNull("city", employee.getCity());
assertNull("name", employee.getName());
}
}
use of com.hazelcast.query.SampleTestObjects.Employee in project hazelcast by hazelcast.
the class QueryBasicTest method testMultipleOrPredicatesIssue885WithDoubleIndex.
@Test(timeout = 1000 * 90)
public void testMultipleOrPredicatesIssue885WithDoubleIndex() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance = factory.newHazelcastInstance(getConfig());
factory.newHazelcastInstance(getConfig());
IMap<Integer, Employee> map = instance.getMap("default");
map.addIndex(IndexType.SORTED, "name");
map.addIndex(IndexType.SORTED, "city");
testMultipleOrPredicates(map);
}
Aggregations