/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Append specified bytes to the buffer * * @param bytes byte array to be appended */ public void append(byte[] bytes) { append(bytes, 0, bytes.length); }
/** * Reads the raw bytes following a <code>Type.MAP</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawMap() throws IOException { Buffer buffer = new Buffer(); int length = readMapHeader(); buffer.append(new byte[] {(byte) Type.MAP.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); for (int i = 0; i < length; i++) { buffer.append(readRaw()); buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.MAP</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawMap() throws IOException { Buffer buffer = new Buffer(); int length = readMapHeader(); buffer.append(new byte[] {(byte) Type.MAP.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); for (int i = 0; i < length; i++) { buffer.append(readRaw()); buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.VECTOR</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawVector() throws IOException { Buffer buffer = new Buffer(); int length = readVectorHeader(); buffer.append(new byte[] { (byte) Type.VECTOR.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length) }); for (int i = 0; i < length; i++) { buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.LIST</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawList() throws IOException { Buffer buffer = new Buffer(new byte[] { (byte) Type.LIST.code }); byte[] bytes = readRaw(); while (bytes != null) { buffer.append(bytes); bytes = readRaw(); } buffer.append(new byte[] { (byte) Type.MARKER.code }); return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.MAP</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawMap() throws IOException { Buffer buffer = new Buffer(); int length = readMapHeader(); buffer.append(new byte[] { (byte) Type.MAP.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length) }); for (int i = 0; i < length; i++) { buffer.append(readRaw()); buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.LIST</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawList() throws IOException { Buffer buffer = new Buffer(new byte[] { (byte) Type.LIST.code }); byte[] bytes = readRaw(); while (bytes != null) { buffer.append(bytes); bytes = readRaw(); } buffer.append(new byte[] { (byte) Type.MARKER.code }); return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.MAP</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawMap() throws IOException { Buffer buffer = new Buffer(); int length = readMapHeader(); buffer.append(new byte[] { (byte) Type.MAP.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length) }); for (int i = 0; i < length; i++) { buffer.append(readRaw()); buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.LIST</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawList() throws IOException { Buffer buffer = new Buffer(new byte[] {(byte) Type.LIST.code}); byte[] bytes = readRaw(); while (bytes != null) { buffer.append(bytes); bytes = readRaw(); } buffer.append(new byte[] {(byte) Type.MARKER.code}); return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.LIST</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawList() throws IOException { Buffer buffer = new Buffer(new byte[] {(byte) Type.LIST.code}); byte[] bytes = readRaw(); while (bytes != null) { buffer.append(bytes); bytes = readRaw(); } buffer.append(new byte[] {(byte) Type.MARKER.code}); return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.VECTOR</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawVector() throws IOException { Buffer buffer = new Buffer(); int length = readVectorHeader(); buffer.append(new byte[] {(byte) Type.VECTOR.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); for (int i = 0; i < length; i++) { buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.VECTOR</code> code. * * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawVector() throws IOException { Buffer buffer = new Buffer(); int length = readVectorHeader(); buffer.append(new byte[] {(byte) Type.VECTOR.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length)}); for (int i = 0; i < length; i++) { buffer.append(readRaw()); } return buffer.get(); }
/** * Reads the raw bytes following a <code>Type.VECTOR</code> code. * @return the obtained bytes sequence * @throws IOException */ public byte[] readRawVector() throws IOException { Buffer buffer = new Buffer(); int length = readVectorHeader(); buffer.append(new byte[] { (byte) Type.VECTOR.code, (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)), (byte) (0xff & (length >> 8)), (byte) (0xff & length) }); for (int i = 0; i < length; i++) { buffer.append(readRaw()); } return buffer.get(); }
/** * Test of append method, of class org.apache.hadoop.record.Buffer. */ public void testAppend() { final byte[] bytes = new byte[100]; final int offset = 0; final int length = 100; for (int idx = 0; idx < 100; idx++) { bytes[idx] = (byte) (100-idx); } final Buffer instance = new Buffer(); instance.append(bytes, offset, length); assertEquals("Buffer size mismatch", 100, instance.getCount()); for (int idx = 0; idx < 100; idx++) { assertEquals("Buffer contents corrupted", 100-idx, instance.get()[idx]); } } }