Search in sources :

Example 56 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method flush.

/**
     * Flushes evicted records to map store.
     *
     * @param recordsToBeFlushed records to be flushed to map-store.
     * @param backup             <code>true</code> if backup, false otherwise.
     */
protected void flush(Collection<Record> recordsToBeFlushed, boolean backup) {
    Iterator<Record> iterator = recordsToBeFlushed.iterator();
    while (iterator.hasNext()) {
        Record record = iterator.next();
        mapDataStore.flush(record.getKey(), record.getValue(), backup);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 57 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class PartitionScanRunner method run.

@SuppressWarnings("unchecked")
public Collection<QueryableEntry> run(String mapName, Predicate predicate, int partitionId) {
    PagingPredicate pagingPredicate = predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
    List<QueryableEntry> resultList = new LinkedList<QueryableEntry>();
    PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Iterator<Record> iterator = partitionContainer.getRecordStore(mapName).loadAwareIterator(getNow(), false);
    Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(pagingPredicate);
    boolean useCachedValues = isUseCachedDeserializedValuesEnabled(mapContainer);
    Extractors extractors = mapServiceContext.getExtractors(mapName);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data key = (Data) toData(record.getKey());
        Object value = toData(useCachedValues ? Records.getValueOrCachedValue(record, serializationService) : record.getValue());
        if (value == null) {
            continue;
        }
        //we want to always use CachedQueryEntry as these are short-living objects anyway
        QueryableEntry queryEntry = new CachedQueryEntry(serializationService, key, value, extractors);
        if (predicate.apply(queryEntry) && compareAnchor(pagingPredicate, queryEntry, nearestAnchorEntry)) {
            resultList.add(queryEntry);
        }
    }
    return getSortedSubList(resultList, pagingPredicate, nearestAnchorEntry);
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Data(com.hazelcast.nio.serialization.Data) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PagingPredicate(com.hazelcast.query.PagingPredicate) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) PagingPredicateAccessor.getNearestAnchorEntry(com.hazelcast.query.PagingPredicateAccessor.getNearestAnchorEntry) Extractors(com.hazelcast.query.impl.getters.Extractors) Record(com.hazelcast.map.impl.record.Record) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) Map(java.util.Map) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 58 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method replace.

// TODO why does not replace method load data from map store if currently not available in memory.
@Override
public Object replace(Data key, Object update) {
    checkIfLoaded();
    final long now = getNow();
    final Record record = getRecordOrNull(key, now, false);
    if (record == null || record.getValue() == null) {
        return null;
    }
    Object oldValue = record.getValue();
    update = mapServiceContext.interceptPut(name, oldValue, update);
    update = mapDataStore.add(key, update, now);
    onStore(record);
    updateRecord(key, record, update, now);
    saveIndex(record, oldValue);
    return oldValue;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Aggregations

Record (com.hazelcast.map.impl.record.Record)58 Data (com.hazelcast.nio.serialization.Data)25 EntryView (com.hazelcast.core.EntryView)9 Map (java.util.Map)7 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)6 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)5 MapContainer (com.hazelcast.map.impl.MapContainer)4 RecordInfo (com.hazelcast.map.impl.record.RecordInfo)4 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 Indexes (com.hazelcast.query.impl.Indexes)4 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 MapConfig (com.hazelcast.config.MapConfig)2 EntryEventType (com.hazelcast.core.EntryEventType)2 TestUtil.toData (com.hazelcast.instance.TestUtil.toData)2 MapEntries (com.hazelcast.map.impl.MapEntries)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2