Class ReadableChannelWithBlockAdvertisement

java.lang.Object
org.aksw.commons.util.closeable.AutoCloseableBase
org.aksw.commons.util.closeable.AutoCloseableWithLeakDetectionBase
org.aksw.commons.io.shared.ChannelBase
org.aksw.commons.io.input.ReadableChannelBase<byte[]>
org.aksw.commons.io.hadoop.ReadableChannelWithBlockAdvertisement
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, HasArrayOps<byte[]>, ReadableChannel<byte[]>, ReadableSource<byte[]>

public class ReadableChannelWithBlockAdvertisement extends ReadableChannelBase<byte[]>
This variant assumes that the underlying encoded stream runs in BLOCK_MODE. Reads are expected to:
  1. stop after yielding the first byte of a block (that byte is returned) and
  2. these reads always return 1 (never anything greater)
  3. the position indicating the block id is updated after that read.
ReadableChannelWithBlockAdvertisementBuffered also assumes that every read stops after yielding the first byte of a block, however the read length may be greater than 1.
  • Field Details

    • decodedIn

      protected InputStream decodedIn
    • seekable

      protected org.apache.hadoop.fs.Seekable seekable
    • startPos

      protected long startPos
    • currentPos

      protected long currentPos
    • pendingByte

      protected byte pendingByte
    • hasPendingByte

      protected boolean hasPendingByte
    • endOfBlockMarker

      protected int endOfBlockMarker
    • readCount

      protected long readCount
  • Constructor Details

  • Method Details

    • position

      public long position() throws IOException
      Throws:
      IOException
    • getStartPos

      public long getStartPos()
    • getCurrentPos

      public long getCurrentPos()
    • read

      public int read(byte[] array, int position, int length) throws IOException
      Throws:
      IOException
    • onBlockEnd

      protected int onBlockEnd(ByteBuffer dst, long oldPos, long newPos)
    • getArrayOps

      public ArrayOps<byte[]> getArrayOps()
    • adjustToNextBlock

      public boolean adjustToNextBlock() throws IOException
      Discard bytes from this channel until a -2 read result is encountered.
      Throws:
      IOException