use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class WriteBehindStateHolder method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
int size = in.readInt();
delayedEntries = new HashMap<String, List<DelayedEntry>>(size);
for (int i = 0; i < size; i++) {
String mapName = in.readUTF();
int listSize = in.readInt();
List<DelayedEntry> delayedEntriesList = new ArrayList<DelayedEntry>(listSize);
for (int j = 0; j < listSize; j++) {
Data key = in.readData();
Data value = in.readData();
long storeTime = in.readLong();
int partitionId = in.readInt();
long sequence = in.readLong();
DelayedEntry<Data, Data> entry = DelayedEntries.createDefault(key, value, storeTime, partitionId);
entry.setSequence(sequence);
delayedEntriesList.add(entry);
}
delayedEntries.put(mapName, delayedEntriesList);
}
int expectedSize = in.readInt();
flushSequences = new HashMap<String, Queue<WriteBehindStore.Sequence>>(expectedSize);
for (int i = 0; i < expectedSize; i++) {
String mapName = in.readUTF();
int setSize = in.readInt();
Queue<WriteBehindStore.Sequence> queue = new ArrayDeque<WriteBehindStore.Sequence>(setSize);
for (int j = 0; j < setSize; j++) {
queue.add(new WriteBehindStore.Sequence(in.readLong(), in.readBoolean()));
}
flushSequences.put(mapName, queue);
}
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class PartitionWideEntryBackupOperation method run.
@Override
public void run() {
long now = getNow();
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
Iterator<Record> iterator = recordStore.iterator(now, true);
while (iterator.hasNext()) {
Record record = iterator.next();
Data dataKey = record.getKey();
Object oldValue = record.getValue();
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
if (!applyPredicate(dataKey, value)) {
continue;
}
Map.Entry entry = createMapEntry(dataKey, value);
processBackup(entry);
if (noOp(entry, oldValue)) {
continue;
}
if (entryRemovedBackup(entry, dataKey)) {
continue;
}
entryAddedOrUpdatedBackup(entry, dataKey);
evict(dataKey);
}
publishWanReplicationEventBackups();
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class PartitionWideEntryOperation method run.
@Override
public void run() {
long now = getNow();
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
responses = new MapEntries(recordStore.size());
Iterator<Record> iterator = recordStore.iterator(now, false);
while (iterator.hasNext()) {
Record record = iterator.next();
Data dataKey = record.getKey();
Object oldValue = record.getValue();
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
if (!applyPredicate(dataKey, value)) {
continue;
}
Map.Entry entry = createMapEntry(dataKey, value);
Data response = process(entry);
if (response != null) {
responses.add(dataKey, response);
}
// first call noOp, other if checks below depends on it.
if (noOp(entry, oldValue, now)) {
continue;
}
if (entryRemoved(entry, dataKey, oldValue, now)) {
continue;
}
entryAddedOrUpdated(entry, dataKey, oldValue, now);
evict(dataKey);
}
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class MapProxyImpl method executeOnEntries.
@Override
public Map<K, Object> executeOnEntries(EntryProcessor entryProcessor, Predicate predicate) {
List<Data> result = new ArrayList<Data>();
executeOnEntriesInternal(entryProcessor, predicate, result);
if (result.isEmpty()) {
return emptyMap();
}
Map<K, Object> resultingMap = MapUtil.createHashMap(result.size() / 2);
for (int i = 0; i < result.size(); ) {
Data key = result.get(i++);
Data value = result.get(i++);
resultingMap.put((K) toObject(key), toObject(value));
}
return resultingMap;
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class MapProxyImpl method containsKey.
@Override
public boolean containsKey(Object k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
return containsKeyInternal(key);
}
Aggregations