public void add(String key, String value) { synchronized (this) { if (this.mapFields == null) { this.mapFields = new TreeMap<String, Buffer>(); } } this.mapFields.put(key, new Buffer(value.getBytes(Charset.forName("UTF-8")))); }
@Override public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
@Override public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
@Override public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
@Override public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
@Override public Buffer readBuffer(final String tag) throws IOException { final int len = Utils.readVInt(in); final byte[] barr = new byte[len]; in.readFully(barr); return new Buffer(barr); }
private static void initBuffers(Record[] buffers) { final int BUFLEN = 32; for (int idx = 0; idx < buffers.length; idx++) { buffers[idx] = new RecBuffer(); int buflen = rand.nextInt(BUFLEN); byte[] bytes = new byte[buflen]; rand.nextBytes(bytes); ((RecBuffer)buffers[idx]).setData(new Buffer(bytes)); } }
/** * Test of getCount method, of class org.apache.hadoop.record.Buffer. */ public void testGetCount() { final Buffer instance = new Buffer(); final int expResult = 0; final int result = instance.getCount(); assertEquals("getSize failed", expResult, result); }
public Buffer readBuffer(String tag) throws IOException { in.skipType(); return new Buffer(in.readBytes()); }
public Buffer readBuffer(String tag) throws IOException { in.skipType(); return new Buffer(in.readBytes()); }
public Buffer readBuffer(String tag) throws IOException { in.skipType(); return new Buffer(in.readBytes()); }
public Buffer readBuffer(String tag) throws IOException { in.skipType(); return new Buffer(in.readBytes()); }
/** * Test of set method, of class org.apache.hadoop.record.Buffer. */ public void testSet() { final byte[] bytes = new byte[10]; final Buffer instance = new Buffer(); instance.set(bytes); assertEquals("set failed", bytes, instance.get()); }
/** * Test of getCapacity method, of class org.apache.hadoop.record.Buffer. */ public void testGetCapacity() { final Buffer instance = new Buffer(); final int expResult = 0; final int result = instance.getCapacity(); assertEquals("getCapacity failed", expResult, result); instance.setCapacity(100); assertEquals("setCapacity failed", 100, instance.getCapacity()); }
/** * 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(); }
/** * Test of truncate method, of class org.apache.hadoop.record.Buffer. */ public void testTruncate() { final Buffer instance = new Buffer(); instance.setCapacity(100); assertEquals("setCapacity failed", 100, instance.getCapacity()); instance.truncate(); assertEquals("truncate failed", 0, instance.getCapacity()); }
/** * 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(); }