@Test public void testParsingWritableReference() throws IOException { final String datafile = System.getProperty("project.build.testSourceDirectory", "src/test") + File.separator + "data" + File.separator + "a6a6562b777440fd9c34885428f5cb61.21e75333ada3d5bafb34bb918f29576c"; FileSystem fs = FileSystem.get(HTU.getConfiguration()); Reference.read(fs, new Path(datafile)); }
public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in)); in.reset(); Reference r = new Reference(); DataInputStream dis = new DataInputStream(in); in = dis; r.readFields(dis); return r; } finally { in.close(); } }
Reference { public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in)); in.reset(); Reference r = new Reference(); DataInputStream dis = new DataInputStream(in); in = dis; r.readFields(dis); return r; } finally { in.close(); } } }
Reference { public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in)); in.reset(); Reference r = new Reference(); DataInputStream dis = new DataInputStream(in); in = dis; r.readFields(dis); return r; } finally { in.close(); } } Reference(final byte [] splitRow, final Range fr); @Deprecated // Make this private when it comes time to let go of this constructor. Needed by pb serialization.  Reference(); }
Reference { public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in)); in.reset(); Reference r = new Reference(); DataInputStream dis = new DataInputStream(in); in = dis; r.readFields(dis); return r; } finally { in.close(); } } Reference(final byte [] splitRow, final Range fr); @Deprecated // Make this private when it comes time to let go of this constructor. Needed by pb serialization.  Reference(); static Reference createTopReference(final byte [] splitRow); static Reference createBottomReference(final byte [] splitRow); Range getFileRegion(); byte [] getSplitKey(); @Override String toString(); static boolean isTopFileRegion(final Range r); @Deprecated void readFields(DataInput in); Path write(final FileSystem fs, final Path p); static Reference read(final FileSystem fs, final Path p); FSProtos.Reference convert(); static Reference convert(final FSProtos.Reference r); }
Reference { public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in)); in.reset(); Reference r = new Reference(); DataInputStream dis = new DataInputStream(in); in = dis; r.readFields(dis); return r; } finally { in.close(); } } Reference(final byte [] splitRow, final Range fr); @Deprecated // Make this private when it comes time to let go of this constructor. Needed by pb serialization.  Reference(); static Reference createTopReference(final byte [] splitRow); static Reference createBottomReference(final byte [] splitRow); Range getFileRegion(); byte [] getSplitKey(); @Override String toString(); static boolean isTopFileRegion(final Range r); @Deprecated void readFields(DataInput in); Path write(final FileSystem fs, final Path p); static Reference read(final FileSystem fs, final Path p); FSProtos.Reference convert(); static Reference convert(final FSProtos.Reference r);  }