public static LogEntry fromBytes(byte bytes[]) throws IOException { DataInputBuffer inp = new DataInputBuffer(); inp.reset(bytes, bytes.length); KeyExtent extent = new KeyExtent(); extent.readFields(inp); long timestamp = inp.readLong(); String server = inp.readUTF(); String filename = inp.readUTF(); return new LogEntry(extent, timestamp, server, filename); }
public void fromBytes(byte bytes[]) throws IOException { DataInputBuffer inp = new DataInputBuffer(); inp.reset(bytes, bytes.length); extent = new KeyExtent(); extent.readFields(inp); timestamp = inp.readLong(); server = inp.readUTF(); filename = inp.readUTF(); tabletId = inp.read(); int count = inp.read(); ArrayList<String> logSet = new ArrayList<String>(count); for (int i = 0; i < count; i++) logSet.add(inp.readUTF()); this.logSet = logSet; }
static public LogEntry fromBytes(byte bytes[]) throws IOException { DataInputBuffer inp = new DataInputBuffer(); inp.reset(bytes, bytes.length); KeyExtent extent = new KeyExtent(); extent.readFields(inp); long timestamp = inp.readLong(); String server = inp.readUTF(); String filename = inp.readUTF(); return new LogEntry(extent, timestamp, server, filename); }
@Override public TMessageSet deserialize(byte[] payload) { DataInputBuffer inBuffer = new DataInputBuffer(); inBuffer.reset(payload, payload.length); try { String app = inBuffer.readUTF(); int numMessages = inBuffer.readInt(); byte compression = inBuffer.readByte(); long crc = inBuffer.readLong(); byte[] messages = new byte[inBuffer.readInt()]; inBuffer.read(messages); return new TMessageSet( app, numMessages, compression, crc, ByteBuffer.wrap(messages) ); } catch (Exception e) { throw new RuntimeException("Failed to de-serialize payload into TMessageSet: "+e.getMessage(), e); } finally { Closeables.closeQuietly(inBuffer); } }
public void testIO() throws Exception { DataOutputBuffer out = new DataOutputBuffer(); DataInputBuffer in = new DataInputBuffer(); for (int i = 0; i < 10000; i++) { // generate a random string String before = getTestString(); // write it out.reset(); UTF8.writeString(out, before); // test that it reads correctly in.reset(out.getData(), out.getLength()); String after = UTF8.readString(in); assertEquals(before, after); // test that it reads correctly with DataInput in.reset(out.getData(), out.getLength()); String after2 = in.readUTF(); assertEquals(before, after2); // test that it is compatible with Java's other decoder String after3 = new String(out.getData(), 2, out.getLength()-2, "UTF-8"); assertEquals(before, after3); } }
public void testIO() throws Exception { DataOutputBuffer out = new DataOutputBuffer(); DataInputBuffer in = new DataInputBuffer(); for (int i = 0; i < 10000; i++) { // generate a random string String before = getTestString(); // write it out.reset(); UTF8.writeString(out, before); // test that it reads correctly in.reset(out.getData(), out.getLength()); String after = UTF8.readString(in); assertEquals(before, after); // test that it reads correctly with DataInput in.reset(out.getData(), out.getLength()); String after2 = in.readUTF(); assertEquals(before, after2); } }
public void testIO() throws Exception { DataOutputBuffer out = new DataOutputBuffer(); DataInputBuffer in = new DataInputBuffer(); for (int i = 0; i < 10000; i++) { // generate a random string String before = getTestString(); // write it out.reset(); UTF8.writeString(out, before); // test that it reads correctly in.reset(out.getData(), out.getLength()); String after = UTF8.readString(in); assertEquals(before, after); // test that it reads correctly with DataInput in.reset(out.getData(), out.getLength()); String after2 = in.readUTF(); assertEquals(before, after2); } }