Search in sources :

Example 6 with RingbufferMergeData

use of com.hazelcast.spi.merge.RingbufferMergeData in project hazelcast by hazelcast.

the class RingbufferMergeIntegerValuesMergePolicy method merge.

@Override
public RingbufferMergeData merge(RingbufferMergeTypes mergingValue, RingbufferMergeTypes existingValue) {
    final RingbufferMergeData mergingRingbuffer = mergingValue.getValue();
    final RingbufferMergeData result = new RingbufferMergeData(mergingRingbuffer.getCapacity());
    RingbufferMergeData existingRingbuffer;
    if (existingValue != null) {
        existingRingbuffer = existingValue.getValue();
    } else {
        existingRingbuffer = new RingbufferMergeData(mergingRingbuffer.getCapacity());
    }
    for (Object value : mergingRingbuffer) {
        if (value instanceof Integer) {
            result.add(value);
        }
    }
    for (Object value : existingRingbuffer) {
        if (value instanceof Integer) {
            result.add(value);
        }
    }
    return result;
}
Also used : RingbufferMergeData(com.hazelcast.spi.merge.RingbufferMergeData)

Aggregations

RingbufferMergeData (com.hazelcast.spi.merge.RingbufferMergeData)6 IOUtil.readObject (com.hazelcast.internal.nio.IOUtil.readObject)2 IOUtil.writeObject (com.hazelcast.internal.nio.IOUtil.writeObject)2 RingbufferMergeTypes (com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)1 Data (com.hazelcast.internal.serialization.Data)1