Search in sources :

Example 6 with QueryCacheRecord

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

the class AbstractInternalQueryCache method doFullKeyScan.

protected void doFullKeyScan(Predicate predicate, Set<K> 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) {
            resultingSet.add((K) queryEntry.getKey());
        }
    }
}
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 7 with QueryCacheRecord

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

the class DefaultQueryCacheRecordStore method add.

@Override
public QueryCacheRecord add(Data keyData, Data valueData) {
    evictionOperator.evictIfRequired();
    QueryCacheRecord entry = recordFactory.createEntry(keyData, valueData);
    QueryCacheRecord oldEntry = cache.put(keyData, entry);
    saveIndex(keyData, entry, oldEntry);
    return oldEntry;
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)

Example 8 with QueryCacheRecord

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

the class DefaultQueryCache method addIndex.

@Override
public void addIndex(String attribute, boolean ordered) {
    getIndexes().addOrGetIndex(attribute, ordered);
    InternalSerializationService serializationService = context.getSerializationService();
    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 queryable = new QueryEntry(serializationService, keyData, value, Extractors.empty());
        indexes.saveEntryIndex(queryable, null);
    }
}
Also used : QueryEntry(com.hazelcast.query.impl.QueryEntry) QueryEntry(com.hazelcast.query.impl.QueryEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap)

Example 9 with QueryCacheRecord

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

the class DefaultQueryCache method setInternal.

@Override
public void setInternal(K key, V value, boolean callDelegate, EntryEventType eventType) {
    Data keyData = toData(key);
    Data valueData = toData(value);
    if (callDelegate) {
        getDelegate().set(keyData, valueData);
    }
    QueryCacheRecord oldRecord = recordStore.add(keyData, valueData);
    if (eventType != null) {
        EventPublisherHelper.publishEntryEvent(context, mapName, cacheName, keyData, valueData, oldRecord, eventType);
    }
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data)

Example 10 with QueryCacheRecord

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

the class DefaultQueryCacheRecordStore method clear.

@Override
public int clear() {
    int removeCount = 0;
    Set<Data> dataKeys = keySet();
    for (Data dataKey : dataKeys) {
        QueryCacheRecord oldRecord = remove(dataKey);
        if (oldRecord != null) {
            removeCount++;
        }
    }
    return removeCount;
}
Also used : QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data)

Aggregations

QueryCacheRecord (com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)10 Data (com.hazelcast.nio.serialization.Data)9 IMap (com.hazelcast.core.IMap)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)4 Map (java.util.Map)4 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)3 AbstractMap (java.util.AbstractMap)3 QueryEntry (com.hazelcast.query.impl.QueryEntry)1 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1