@Override public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated) throws IOException { output.writeByteRange(utf8String, fieldNumber, value, offset, length, repeated); }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int size = readRawVarint32(); if (size <= (bufferSize - bufferPos) && size > 0) { // Fast path: We already have the bytes in a contiguous buffer output.writeByteRange(utf8String, fieldNumber, buffer, bufferPos, size, repeated); bufferPos += size; } else { // Slow path: Build a byte array first then copy it. output.writeByteRange(utf8String, fieldNumber, readRawBytes(size), 0, size, repeated); } }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarint32(); if (length < 0) throw ProtobufException.negativeSize(); output.writeByteRange(utf8String, fieldNumber, buffer, offset, length, repeated); offset += length; }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarInt32(); if (length < 0) { throw ProtocolException.negativeSize(); } if (utf8String) { // if it is a UTF string, we have to call the writeByteRange. if (nioBuffer.hasArray()) { output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); } else { byte[] bytes = new byte[length]; nioBuffer.get(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated); } } else { // Do the potentially vastly more efficient potential splice call. if (nioBuffer.remaining() < length) { throw ProtocolException.misreportedSize(); } ByteBuffer dup = nioBuffer.slice(); dup.limit(length); output.writeBytes(fieldNumber, dup, repeated); nioBuffer.position(nioBuffer.position() + length); } }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarInt32(); if (length < 0) { throw ProtocolException.negativeSize(); } if (utf8String) { // if it is a UTF string, we have to call the writeByteRange. if (nioBuffer.hasArray()) { output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); } else { byte[] bytes = new byte[length]; nioBuffer.get(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated); } } else { // Do the potentially vastly more efficient potential splice call. if (nioBuffer.remaining() < length) { throw ProtocolException.misreportedSize(); } ByteBuffer dup = nioBuffer.slice(); dup.limit(length); output.writeBytes(fieldNumber, dup, repeated); nioBuffer.position(nioBuffer.position() + length); } }
output.writeByteRange(true, fieldNumber, buffer.array(), buffer.arrayOffset() + buffer.position(), length, repeated); buffer.position(buffer.position() + length); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length); nioBuffer.position(position + length); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length); nioBuffer.position(position + length); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarInt32(); if (length < 0) { throw ProtocolException.negativeSize(); } if (utf8String) { // if it is a UTF string, we have to call the writeByteRange. if (nioBuffer.hasArray()) { output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); } else { byte[] bytes = new byte[length]; nioBuffer.get(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated); } } else { // Do the potentially vastly more efficient potential splice call. if (nioBuffer.remaining() < length) { throw ProtocolException.misreportedSize(); } ByteBuffer dup = nioBuffer.slice(); dup.limit(length); output.writeBytes(fieldNumber, dup, repeated); nioBuffer.position(nioBuffer.position() + length); } }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarInt32(); if (length < 0) { throw ProtocolException.negativeSize(); } if (utf8String) { // if it is a UTF string, we have to call the writeByteRange. if (nioBuffer.hasArray()) { output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); } else { byte[] bytes = new byte[length]; nioBuffer.get(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated); } } else { // Do the potentially vastly more efficient potential splice call. if (nioBuffer.remaining() < length) { throw ProtocolException.misreportedSize(); } ByteBuffer dup = nioBuffer.slice(); dup.limit(length); output.writeBytes(fieldNumber, dup, repeated); nioBuffer.position(nioBuffer.position() + length); } }
output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length); nioBuffer.position(position + length); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); UnsafeDirectBufferUtil.getBytes(address(position), bytes, 0, length); nioBuffer.position(position + length); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
output.writeByteRange(true, fieldNumber, byteBuf.array(), byteBuf.arrayOffset() + byteBuf.readerIndex(), length, repeated); byteBuf.readerIndex(byteBuf.readerIndex() + length); byte[] bytes = new byte[length]; byteBuf.readBytes(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);