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, org.aksw.commons.io.buffer.array.HasArrayOps<byte[]>, org.aksw.commons.io.input.ReadableChannel<byte[]>, org.aksw.commons.io.input.ReadableSource<byte[]>

public class ReadableChannelWithBlockAdvertisement extends org.aksw.commons.io.input.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
     
    protected InputStream
     
    protected int
     
    protected boolean
     
    protected byte
     
    protected long
     
    protected org.apache.hadoop.fs.Seekable
     
    protected long
     

    Fields inherited from class org.aksw.commons.util.closeable.AutoCloseableWithLeakDetectionBase

    instantiationStackTrace

    Fields inherited from class org.aksw.commons.util.closeable.AutoCloseableBase

    closeStackTrace, enableCloseStackTrace, isClosed
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ReadableChannelWithBlockAdvertisement(InputStream decodedIn, int endOfBlockMarker)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Discard bytes from this channel until a -2 read result is encountered.
    org.aksw.commons.io.buffer.array.ArrayOps<byte[]>
     
    long
     
    long
     
    protected int
    onBlockEnd(ByteBuffer dst, long oldPos, long newPos)
     
    long
     
    int
    read(byte[] array, int position, int length)
     

    Methods inherited from class org.aksw.commons.io.shared.ChannelBase

    isOpen

    Methods inherited from class org.aksw.commons.util.closeable.AutoCloseableWithLeakDetectionBase

    finalize, getInstantiationStackTrace

    Methods inherited from class org.aksw.commons.util.closeable.AutoCloseableBase

    close, closeActual, ensureOpen, throwClosedException

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.nio.channels.Channel

    close, isOpen

    Methods inherited from interface org.aksw.commons.io.input.ReadableSource

    readRaw
  • 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 org.aksw.commons.io.buffer.array.ArrayOps<byte[]> getArrayOps()
    • adjustToNextBlock

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