Search in sources :

Example 1 with IckleFilterAndConverter

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;
}
Also used : IckleFilterAndConverter(org.infinispan.query.core.impl.eventfilter.IckleFilterAndConverter)

Example 2 with IckleFilterAndConverter

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);
    }
}
Also used : ObjectFilter(org.infinispan.objectfilter.ObjectFilter) CacheEntry(org.infinispan.container.entries.CacheEntry) CacheEntry(org.infinispan.container.entries.CacheEntry) IckleFilterAndConverter(org.infinispan.query.core.impl.eventfilter.IckleFilterAndConverter) Person(org.infinispan.query.test.Person) MagicKey(org.infinispan.distribution.MagicKey) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest) Test(org.testng.annotations.Test)

Aggregations

IckleFilterAndConverter (org.infinispan.query.core.impl.eventfilter.IckleFilterAndConverter)2 CacheEntry (org.infinispan.container.entries.CacheEntry)1 MagicKey (org.infinispan.distribution.MagicKey)1 ObjectFilter (org.infinispan.objectfilter.ObjectFilter)1 Person (org.infinispan.query.test.Person)1 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)1 Test (org.testng.annotations.Test)1