use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryBasicTest method testPredicateStringAttribute.
/**
* Github issues 98 and 131
*/
@Test(timeout = 1000 * 90)
public void testPredicateStringAttribute() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<Integer, Value> map = instance.getMap("testPredicateStringWithString");
testPredicateStringAttribute(map);
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryBasicTest method testIndexingEnumAttributeIssue597.
@Test(timeout = 1000 * 90)
public void testIndexingEnumAttributeIssue597() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<Integer, Value> map = instance.getMap("default");
map.addIndex(IndexType.SORTED, "state");
for (int i = 0; i < 4; i++) {
Value v = new Value(i % 2 == 0 ? State.STATE1 : State.STATE2, new ValueType(), i);
map.put(i, v);
}
Predicate predicate = Predicates.newPredicateBuilder().getEntryObject().get("state").equal(State.STATE1);
Collection<Value> values = map.values(predicate);
int[] expectedValues = new int[] { 0, 2 };
assertEquals(expectedValues.length, values.size());
int[] indexes = new int[2];
int index = 0;
for (Value configObject : values) {
indexes[index++] = configObject.getIndex();
}
Arrays.sort(indexes);
assertArrayEquals(indexes, expectedValues);
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method updateMapAndRunQuery.
private void updateMapAndRunQuery(final IMap<Object, Value> map, final int runCount) {
String name = randomString();
Predicate<Object, Value> predicate = equal("name", name);
map.put(name, new Value(name, 0));
// helper call on nodes to sync partitions (see issue github.com/hazelcast/hazelcast/issues/1282)
map.size();
for (int i = 1; i <= runCount && !interrupted(); i++) {
Value value = map.get(name);
value.setIndex(i);
map.put(name, value);
sleepMillis(random.nextInt(100) + 1);
Collection<Value> values = map.values(predicate);
assertEquals(1, values.size());
Value firstValue = IterableUtil.getFirst(values, null);
assertEquals(value, firstValue);
}
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method testIndexCleanupOnMigration.
/**
* test for issue #359
*/
@Test(timeout = 4 * MINUTE)
public void testIndexCleanupOnMigration() throws Exception {
int nodeCount = 6;
final int runCount = 500;
final Config config = newConfigWithIndex("testMap", "name");
executor = Executors.newFixedThreadPool(nodeCount);
List<Future<?>> futures = new ArrayList<Future<?>>();
for (int i = 0; i < nodeCount; i++) {
sleepMillis(random.nextInt((i + 1) * 100) + 10);
futures.add(executor.submit(new Runnable() {
public void run() {
HazelcastInstance hz = nodeFactory.newHazelcastInstance(config);
IMap<Object, Value> map = hz.getMap("testMap");
updateMapAndRunQuery(map, runCount);
}
}));
}
for (Future<?> future : futures) {
future.get();
}
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexMigrationTest method fillMap.
private static void fillMap(IMap<Object, Object> map, final String value, final int count, final int modulo) {
for (int i = 0; i < count; i++) {
String name = randomString();
if (i % modulo == 0) {
name = value;
}
map.put(randomString(), new Value(name, i));
}
}
Aggregations