use of com.hazelcast.query.Predicate in project hazelcast-jet by hazelcast.
the class GenericPredicatesTest method testAnd.
@Test
public void testAnd() {
final Predicate and1 = and(greaterThan(ATTRIBUTE, 4), lessThan(ATTRIBUTE, 6));
assertPredicateTrue(and1, 5);
final Predicate and2 = and(greaterThan(ATTRIBUTE, 5), lessThan(ATTRIBUTE, 6));
assertPredicateFalse(and2, 4);
}
use of com.hazelcast.query.Predicate in project hazelcast-jet by hazelcast.
the class GenericPredicatesTest method testOr.
@Test
public void testOr() {
final Predicate or1 = or(equal(ATTRIBUTE, 3), equal(ATTRIBUTE, 4), equal(ATTRIBUTE, 5));
assertPredicateTrue(or1, 4);
assertPredicateFalse(or1, 6);
}
use of com.hazelcast.query.Predicate in project hazelcast-jet by hazelcast.
the class SnapshotRepository method deleteAllSnapshots.
/**
* Delete all snapshots for a given job
*/
void deleteAllSnapshots(long jobId) {
final IMapJet<Long, SnapshotRecord> snapshotMap = getSnapshotMap(jobId);
Predicate predicate = e -> !e.getKey().equals(LATEST_STARTED_SNAPSHOT_ID_KEY);
for (Entry<Long, SnapshotRecord> entry : snapshotMap.entrySet(predicate)) {
deleteSnapshotData(entry.getValue());
}
logFine(logger, "Deleted all snapshots for job %s", idToString(jobId));
snapshotMap.destroy();
}
use of com.hazelcast.query.Predicate in project jnosql-diana-driver by eclipse.
the class HazelcastBucketManagerQueryTest method shouldReturnActiveAndGreaterThan2000Predicate.
@Test
public void shouldReturnActiveAndGreaterThan2000Predicate() {
Predicate predicate = and(equal("active", false), greaterEqual("year", 1990));
Collection<Value> result = bucketManager.query(predicate);
assertEquals(2, result.size());
}
use of com.hazelcast.query.Predicate in project providence by morimekta.
the class HazelcastMessageBuilderStorageTest method testQueries.
@Test
public void testQueries() {
// To ensure that the messages are stored in an indexable way, we add an index to query it directly.
IMap<String, OptionalFields._Builder> map = instance.getMap(getClass().getName() + "_queries");
HazelcastMessageBuilderStorage<String, OptionalFields, OptionalFields._Field, OptionalFields._Builder> storage = new HazelcastMessageBuilderStorage<>(map);
map.addIndex(OptionalFields._Field.INTEGER_VALUE.getName(), true);
for (int i = 0; i < 100; ++i) {
storage.put(UUID.randomUUID().toString(), generator.generate(OptionalFields.kDescriptor));
}
generator.withGenerator(OptionalFields.kDescriptor, gen -> {
gen.setAlwaysPresent(OptionalFields._Field.INTEGER_VALUE);
});
String theId = UUID.randomUUID().toString();
OptionalFields toSearchFor = generator.generate(OptionalFields.kDescriptor);
storage.put(theId, toSearchFor);
EntryObject eo = new PredicateBuilder().getEntryObject();
Predicate q = eo.get(OptionalFields._Field.INTEGER_VALUE.getName()).equal(toSearchFor.getIntegerValue());
Set<Map.Entry<String, OptionalFields._Builder>> res = map.entrySet(q);
// There is a 100 / 2 p 32 chance of collision.
assertThat(res, hasSize(1));
AtomicReference<String> id = new AtomicReference<>();
AtomicReference<OptionalFields> value = new AtomicReference<>();
res.forEach(e -> {
id.set(e.getKey());
value.set(e.getValue().build());
});
assertThat(id.get(), is(theId));
assertThat(value.get(), is(toSearchFor));
}
Aggregations