Search in sources :

Example 1 with ArrayExpandableByteBuffer

use of de.invesdwin.util.streams.buffer.bytes.extend.ArrayExpandableByteBuffer in project invesdwin-context-persistence by subes.

the class SerdeGroupSerializer method serialize.

@Override
public void serialize(final DataOutput2 out, final T value) throws IOException {
    final IByteBuffer buffer = new ArrayExpandableByteBuffer(out.buf);
    final int positionBefore = out.pos;
    final IByteBuffer valueBuffer = buffer.sliceFrom(positionBefore + VALUE_INDEX);
    final int valueLength = serde.toBuffer(valueBuffer, value);
    buffer.putInt(positionBefore + SIZE_INDEX, valueLength);
    out.buf = buffer.byteArray();
    out.pos = positionBefore + VALUE_INDEX + valueLength;
    out.sizeMask = 0xFFFFFFFF - (out.buf.length - 1);
}
Also used : ArrayExpandableByteBuffer(de.invesdwin.util.streams.buffer.bytes.extend.ArrayExpandableByteBuffer) IByteBuffer(de.invesdwin.util.streams.buffer.bytes.IByteBuffer)

Aggregations

IByteBuffer (de.invesdwin.util.streams.buffer.bytes.IByteBuffer)1 ArrayExpandableByteBuffer (de.invesdwin.util.streams.buffer.bytes.extend.ArrayExpandableByteBuffer)1