/** * Adds bytes to this writer's buffer. * * @param bytes * byte array * @param off * offset into array to start copying bytes * @param length * number of bytes to add * @throws IndexOutOfBoundsException * if off or length are invalid */ public void add(byte[] bytes, int off, int length) { reserve(length); System.arraycopy(bytes, off, data, offset, length); offset += length; }
/** * Adds bytes to this writer's buffer. * * @param bytes * byte array * @param off * offset into array to start copying bytes * @param length * number of bytes to add * @throws IndexOutOfBoundsException * if off or length are invalid */ public void add(byte[] bytes, int off, int length) { reserve(length); System.arraycopy(bytes, off, data, offset, length); offset += length; }
reserve(9); if (i >= -112 && i <= 127) { data[offset++] = (byte) i;
/** * Adds a Boolean value to this writer's buffer. * * @param b * Boolean value */ public void add(boolean b) { reserve(1); if (b) data[offset++] = 1; else data[offset++] = 0; }
/** * Adds a Boolean value to this writer's buffer. * * @param b * Boolean value */ public void add(boolean b) { reserve(1); if (b) data[offset++] = 1; else data[offset++] = 0; }
/** * 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); }