@Override public void mark(int readlimit) { in.mark(readlimit); }
/** * Parses an RegionInfo instance from the passed in stream. * Presumes the RegionInfo was serialized to the stream with * {@link #toDelimitedByteArray(RegionInfo)}. * @param in * @return An instance of RegionInfo. * @throws IOException */ static RegionInfo parseFrom(final DataInputStream in) throws IOException { // I need to be able to move back in the stream if this is not a pb // serialization so I can do the Writable decoding instead. int pblen = ProtobufUtil.lengthOfPBMagic(); byte [] pbuf = new byte[pblen]; if (in.markSupported()) { //read it with mark() in.mark(pblen); } //assumption: if Writable serialization, it should be longer than pblen. int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) { return ProtobufUtil.toRegionInfo(HBaseProtos.RegionInfo.parseDelimitedFrom(in)); } else { throw new IOException("PB encoded RegionInfo expected"); } }
@Override public void mark(int readlimit) { in.mark(readlimit); }
/** * Parses an HRegionInfo instance from the passed in stream. Presumes the HRegionInfo was * serialized to the stream with {@link #toDelimitedByteArray()} * @param in * @return An instance of HRegionInfo. * @throws IOException * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 * Use {@link RegionInfo#parseFrom(DataInputStream)}. */ @Deprecated @InterfaceAudience.Private public static HRegionInfo parseFrom(final DataInputStream in) throws IOException { // I need to be able to move back in the stream if this is not a pb serialization so I can // do the Writable decoding instead. int pblen = ProtobufUtil.lengthOfPBMagic(); byte [] pbuf = new byte[pblen]; if (in.markSupported()) { //read it with mark() in.mark(pblen); } //assumption: if Writable serialization, it should be longer than pblen. int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen); if (ProtobufUtil.isPBMagicPrefix(pbuf)) { return convert(HBaseProtos.RegionInfo.parseDelimitedFrom(in)); } else { throw new IOException("PB encoded HRegionInfo expected"); } }
@Override public void mark(int readlimit) { in.mark(readlimit); }
if (in.markSupported()) in.mark(pblen); int read = in.read(pbuf); if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
@Override public void mark(int readlimit) { in.mark(readlimit); }
@Override public byte peekByte() throws IOException { data.mark(1); byte value = data.readByte(); data.reset(); return value; } }
protected boolean hasInput() throws IOException { din.mark(1); if (din.read() >= 0) { din.reset(); return true; } return false; }
@Override public SearchTerm<byte[]> nextTerm() throws IOException { inStream.mark(1); final int nextByte = inStream.read(); if (nextByte == -1) { return null; } inStream.reset(); final int termLength = inStream.readInt(); final byte[] term = new byte[termLength]; inStream.readFully(term); return new SearchTerm<>(term); }
public static boolean nextPacketIsAuth(DataInputStream din) throws IOException { din.mark(32); BinaryInputArchive bia = new BinaryInputArchive(din); boolean firstIsAuth = (bia.readLong("NO_TAG") == QuorumAuth.QUORUM_AUTH_MAGIC_NUMBER); din.reset(); return firstIsAuth; } }
private SwapDeserializer createSwapDeserializer(final DataInputStream dis) throws IOException { dis.mark(MAGIC_HEADER.length); final byte[] magicHeader = new byte[MAGIC_HEADER.length]; try { StreamUtils.fillBuffer(dis, magicHeader); } catch (final EOFException eof) { throw new IOException("Failed to read swap file because the file contained less than 4 bytes of data"); } if (Arrays.equals(magicHeader, MAGIC_HEADER)) { final String serializationName = dis.readUTF(); if (serializationName.equals(SchemaSwapDeserializer.getSerializationName())) { return new SchemaSwapDeserializer(); } throw new IOException("Cannot find a suitable Deserializer for swap file, written with Serialization Name '" + serializationName + "'"); } else { // SimpleSwapDeserializer is old and did not write out a magic header. dis.reset(); return new SimpleSwapDeserializer(); } }
public static boolean nextPacketIsAuth(DataInputStream din) throws IOException { din.mark(32); BinaryInputArchive bia = new BinaryInputArchive(din); boolean firstIsAuth = (bia.readLong("NO_TAG") == QuorumAuth.QUORUM_AUTH_MAGIC_NUMBER); din.reset(); return firstIsAuth; } }
public BTraceProbe createProbe(InputStream code, ArgsMap argsMap) { BTraceProbe bp = null; try (DataInputStream dis = new DataInputStream(code)) { dis.mark(0); int mgc = dis.readInt(); if (mgc == BTraceProbePersisted.MAGIC) { BTraceProbePersisted bpp = new BTraceProbePersisted(this); bpp.read(dis); bp = bpp; } else { code.reset(); bp = new BTraceProbeNode(this, code); } } catch (IOException e) { if (debug.isDebug()) { debug.debug(e); } } applyArgs(bp, argsMap); return bp; }
/** * Parses a PFB file into a PFBData object. * @param in InputStream to load the PFB file from * @return PFBData memory representation of the font * @throws IOException In case of an I/O problem */ public PFBData parsePFB(InputStream in) throws IOException { PFBData pfb = new PFBData(); BufferedInputStream bin = new BufferedInputStream(in); DataInputStream din = new DataInputStream(bin); din.mark(32); int firstByte = din.readUnsignedByte(); din.reset(); if (firstByte == 128) { pfb.setPFBFormat(PFBData.PFB_PC); parsePCFormat(pfb, din); } else { pfb.setPFBFormat(PFBData.PFB_RAW); parseRAWFormat(pfb, bin); } return pfb; }
try { this.dataIn.mark(10); int type = this.dataIn.read(); if (type == -1) {
try { if (this.updateOK) { this.dataIn.mark(BUFFER_SIZE);
try { this.dataIn.mark(10); int type = this.dataIn.read(); if (type == -1) {
initializeReading(); try { this.dataIn.mark(33); int type = this.dataIn.read(); if (type == -1) {
try { this.dataIn.mark(17); int type = this.dataIn.read(); if (type == -1) {