@Test public void testSignedSize() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutput out = new DataOutputStream(baos); int expectedSize = 0; for (int exponent = 0; exponent <= 61; exponent++) { Varint.writeSignedVarLong(1L << exponent, out); expectedSize += 1 + ((exponent + 1) / 7); assertEquals(expectedSize, baos.size()); } for (int exponent = 0; exponent <= 61; exponent++) { Varint.writeSignedVarLong(-(1L << exponent)-1, out); expectedSize += 1 + ((exponent + 1) / 7); assertEquals(expectedSize, baos.size()); } }
public static void writeSignedVarLong(long value, DataOutput out) throws IOException { writeUnsignedVarLong((value << 1) ^ (value >> 63), out); }
Varint { public static void writeSignedVarLong(long value, DataOutput out) throws IOException { writeUnsignedVarLong((value << 1) ^ (value >> 63), out); } }
Varint { public static void writeSignedVarLong(long value, DataOutput out) throws IOException { writeUnsignedVarLong((value << 1) ^ (value >> 63), out); } private  Varint(); }
Varint { public static void writeSignedVarLong(long value, DataOutput out) throws IOException { writeUnsignedVarLong((value << 1) ^ (value >> 63), out); } private  Varint(); static void writeSignedVarLong(long value, DataOutput out); static void writeUnsignedVarLong(long value, DataOutput out); static void writeSignedVarInt(int value, DataOutput out); static void writeUnsignedVarInt(int value, DataOutput out); static long readSignedVarLong(DataInput in); static long readUnsignedVarLong(DataInput in); static long readUnsignedVarLong(byte[] bytes, int start, int length); static int readSignedVarInt(DataInput in); static int readUnsignedVarInt(DataInput in); static int readUnsignedVarInt(byte[] bytes, int start, int length); }
Varint { public static void writeSignedVarLong(long value, DataOutput out) throws IOException { writeUnsignedVarLong((value << 1) ^ (value >> 63), out); } private  Varint(); static void writeSignedVarLong(long value, DataOutput out); static void writeUnsignedVarLong(long value, DataOutput out); static void writeSignedVarInt(int value, DataOutput out); static void writeUnsignedVarInt(int value, DataOutput out); static long readSignedVarLong(DataInput in); static long readUnsignedVarLong(DataInput in); static long readUnsignedVarLong(byte[] bytes, int start, int length); static int readSignedVarInt(DataInput in); static int readUnsignedVarInt(DataInput in); static int readUnsignedVarInt(byte[] bytes, int start, int length);  }