ProtobufOutput extends WriteSession implements Output { public static int computeRawVarint64Size(final long value) { if ((value & (0xffffffffffffffffL << 7)) == 0) return 1; if ((value & (0xffffffffffffffffL << 14)) == 0) return 2; if ((value & (0xffffffffffffffffL << 21)) == 0) return 3; if ((value & (0xffffffffffffffffL << 28)) == 0) return 4; if ((value & (0xffffffffffffffffL << 35)) == 0) return 5; if ((value & (0xffffffffffffffffL << 42)) == 0) return 6; if ((value & (0xffffffffffffffffL << 49)) == 0) return 7; if ((value & (0xffffffffffffffffL << 56)) == 0) return 8; if ((value & (0xffffffffffffffffL << 63)) == 0) return 9; return 10; } ProtobufOutput(LinkedBuffer buffer);  ProtobufOutput(LinkedBuffer buffer, int nextBufferSize); @Override ProtobufOutput clear(); @Override void writeInt32(int fieldNumber, int value, boolean repeated); @Override void writeUInt32(int fieldNumber, int value, boolean repeated); @Override void writeSInt32(int fieldNumber, int value, boolean repeated); @Override void writeFixed32(int fieldNumber, int value, boolean repeated); @Override void writeSFixed32(int fieldNumber, int value, boolean repeated); @Override void writeInt64(int fieldNumber, long value, boolean repeated); @Override void writeUInt64(int fieldNumber, long value, boolean repeated); @Override void writeSInt64(int fieldNumber, long value, boolean repeated); @Override void writeFixed64(int fieldNumber, long value, boolean repeated); @Override void writeSFixed64(int fieldNumber, long value, boolean repeated); @Override void writeFloat(int fieldNumber, float value, boolean repeated); @Override void writeDouble(int fieldNumber, double value, boolean repeated); @Override void writeBool(int fieldNumber, boolean value, boolean repeated); @Override void writeEnum(int fieldNumber, int number, boolean repeated); @Override void writeString(int fieldNumber, CharSequence value, boolean repeated); @Override void writeBytes(int fieldNumber, ByteString value, boolean repeated); @Override void writeByteArray(int fieldNumber, byte[] bytes, boolean repeated); @Override void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
            int offset, int length, boolean repeated); @Override void writeObject(final int fieldNumber, final T value, final Schema<T> schema,
            final boolean repeated); static LinkedBuffer writeRawVarInt32(int value, final WriteSession session,
            LinkedBuffer lb); static LinkedBuffer writeTagAndLinkedBuffer(int tag,
            final LinkedBuffer buffer, final WriteSession session, LinkedBuffer lb); static LinkedBuffer writeTagAndByteArray(int tag, final byte[] value,
            int offset, int valueLen,
            final WriteSession session, LinkedBuffer lb); static LinkedBuffer writeTagAndRawVarInt32(int tag, int value,
            final WriteSession session, LinkedBuffer lb); static LinkedBuffer writeTagAndRawVarInt64(int tag, long value,
            final WriteSession session, LinkedBuffer lb); static LinkedBuffer writeTagAndRawLittleEndian32(int tag, int value,
            final WriteSession session, LinkedBuffer lb); static LinkedBuffer writeTagAndRawLittleEndian64(int tag, long value,
            final WriteSession session, LinkedBuffer lb); static void writeRawVarInt32(int value, final byte[] buf, int offset); static void writeRawVarInt32Bytes(OutputStream out, int value); static void writeRawVarInt32Bytes(DataOutput out, int value); static byte[] getTagAndRawVarInt32Bytes(int tag, int value); static byte[] getTagAndRawVarInt64Bytes(int tag, long value); static byte[] getTagAndRawLittleEndian32Bytes(int tag, int value); static byte[] getTagAndRawLittleEndian64Bytes(int tag, long value); static int writeRawLittleEndian32(int value, byte[] buffer, int offset); static int writeRawLittleEndian64(long value, byte[] buffer, int offset); static byte[] getRawVarInt32Bytes(int value); static int computeRawVarint32Size(final int value); static int computeRawVarint64Size(final long value); static int encodeZigZag32(final int n); static long encodeZigZag64(final long n); @Override void writeBytes(int fieldNumber, ByteBuffer value, boolean repeated); static final int LITTLE_ENDIAN_32_SIZE; }
@Test public void testComputeRawVarint64Size() { Assert.assertEquals(1, ProtobufOutput.computeRawVarint64Size(0L)); Assert.assertEquals(2, ProtobufOutput.computeRawVarint64Size(1024L)); Assert.assertEquals(3, ProtobufOutput.computeRawVarint64Size(65536L)); Assert.assertEquals(4, ProtobufOutput.computeRawVarint64Size(8388608L)); Assert.assertEquals(5, ProtobufOutput.computeRawVarint64Size(1073807360L)); Assert.assertEquals(6, ProtobufOutput.computeRawVarint64Size(549755879424L)); Assert.assertEquals(7, ProtobufOutput.computeRawVarint64Size(4398046511104L)); Assert.assertEquals(8, ProtobufOutput.computeRawVarint64Size(562949953421312L)); Assert.assertEquals(9, ProtobufOutput.computeRawVarint64Size(4612248968380809216L)); Assert.assertEquals(10, ProtobufOutput.computeRawVarint64Size(-9223372036854710272L)); }