/** * Writes a variable int directly to a byte array. Is compatible with {@link WritableUtils} as it * will write the same data. */ public static int writeVInt(byte[] dest, int offset, int i) { return writeVLong(dest, offset, i); }
/** * Use the provided byte[] to buffer only the bytes used to write out the long i to the DataOutput * out. This will only ever make one write call to the DataOutput. Use this instead of * {@link WritableUtils#writeVLong(DataOutput, long)} which could make up to 8 separate writes to * the underlying OutputStream. Is compatible with WritableUtils as it will write the same data. */ public static void writeVLong(DataOutput out, byte[] workBuffer, long i) throws IOException { int size = UnsynchronizedBuffer.writeVLong(workBuffer, 0, i); out.write(workBuffer, 0, size); }
@Override public void write(DataOutput out) throws IOException { final byte[] timeBuffer = new byte[9]; super.write(out); UnsynchronizedBuffer.writeVLong(out, timeBuffer, systemTime); }
/** * Adds a long value to this writer's buffer. The long is encoded as a variable-length list of * bytes. For a description of the encoding scheme, see <code>WritableUtils.writeVLong()</code> * in the Hadoop API. [<a href= * "http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/io/WritableUtils.html#writeVLong%28java.io.DataOutput,%20long%29">link</a>] * * @param i * long value */ public void writeVLong(long i) { reserve(9); offset = UnsynchronizedBuffer.writeVLong(data, offset, i); }