Search in sources :

Example 1 with QueryCacheRecord

use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.

the class AbstractInternalQueryCache method doFullValueScan.

protected void doFullValueScan(Predicate predicate, Set<V> resultingSet) {
    InternalSerializationService serializationService = this.serializationService;
    CachedQueryEntry queryEntry = new CachedQueryEntry();
    Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
    for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
        Data keyData = entry.getKey();
        QueryCacheRecord record = entry.getValue();
        Object value = record.getValue();
        queryEntry.init(serializationService, keyData, value, Extractors.empty());
        boolean valid = predicate.apply(queryEntry);
        if (valid) {
            Object valueObject = queryEntry.getValue();
            resultingSet.add((V) valueObject);
        }
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) AbstractMap(java.util.AbstractMap) IMap(com.hazelcast.core.IMap) Map(java.util.Map)

Example 2 with QueryCacheRecord

use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.

the class AbstractInternalQueryCache method doFullEntryScan.

protected void doFullEntryScan(Predicate predicate, Set<Map.Entry<K, V>> resultingSet) {
    InternalSerializationService serializationService = this.serializationService;
    CachedQueryEntry queryEntry = new CachedQueryEntry();
    Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
    for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
        Data keyData = entry.getKey();
        QueryCacheRecord record = entry.getValue();
        Object value = record.getValue();
        queryEntry.init(serializationService, keyData, value, Extractors.empty());
        boolean valid = predicate.apply(queryEntry);
        if (valid) {
            Object keyObject = queryEntry.getKey();
            Object valueObject = queryEntry.getValue();
            Map.Entry simpleEntry = new AbstractMap.SimpleEntry(keyObject, valueObject);
            resultingSet.add(simpleEntry);
        }
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) AbstractMap(java.util.AbstractMap) IMap(com.hazelcast.core.IMap) Map(java.util.Map)

Example 3 with QueryCacheRecord

use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.

the class DefaultQueryCache method deleteInternal.

@Override
public void deleteInternal(Object key, boolean callDelegate, EntryEventType eventType) {
    checkNotNull(key, "key cannot be null");
    Data keyData = toData(key);
    if (callDelegate) {
        getDelegate().delete(keyData);
    }
    QueryCacheRecord oldRecord = recordStore.remove(keyData);
    if (oldRecord == null) {
        return;
    }
    if (eventType != null) {
        EventPublisherHelper.publishEntryEvent(context, mapName, cacheName, keyData, null, oldRecord, eventType);
    }
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data)

Example 4 with QueryCacheRecord

use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.

the class DefaultQueryCache method delete.

@Override
public void delete(Object key, EntryEventType eventType) {
    checkNotNull(key, "key cannot be null");
    Object queryCacheKey = recordStore.toQueryCacheKey(key);
    QueryCacheRecord oldRecord = recordStore.remove(queryCacheKey);
    if (oldRecord == null) {
        return;
    }
    if (eventType != null) {
        publishEntryEvent(context, mapName, cacheId, queryCacheKey, null, oldRecord, eventType, extractors);
    }
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)

Example 5 with QueryCacheRecord

use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.

the class DefaultQueryCache method getAll.

@Override
public Map<K, V> getAll(Set<K> keys) {
    checkNotNull(keys, "keys cannot be null");
    checkNoNullInside(keys, "supplied key-set cannot contain null key");
    if (keys.isEmpty()) {
        return Collections.emptyMap();
    }
    if (!includeValue) {
        return getDelegate().getAll(keys);
    }
    Map<K, V> map = MapUtil.createHashMap(keys.size());
    for (K key : keys) {
        Object queryCacheKey = recordStore.toQueryCacheKey(key);
        QueryCacheRecord record = recordStore.get(queryCacheKey);
        if (record != null) {
            V value = toObject(record.getValue());
            map.put(key, value);
        }
    }
    return map;
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)

Aggregations

QueryCacheRecord (com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)16 Map (java.util.Map)7 Data (com.hazelcast.nio.serialization.Data)6 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)6 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)5 IMap (com.hazelcast.core.IMap)4 Data (com.hazelcast.internal.serialization.Data)3 AbstractMap (java.util.AbstractMap)3 IMap (com.hazelcast.map.IMap)2 QueryEntry (com.hazelcast.query.impl.QueryEntry)2 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 IndexConfig (com.hazelcast.config.IndexConfig)1