Search in sources :

Example 6 with QueryEntry

use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.

the class ReplicatedMapEventPublishingService method shouldPublish.

private boolean shouldPublish(Data key, Data oldValue, Data value, EntryEventType eventType, EventFilter filter) {
    QueryEntry queryEntry = null;
    if (filter instanceof ReplicatedQueryEventFilter) {
        Data testValue;
        if (eventType == REMOVED) {
            testValue = oldValue;
        } else {
            testValue = value;
        }
        queryEntry = new QueryEntry(serializationService, key, testValue, extractors);
    }
    return filter == null || filter.eval(queryEntry != null ? queryEntry : key);
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) QueryEntry(com.hazelcast.query.impl.QueryEntry) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) MapEventData(com.hazelcast.map.impl.event.MapEventData)

Example 7 with QueryEntry

use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.

the class NodeQueryCacheEventService method canPassFilter.

private boolean canPassFilter(LocalEntryEventData localEntryEventData, EventFilter filter, Extractors extractors) {
    if (filter == null || filter instanceof TrueEventFilter) {
        return true;
    }
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    SerializationService serializationService = nodeEngine.getSerializationService();
    Data keyData = localEntryEventData.getKeyData();
    Object value = getValueOrOldValue(localEntryEventData);
    QueryableEntry entry = new QueryEntry(serializationService, keyData, value, extractors);
    return filter.eval(entry);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) QueryEntry(com.hazelcast.query.impl.QueryEntry) SerializationService(com.hazelcast.internal.serialization.SerializationService) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 8 with QueryEntry

use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.

the class DefaultQueryCacheRecordStore method saveIndex.

/**
 * Same as {@link #saveIndex}
 * with explicit {@link CachedQueryEntry} arguments for reuse, to avoid
 * excessive litter when adding several entries in batch.
 */
private void saveIndex(Data keyData, QueryCacheRecord currentRecord, QueryCacheRecord oldRecord, CachedQueryEntry newEntry, CachedQueryEntry oldEntry) {
    if (indexes.haveAtLeastOneIndex()) {
        Object currentValue = currentRecord.getValue();
        QueryEntry queryEntry = new QueryEntry(ss, keyData, currentValue, extractors);
        Object oldValue = oldRecord == null ? null : oldRecord.getValue();
        newEntry.init(keyData, currentValue);
        oldEntry.init(keyData, oldValue);
        indexes.putEntry(newEntry, oldEntry, queryEntry, Index.OperationSource.USER);
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryEntry(com.hazelcast.query.impl.QueryEntry)

Example 9 with QueryEntry

use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.

the class DefaultQueryCacheRecordStore method saveIndex.

private void saveIndex(Object queryCacheKey, QueryCacheRecord currentRecord, QueryCacheRecord oldRecord) {
    if (indexes.haveAtLeastOneIndex()) {
        Data keyData = ss.toData(queryCacheKey);
        Object currentValue = currentRecord.getValue();
        QueryEntry queryEntry = new QueryEntry(ss, keyData, currentValue, extractors);
        Object oldValue = oldRecord == null ? null : oldRecord.getValue();
        CachedQueryEntry newEntry = new CachedQueryEntry(ss, keyData, currentValue, extractors);
        CachedQueryEntry oldEntry = new CachedQueryEntry(ss, keyData, oldValue, extractors);
        indexes.putEntry(newEntry, oldEntry, queryEntry, Index.OperationSource.USER);
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryEntry(com.hazelcast.query.impl.QueryEntry) Data(com.hazelcast.internal.serialization.Data) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry)

Example 10 with QueryEntry

use of com.hazelcast.query.impl.QueryEntry in project hazelcast by hazelcast.

the class ClientQueryCacheEventService method canPassFilter.

private boolean canPassFilter(Object eventData, EventFilter filter, Extractors extractors) {
    if (filter == null || filter instanceof TrueEventFilter) {
        return true;
    }
    if (!(eventData instanceof LocalEntryEventData)) {
        return true;
    }
    LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventData;
    if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
        Object value = getValueOrOldValue(localEntryEventData);
        Data keyData = localEntryEventData.getKeyData();
        QueryEntry entry = new QueryEntry(serializationService, keyData, value, extractors);
        return filter.eval(entry);
    }
    return true;
}
Also used : QueryEntry(com.hazelcast.query.impl.QueryEntry) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData) BatchEventData(com.hazelcast.map.impl.querycache.event.BatchEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)

Aggregations

QueryEntry (com.hazelcast.query.impl.QueryEntry)11 Data (com.hazelcast.internal.serialization.Data)5 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)4 EventData (com.hazelcast.map.impl.event.EventData)4 Map (java.util.Map)4 LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)3 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)3 IMap (com.hazelcast.core.IMap)2 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)2 QueryCacheRecord (com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)2 Data (com.hazelcast.nio.serialization.Data)2 ArrayList (java.util.ArrayList)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 IndexConfig (com.hazelcast.config.IndexConfig)1 SerializationService (com.hazelcast.internal.serialization.SerializationService)1 IMap (com.hazelcast.map.IMap)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 MapEventData (com.hazelcast.map.impl.event.MapEventData)1