Search in sources :

Example 81 with Record

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

the class AddIndexOperation method run.

@Override
public void run() throws Exception {
    Indexes indexes = mapContainer.getIndexes();
    Index index = indexes.addOrGetIndex(attributeName, ordered);
    final long now = getNow();
    final Iterator<Record> iterator = recordStore.iterator(now, false);
    SerializationService serializationService = getNodeEngine().getSerializationService();
    while (iterator.hasNext()) {
        final Record record = iterator.next();
        Data key = record.getKey();
        Object value = Records.getValueOrCachedValue(record, serializationService);
        QueryableEntry queryEntry = mapContainer.newQueryEntry(key, value);
        index.saveEntryIndex(queryEntry, null);
    }
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Index(com.hazelcast.query.impl.Index) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 82 with Record

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

the class EvictorImpl method evictEntry.

private void evictEntry(RecordStore recordStore, EntryView selectedEntry) {
    Record record = getRecordFromEntryView(selectedEntry);
    Data key = record.getKey();
    if (recordStore.isLocked(record.getKey())) {
        return;
    }
    boolean backup = isBackup(recordStore);
    recordStore.evict(key, backup);
    if (!backup) {
        recordStore.doPostEvictionOperations(record, backup);
    }
}
Also used : LazyEntryViewFromRecord(com.hazelcast.map.impl.recordstore.LazyEntryViewFromRecord) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 83 with Record

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

the class EntryOperation method afterRun.

@Override
public void afterRun() throws Exception {
    super.afterRun();
    if (eventType == null) {
        return;
    }
    mapServiceContext.interceptAfterPut(name, dataValue);
    if (isPostProcessing(recordStore)) {
        Record record = recordStore.getRecord(dataKey);
        dataValue = record == null ? null : record.getValue();
    }
    invalidateNearCache(dataKey);
    publishEntryEvent();
    publishWanReplicationEvent();
    evict(dataKey);
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 84 with Record

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

the class MapMigrationAwareService method migrateIndex.

private void migrateIndex(PartitionMigrationEvent event) {
    final long now = getNow();
    final PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
    for (RecordStore recordStore : container.getMaps().values()) {
        final MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
        final Indexes indexes = mapContainer.getIndexes();
        if (!indexes.hasIndex()) {
            continue;
        }
        final Iterator<Record> iterator = recordStore.iterator(now, false);
        while (iterator.hasNext()) {
            Record record = iterator.next();
            Data key = record.getKey();
            if (event.getMigrationEndpoint() == SOURCE) {
                assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event;
                Object value = Records.getValueOrCachedValue(record, serializationService);
                indexes.removeEntryIndex(key, value);
            } else if (event.getNewReplicaIndex() == 0) {
                Object value = Records.getValueOrCachedValue(record, serializationService);
                if (value != null) {
                    QueryableEntry queryEntry = mapContainer.newQueryEntry(record.getKey(), value);
                    indexes.saveEntryIndex(queryEntry, null);
                }
            }
        }
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 85 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)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