Class BlockSourceChannel

java.lang.Object
org.aksw.commons.io.hadoop.binseach.v2.BlockSourceChannel
All Implemented Interfaces:
Closeable, AutoCloseable, Cloneable, Channel, org.aksw.commons.io.buffer.array.HasArrayOps<byte[]>, org.aksw.commons.io.input.HasPosition, org.aksw.commons.io.input.ReadableChannel<byte[]>, org.aksw.commons.io.input.ReadableSource<byte[]>, org.aksw.commons.io.input.SeekableReadableChannel<byte[]>

public class BlockSourceChannel extends Object implements org.aksw.commons.io.input.SeekableReadableChannel<byte[]>
  • Field Details

    • codec

      protected final org.apache.hadoop.io.compress.SplittableCompressionCodec codec
    • encodedChannel

      protected final org.aksw.commons.io.input.SeekableReadableChannel<byte[]> encodedChannel
    • decodedChannelStart

      protected long decodedChannelStart
      The decoded channel is recreated on every first read after calling position(long).
    • decodedChannel

      protected ReadableChannelWithBlockAdvertisement decodedChannel
      The current non-seekable channel.
    • positionInBlock

      protected int positionInBlock
      The starting block id will be set after reading the first byte from the stream after its creation or setting the position.
    • pendingRead

      protected ByteBuffer pendingRead
    • decodedIn

      protected org.apache.hadoop.io.compress.SplitCompressionInputStream decodedIn
    • blockMode

      protected boolean blockMode
  • Constructor Details

    • BlockSourceChannel

      public BlockSourceChannel(org.aksw.commons.io.input.SeekableReadableChannel<byte[]> seekable, org.apache.hadoop.io.compress.SplittableCompressionCodec codec, boolean blockMode)
  • Method Details

    • ensureDecodedChannel

      public void ensureDecodedChannel() throws IOException
      Throws:
      IOException
    • resetTracker

      protected void resetTracker()
    • getStartingBlockId

      public long getStartingBlockId() throws IOException
      Throws:
      IOException
    • getCurrentBlockId

      public long getCurrentBlockId() throws IOException
      Throws:
      IOException
    • getPositionInBlock

      public int getPositionInBlock()
    • adjustToNextBlock

      public boolean adjustToNextBlock() throws IOException
      Throws:
      IOException
    • closeDecodedChannel

      protected void closeDecodedChannel() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • read

      public int read(byte[] array, int position, int length) throws IOException
      Specified by:
      read in interface org.aksw.commons.io.input.ReadableSource<byte[]>
      Throws:
      IOException
    • position

      public long position() throws IOException
      Specified by:
      position in interface org.aksw.commons.io.input.HasPosition
      Throws:
      IOException
    • position

      public void position(long newPosition) throws IOException
      Specified by:
      position in interface org.aksw.commons.io.input.HasPosition
      Throws:
      IOException
    • getArrayOps

      public org.aksw.commons.io.buffer.array.ArrayOps<byte[]> getArrayOps()
      Specified by:
      getArrayOps in interface org.aksw.commons.io.buffer.array.HasArrayOps<byte[]>
    • cloneObject

      public org.aksw.commons.io.input.SeekableReadableChannel<byte[]> cloneObject()
      Specified by:
      cloneObject in interface org.aksw.commons.io.input.SeekableReadableChannel<byte[]>