use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.
the class AbstractFilteringStrategy method evaluateQueryEventFilter.
/**
* Evaluates the {@code filter} using a {@link CachedQueryEntry} together with the
* value {@link Extractors} configured for this map. The filter must be of {@link QueryEventFilter} type.
*
* @param filter a {@link QueryEventFilter} filter
* @param dataKey the entry key
* @param testValue the value used to evaluate the filter
* @param mapNameOrNull the map name. May be null if this is not a map event (e.g. cache event)
* @return {@code true} if the entry matches the query event filter
*/
protected boolean evaluateQueryEventFilter(EventFilter filter, Data dataKey, Object testValue, String mapNameOrNull) {
Extractors extractors = getExtractorsForMapName(mapNameOrNull);
QueryEventFilter queryEventFilter = (QueryEventFilter) filter;
QueryableEntry entry = new CachedQueryEntry(serializationService, dataKey, testValue, extractors);
return queryEventFilter.eval(entry);
}
use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.
the class TransactionalMapProxy method keySet.
@Override
@SuppressWarnings("unchecked")
public Set keySet(Predicate predicate) {
checkTransactionState();
checkNotNull(predicate, "Predicate should not be null!");
checkNotInstanceOf(PagingPredicate.class, predicate, "Paging is not supported for Transactional queries!");
QueryEngine queryEngine = mapServiceContext.getQueryEngine(name);
Query query = Query.of().mapName(name).predicate(predicate).iterationType(IterationType.KEY).build();
QueryResult queryResult = queryEngine.execute(query, Target.ALL_NODES);
Set queryResultSet = QueryResultUtils.transformToSet(ss, queryResult, predicate, IterationType.KEY, true, tx.isOriginatedFromClient());
Extractors extractors = mapServiceContext.getExtractors(name);
Set<Object> returningKeySet = new HashSet<Object>(queryResultSet);
CachedQueryEntry cachedQueryEntry = new CachedQueryEntry();
for (Map.Entry<Data, TxnValueWrapper> entry : txMap.entrySet()) {
if (entry.getValue().type == Type.REMOVED) {
// meanwhile remove keys which are not in txMap
returningKeySet.remove(toObjectIfNeeded(entry.getKey()));
} else {
Data keyData = entry.getKey();
if (predicate == Predicates.alwaysTrue()) {
returningKeySet.add(toObjectIfNeeded(keyData));
} else {
cachedQueryEntry.init(ss, keyData, entry.getValue().value, extractors);
// apply predicate on txMap
if (predicate.apply(cachedQueryEntry)) {
returningKeySet.add(toObjectIfNeeded(keyData));
}
}
}
}
return returningKeySet;
}
use of com.hazelcast.query.impl.getters.Extractors in project hazelcast by hazelcast.
the class IndexImplTest method setUp.
@Before
public void setUp() {
InternalSerializationService mockSerializationService = mock(InternalSerializationService.class);
Extractors mockExtractors = Extractors.newBuilder(mockSerializationService).build();
IndexConfig config = IndexUtils.createTestIndexConfig(IndexType.HASH, ATTRIBUTE_NAME);
index = new IndexImpl(config, mockSerializationService, mockExtractors, IndexCopyBehavior.COPY_ON_READ, PerIndexStats.EMPTY, MemberPartitionStateImpl.DEFAULT_PARTITION_COUNT);
}
Aggregations