/** * Parses all the HRegionInfo instances from the passed in stream until EOF. Presumes the * HRegionInfo's were serialized to the stream with {@link #toDelimitedByteArray()} * @param bytes serialized bytes * @param offset the start offset into the byte[] buffer * @param length how far we should read into the byte[] buffer * @return All the hregioninfos that are in the byte array. Keeps reading till we hit the end. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * Use {@link RegionInfo#parseDelimitedFrom(byte[], int, int)}. */ @Deprecated public static List<HRegionInfo> parseDelimitedFrom(final byte[] bytes, final int offset, final int length) throws IOException { if (bytes == null) { throw new IllegalArgumentException("Can't build an object with empty bytes array"); } DataInputBuffer in = new DataInputBuffer(); List<HRegionInfo> hris = new ArrayList<>(); try { in.reset(bytes, offset, length); while (in.available() > 0) { HRegionInfo hri = parseFrom(in); hris.add(hri); } } finally { in.close(); } return hris; }
return w; } finally { in.close();
@Override public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
/** * Parses all the RegionInfo instances from the passed in stream until EOF. Presumes the * RegionInfo's were serialized to the stream with oDelimitedByteArray() * @param bytes serialized bytes * @param offset the start offset into the byte[] buffer * @param length how far we should read into the byte[] buffer * @return All the RegionInfos that are in the byte array. Keeps reading till we hit the end. * @throws IOException */ static List<RegionInfo> parseDelimitedFrom(final byte[] bytes, final int offset, final int length) throws IOException { if (bytes == null) { throw new IllegalArgumentException("Can't build an object with empty bytes array"); } DataInputBuffer in = new DataInputBuffer(); List<RegionInfo> ris = new ArrayList<>(); try { in.reset(bytes, offset, length); while (in.available() > 0) { RegionInfo ri = parseFrom(in); ris.add(ri); } } finally { in.close(); } return ris; } }
public static TestSignable deserialize(byte[] bytes) throws IOException { DataInputBuffer db = new DataInputBuffer(); db.reset(bytes, bytes.length); int keyId = db.readInt(); byte b = db.readByte(); db.close(); return new TestSignable(keyId, b); }
/** * Test RegionInfo serialization * @throws Exception */ @Test public void testRegionInfo() throws Exception { HRegionInfo hri = createRandomRegion("testRegionInfo"); //test toByteArray() byte [] hrib = hri.toByteArray(); HRegionInfo deserializedHri = HRegionInfo.parseFrom(hrib); assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName()); assertEquals(hri, deserializedHri); //test toDelimitedByteArray() hrib = hri.toDelimitedByteArray(); DataInputBuffer buf = new DataInputBuffer(); try { buf.reset(hrib, hrib.length); deserializedHri = HRegionInfo.parseFrom(buf); assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName()); assertEquals(hri, deserializedHri); } finally { buf.close(); } }
return w; } finally { in.close();
/** * Parses all the HRegionInfo instances from the passed in stream until EOF. Presumes the * HRegionInfo's were serialized to the stream with {@link #toDelimitedByteArray()} * @param bytes serialized bytes * @param offset the start offset into the byte[] buffer * @param length how far we should read into the byte[] buffer * @return All the hregioninfos that are in the byte array. Keeps reading till we hit the end. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * Use {@link RegionInfo#parseDelimitedFrom(byte[], int, int)}. */ @Deprecated public static List<HRegionInfo> parseDelimitedFrom(final byte[] bytes, final int offset, final int length) throws IOException { if (bytes == null) { throw new IllegalArgumentException("Can't build an object with empty bytes array"); } DataInputBuffer in = new DataInputBuffer(); List<HRegionInfo> hris = new ArrayList<>(); try { in.reset(bytes, offset, length); while (in.available() > 0) { HRegionInfo hri = parseFrom(in); hris.add(hri); } } finally { in.close(); } return hris; }
/** * Parses all the RegionInfo instances from the passed in stream until EOF. Presumes the * RegionInfo's were serialized to the stream with oDelimitedByteArray() * @param bytes serialized bytes * @param offset the start offset into the byte[] buffer * @param length how far we should read into the byte[] buffer * @return All the RegionInfos that are in the byte array. Keeps reading till we hit the end. * @throws IOException */ static List<RegionInfo> parseDelimitedFrom(final byte[] bytes, final int offset, final int length) throws IOException { if (bytes == null) { throw new IllegalArgumentException("Can't build an object with empty bytes array"); } DataInputBuffer in = new DataInputBuffer(); List<RegionInfo> ris = new ArrayList<>(); try { in.reset(bytes, offset, length); while (in.available() > 0) { RegionInfo ri = parseFrom(in); ris.add(ri); } } finally { in.close(); } return ris; } }
@Override public void close() throws IOException { dataIn.close(); }
@Test public void testFSCheckpointIDSerialization() throws IOException { Path inpath = new Path("/tmp/blah"); FSCheckpointID cidin = new FSCheckpointID(inpath); DataOutputBuffer out = new DataOutputBuffer(); cidin.write(out); out.close(); FSCheckpointID cidout = new FSCheckpointID(null); DataInputBuffer in = new DataInputBuffer(); in.reset(out.getData(), 0, out.getLength()); cidout.readFields(in); in.close(); assert cidin.equals(cidout); }
/** * Close the file. */ public synchronized void close() throws IOException { deser.close(); inBuffer.close(); innerReader.close(); }
public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
@Override public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
@Override public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
@Override public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
@Override public void close() throws IOException { inBuf.close(); outBuf.close(); deserializer.close(); serializer.close(); }
public static Credentials parseCredentialsBytes(byte[] credentialsBytes) throws IOException { Credentials credentials = new Credentials(); DataInputBuffer dib = new DataInputBuffer(); try { byte[] tokenBytes = credentialsBytes; dib.reset(tokenBytes, tokenBytes.length); credentials.readTokenStorageStream(dib); return credentials; } finally { dib.close(); } }
private void validate(KeyValue kv, byte[] row, byte[] family, byte[] qualifier, long ts, Type type, byte[] value) throws IOException { DataOutputBuffer out = new DataOutputBuffer(); kv.write(out); out.close(); byte[] data = out.getData(); // read it back in KeyValue read = new KeyValue(); DataInputBuffer in = new DataInputBuffer(); in.reset(data, data.length); read.readFields(in); in.close(); // validate that its the same assertTrue("Row didn't match!", Bytes.equals(row, read.getRow())); assertTrue("Family didn't match!", Bytes.equals(family, read.getFamily())); assertTrue("Qualifier didn't match!", Bytes.equals(qualifier, read.getQualifier())); assertTrue("Value didn't match!", Bytes.equals(value, read.getValue())); assertEquals("Timestamp didn't match", ts, read.getTimestamp()); assertEquals("Type didn't match", type.getCode(), read.getType()); }