@Test public void testEncodeInt() throws Exception { encoder.writeInt(1); assertArrayEquals(new byte[] { (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x01 }, byteOutputStream.toByteArray()); byteOutputStream.reset(); encoder.writeInt(-1); assertArrayEquals(new byte[] { (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff }, byteOutputStream.toByteArray()); byteOutputStream.reset(); encoder.writeInt(0); assertArrayEquals(new byte[] { (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00 }, byteOutputStream.toByteArray()); }
@Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); }
MemcmpEncoder extends Encoder { @Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); } }
MemcmpEncoder extends Encoder { @Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); } MemcmpEncoder(OutputStream out); }
MemcmpEncoder extends Encoder { @Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); } MemcmpEncoder(OutputStream out); @Override void flush(); @Override void writeNull(); @Override void writeBoolean(boolean b); @Override void writeInt(int n); @Override void writeLong(long n); @Override void writeFloat(float f); @Override void writeDouble(double d); @Override void writeString(Utf8 utf8); @Override void writeFixed(byte[] bytes, int start, int len); @Override void writeBytes(ByteBuffer bytes); @Override void writeBytes(byte[] bytes, int start, int len); @Override void writeEnum(int e); @Override void writeArrayStart(); @Override void setItemCount(long itemCount); @Override void startItem(); @Override void writeArrayEnd(); @Override void writeMapStart(); @Override void writeMapEnd(); @Override void writeIndex(int unionIndex); }
MemcmpEncoder extends Encoder { @Override public void writeInt(int n) throws IOException { byte[] intBytes = new byte[] { (byte) ((n >>> 24) ^ 0x80), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; out.write(intBytes); } MemcmpEncoder(OutputStream out); @Override void flush(); @Override void writeNull(); @Override void writeBoolean(boolean b); @Override void writeInt(int n); @Override void writeLong(long n); @Override void writeFloat(float f); @Override void writeDouble(double d); @Override void writeString(Utf8 utf8); @Override void writeFixed(byte[] bytes, int start, int len); @Override void writeBytes(ByteBuffer bytes); @Override void writeBytes(byte[] bytes, int start, int len); @Override void writeEnum(int e); @Override void writeArrayStart(); @Override void setItemCount(long itemCount); @Override void startItem(); @Override void writeArrayEnd(); @Override void writeMapStart(); @Override void writeMapEnd(); @Override void writeIndex(int unionIndex);  }