Package com.hazelcast.nio.serialization

Examples of com.hazelcast.nio.serialization.Data


        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        final LocalMapStatsImpl mapStats = mapService.getLocalMapStatsImpl(name);
        final Map<Data, Record> records = recordStore.getReadonlyRecordMap();
        for (final Map.Entry<Data, Record> recordEntry : records.entrySet()) {
            final long start = System.currentTimeMillis();
            final Data dataKey = recordEntry.getKey();
            final Record record = recordEntry.getValue();
            final Object valueBeforeProcess = record.getValue();
            final Object valueBeforeProcessObject = mapService.toObject(valueBeforeProcess);
            Object objectKey = mapService.toObject(record.getKey());
            if (getPredicate() != null) {
                final SerializationService ss = getNodeEngine().getSerializationService();
                QueryEntry queryEntry = new QueryEntry(ss, dataKey, objectKey, valueBeforeProcessObject);
                if (!getPredicate().apply(queryEntry)) {
                    continue;
                }
            }
            entry = new MapEntrySimple(objectKey, valueBeforeProcessObject);
            final Object result = entryProcessor.process(entry);
            final Object valueAfterProcess = entry.getValue();
            Data dataValue = null;
            if (result != null) {
                dataValue = mapService.toData(result);
                response.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(dataKey, dataValue));
            }

            EntryEventType eventType;
            if (valueAfterProcess == null) {
                recordStore.remove(dataKey);
                mapStats.incrementRemoves(getLatencyFrom(start));
                eventType = EntryEventType.REMOVED;
            } else {
                if (valueBeforeProcessObject == null) {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.ADDED;
                }
                // take this case as a read so no need to fire an event.
                else if (!entry.isModified()) {
                    mapStats.incrementGets(getLatencyFrom(start));
                    eventType = __NO_NEED_TO_FIRE_EVENT;
                } else {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.UPDATED;
                }
                // todo if this is a read only operation, record access operations should be done.
                if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                    recordStore.put(new AbstractMap.SimpleImmutableEntry<Data, Object>(dataKey, valueAfterProcess));
                }
            }
            if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                final Data oldValue = mapService.toData(valueBeforeProcess);
                final Data value = mapService.toData(valueAfterProcess);
                mapService.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, value);
                if (mapService.isNearCacheAndInvalidationEnabled(name)) {
                    mapService.invalidateAllNearCaches(name, dataKey);
                }
                if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
View Full Code Here


    protected void writeInternal(ObjectDataOutput out) throws IOException {
        super.writeInternal(out);
        out.writeInt(dataMap.size());
        for (Map.Entry<Long, Data> entry: dataMap.entrySet()) {
            long itemId = entry.getKey();
            Data value = entry.getValue();
            out.writeLong(itemId);
            value.writeData(out);
        }
    }
View Full Code Here

        super.readInternal(in);
        int size = in.readInt();
        dataMap = new HashMap<Long, Data>(size);
        for (int i = 0; i < size; i++) {
            long itemId = in.readLong();
            Data value = new Data();
            value.readData(in);
            dataMap.put(itemId, value);
        }
    }
View Full Code Here

        RecordStore recordStore = mapService.getRecordStore(partitionId, name);
        Set<Map.Entry<Data, Data>> entries = entrySet.getEntrySet();
        InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        Set<Data> keysToInvalidate = new HashSet<Data>();
        for (Map.Entry<Data, Data> entry : entries) {
            Data dataKey = entry.getKey();
            Data dataValue = entry.getValue();
            if (partitionId == partitionService.getPartitionId(dataKey)) {
                Data dataOldValue = null;
                if (initialLoad) {
                    recordStore.putFromLoad(dataKey, dataValue, -1);
                } else {
                    dataOldValue = mapService.toData(recordStore.put(dataKey, dataValue, -1));
                }
View Full Code Here

        }
        txMap.put(itemId, new TxQueueItem(item).setPollOperation(true).setTransactionId(transactionId));
    }

    public Data txnCommitPoll(long itemId) {
        final Data result = txnCommitPollBackup(itemId);
        scheduleEvictionIfEmpty();
        return result;
    }
View Full Code Here

    protected void readInternal(ObjectDataInput in) throws IOException {
        super.readInternal(in);
        int size = in.readInt();
        if (size > -1) {
            for (int i = 0; i < size; i++) {
                Data data = new Data();
                data.readData(in);
                keys.add(data);
            }
        }
    }
View Full Code Here

        Map<Data, Record> records = rs.getReadonlyRecordMap();
        IndexService indexService = mapContainer.getIndexService();
        SerializationService ss = getNodeEngine().getSerializationService();
        Index index = indexService.addOrGetIndex(attributeName, ordered);
        for (Record record : records.values()) {
            Data key = record.getKey();
            Object value = record.getValue();
            index.saveEntryIndex(new QueryEntry(ss, key, key, value));
        }
    }
View Full Code Here

        if (enabled) {
            final Object val = store.load(key);
            if (binary) {
                byte[] dataBuffer = (byte[]) val;
                ObjectDataInput in = serializationService.createObjectDataInput(dataBuffer);
                Data data = new Data();
                try {
                    data.readData(in);
                } catch (IOException e) {
                    throw new HazelcastException(e);
                }
                return data;
            }
View Full Code Here

            final Map<Long, Data> dataMap = new HashMap<Long, Data>(map.size());
            if (binary) {
                for (Map.Entry<Long, ?> entry : map.entrySet()) {
                    byte[] dataBuffer = (byte[]) entry.getValue();
                    ObjectDataInput in = serializationService.createObjectDataInput(dataBuffer);
                    Data data = new Data();
                    try {
                        data.readData(in);
                    } catch (IOException e) {
                        throw new HazelcastException(e);
                    }
                    dataMap.put(entry.getKey(), data);
                }
View Full Code Here

        return InMemoryFormat.OFFHEAP;
    }

    @Override
    public Record<Data> newRecord(Data key, Object value) {
        Data v = serializationService.toData(value, partitionStrategy);
        return new OffHeapRecord(storage, key, v, statisticsEnabled);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.nio.serialization.Data

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.