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);
}
}
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;
}
use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.
the class DefaultQueryCache method setInternal.
/**
* @param doEvictionCheck when doing pre-population of query cache, set
* this to false since we quit population if we reach max capacity {@link
* #reachedMaxCapacity()}, eviction is not needed.
*/
private void setInternal(K key, V value, EntryEventType eventType, boolean doEvictionCheck) {
Object queryCacheKey = recordStore.toQueryCacheKey(key);
Data valueData = toData(value);
QueryCacheRecord oldRecord = doEvictionCheck ? recordStore.add(queryCacheKey, valueData) : recordStore.addWithoutEvictionCheck(queryCacheKey, valueData);
if (eventType != null) {
publishEntryEvent(context, mapName, cacheId, queryCacheKey, valueData, oldRecord, eventType, extractors);
}
}
use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.
the class AbstractInternalQueryCache method scanWithPredicate.
/**
* Scan all key-value pairs and add matching ones with predicate to result.
*/
private void scanWithPredicate(Predicate predicate, BiConsumer consumer) {
// needed for optimization where key and value are not an instance of Data type
final boolean areKeyValueObjectType = !queryCacheConfig.isSerializeKeys() && InMemoryFormat.OBJECT == queryCacheConfig.getInMemoryFormat();
CachedQueryEntry queryEntry = new CachedQueryEntry(ss, extractors);
Set<Map.Entry<Object, QueryCacheRecord>> entries = recordStore.entrySet();
for (Map.Entry<Object, QueryCacheRecord> entry : entries) {
Object queryCacheKey = entry.getKey();
Object rawValue = entry.getValue().getRawValue();
if (areKeyValueObjectType) {
queryEntry.initWithObjectKeyValue(queryCacheKey, rawValue);
} else {
queryEntry.init(queryCacheKey, rawValue);
}
if (!predicate.apply(queryEntry)) {
continue;
}
consumer.accept(queryCacheKey, queryEntry.getByPrioritizingObjectValue());
}
}
use of com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord in project hazelcast by hazelcast.
the class DefaultQueryCacheRecordStore method addWithoutEvictionCheck.
@Override
public QueryCacheRecord addWithoutEvictionCheck(Object queryCacheKey, Data valueData) {
QueryCacheRecord newRecord = recordFactory.createRecord(valueData);
QueryCacheRecord oldRecord = cache.put(queryCacheKey, newRecord);
saveIndex(queryCacheKey, newRecord, oldRecord);
return oldRecord;
}
Aggregations