use of org.infinispan.query.core.impl.eventfilter.IckleFilterAndConverter in project infinispan by infinispan.
the class QueryEngine method createAndWireFilter.
protected final IckleFilterAndConverter createAndWireFilter(String queryString, Map<String, Object> namedParameters) {
IckleFilterAndConverter filter = createFilter(queryString, namedParameters);
SecurityActions.getCacheComponentRegistry(cache).wireDependencies(filter);
return filter;
}
use of org.infinispan.query.core.impl.eventfilter.IckleFilterAndConverter in project infinispan by infinispan.
the class IckleFilterAndConverterDistTest method testFilter.
@Test
public void testFilter() {
final boolean isClustered = cache(0).getCacheConfiguration().clustering().cacheMode().isClustered();
for (int i = 0; i < 10; ++i) {
Person value = new Person();
value.setName("John");
value.setAge(i + 30);
Cache<Object, Person> cache = cache(i % numNodes);
Object key = isClustered ? new MagicKey(cache) : i;
cache.put(key, value);
}
IckleFilterAndConverter filterAndConverter = new IckleFilterAndConverter<Object, Person>("from org.infinispan.query.test.Person where blurb is null and age <= 31", null, ReflectionMatcher.class);
Stream<CacheEntry<Object, Object>> stream = cache(0).getAdvancedCache().cacheEntrySet().stream();
CloseableIterator<Map.Entry<Object, ObjectFilter.FilterResult>> iterator = Closeables.iterator(CacheFilters.filterAndConvert(stream, filterAndConverter).iterator());
Map<Object, ObjectFilter.FilterResult> results = mapFromIterator(iterator);
assertEquals(2, results.size());
for (ObjectFilter.FilterResult p : results.values()) {
assertNull(((Person) p.getInstance()).getBlurb());
assertTrue(((Person) p.getInstance()).getAge() <= 31);
}
}
Aggregations