Search in sources :

Example 31 with Record

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

the class EvictBatchBackupOperation method runInternal.

@Override
protected void runInternal() {
    if (recordStore == null) {
        return;
    }
    for (ExpiredKey expiredKey : expiredKeys) {
        Data key = expiredKey.getKey();
        Record existingRecord = recordStore.getRecord(key);
        if (hasSameValueHashCode(existingRecord, expiredKey)) {
            recordStore.evict(key, true);
        }
    }
    equalizeEntryCountWithPrimary();
}
Also used : Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiredKey(com.hazelcast.internal.eviction.ExpiredKey)

Example 32 with Record

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

the class GetEntryViewOperation method runInternal.

@Override
protected void runInternal() {
    Record record = recordStore.getRecordOrNull(dataKey);
    if (record != null) {
        Data value = mapServiceContext.toData(record.getValue());
        ExpiryMetadata expiryMetadata = recordStore.getExpirySystem().getExpiryMetadata(dataKey);
        result = EntryViews.createSimpleEntryView(dataKey, value, record, expiryMetadata);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.internal.serialization.Data) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 33 with Record

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

the class PartitionScanRunner method run.

@SuppressWarnings("unchecked")
public void run(String mapName, Predicate predicate, int partitionId, Result result) {
    PagingPredicateImpl pagingPredicate = predicate instanceof PagingPredicateImpl ? (PagingPredicateImpl) predicate : null;
    PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    RecordStore<Record> recordStore = partitionContainer.getRecordStore(mapName);
    boolean nativeMemory = recordStore.getInMemoryFormat() == InMemoryFormat.NATIVE;
    boolean useCachedValues = isUseCachedDeserializedValuesEnabled(mapContainer, partitionId);
    Extractors extractors = mapServiceContext.getExtractors(mapName);
    Map.Entry<Integer, Map.Entry> nearestAnchorEntry = pagingPredicate == null ? null : pagingPredicate.getNearestAnchorEntry();
    recordStore.forEachAfterLoad(new BiConsumer<Data, Record>() {

        LazyMapEntry queryEntry = new LazyMapEntry();

        @Override
        public void accept(Data key, Record record) {
            Object value = useCachedValues ? getValueOrCachedValue(record, ss) : record.getValue();
            // TODO how can a value be null?
            if (value == null) {
                return;
            }
            queryEntry.init(ss, key, value, extractors);
            queryEntry.setRecord(record);
            queryEntry.setMetadata(recordStore.getOrCreateMetadataStore().get(key));
            if (predicate.apply(queryEntry) && compareAnchor(pagingPredicate, queryEntry, nearestAnchorEntry)) {
                // always copy key&value to heap if map is backed by native memory
                value = nativeMemory ? toHeapData((Data) value) : value;
                result.add(queryEntry.init(ss, toHeapData(key), value, extractors));
                // We can't reuse the existing entry after it was added to the
                // result. Allocate the new one.
                queryEntry = new LazyMapEntry();
            }
        }
    }, false);
    result.orderAndLimit(pagingPredicate, nearestAnchorEntry);
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) ToHeapDataConverter.toHeapData(com.hazelcast.internal.util.ToHeapDataConverter.toHeapData) Data(com.hazelcast.internal.serialization.Data) MapContainer(com.hazelcast.map.impl.MapContainer) Extractors(com.hazelcast.query.impl.getters.Extractors) LazyMapEntry(com.hazelcast.map.impl.LazyMapEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) Entry(java.util.Map.Entry) LazyMapEntry(com.hazelcast.map.impl.LazyMapEntry) Record(com.hazelcast.map.impl.record.Record) Map(java.util.Map) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Example 34 with Record

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

the class AbstractRecordStore method createRecord.

@Override
public Record createRecord(Data key, Object value, long now) {
    Record record = recordFactory.newRecord(key, value);
    record.setCreationTime(now);
    record.setLastUpdateTime(now);
    if (record.getMatchingRecordReaderWriter() == RecordReaderWriter.SIMPLE_DATA_RECORD_WITH_LRU_EVICTION_READER_WRITER) {
        // To distinguish last-access-time from creation-time we
        // set last-access-time for only LRU records. A LRU record
        // has no creation-time field but last-access-time field.
        record.setLastAccessTime(now);
    }
    updateStatsOnPut(false, now);
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 35 with Record

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

the class DefaultRecordStore method putOrUpdateReplicatedRecord.

@Override
public Record putOrUpdateReplicatedRecord(Data dataKey, Record replicatedRecord, ExpiryMetadata expiryMetadata, boolean indexesMustBePopulated, long now) {
    Record newRecord = storage.get(dataKey);
    if (newRecord == null) {
        newRecord = createRecord(dataKey, replicatedRecord != null ? replicatedRecord.getValue() : null, now);
        storage.put(dataKey, newRecord);
    } else {
        storage.updateRecordValue(dataKey, newRecord, replicatedRecord.getValue());
    }
    Records.copyMetadataFrom(replicatedRecord, newRecord);
    expirySystem.add(dataKey, expiryMetadata, now);
    mutationObserver.onReplicationPutRecord(dataKey, newRecord, indexesMustBePopulated);
    updateStatsOnPut(replicatedRecord.getHits(), now);
    return newRecord;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Aggregations

Record (com.hazelcast.map.impl.record.Record)109 Data (com.hazelcast.internal.serialization.Data)27 Data (com.hazelcast.nio.serialization.Data)22 Map (java.util.Map)13 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)11 ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)11 EntryView (com.hazelcast.core.EntryView)8 Indexes (com.hazelcast.query.impl.Indexes)8 ArrayList (java.util.ArrayList)7 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)6 MapContainer (com.hazelcast.map.impl.MapContainer)6 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)6 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)6 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)5 MapService (com.hazelcast.map.impl.MapService)5 List (java.util.List)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapEntries (com.hazelcast.map.impl.MapEntries)3