Class RangeBufferUnion<A>

java.lang.Object
org.aksw.commons.io.buffer.range.RangeBufferUnion<A>
Type Parameters:
A -
All Implemented Interfaces:
ArrayReadable<A>, ArrayWritable<A>, BufferLike<A>, HasArrayOps<A>, RangeBuffer<A>, ReadableChannelFactory<A>, ReadableChannelSource<A>, SeekableReadableChannelSource<A>

public class RangeBufferUnion<A> extends Object implements RangeBuffer<A>
A union view of two buffers. Writes go into the first one.
Author:
raven
  • Field Details

    • first

      protected RangeBuffer<A> first
    • second

      protected RangeBuffer<A> second
    • unionRanges

      protected com.google.common.collect.RangeSet<Long> unionRanges
  • Constructor Details

  • Method Details

    • create

      public static <A> RangeBufferUnion<A> create(RangeBuffer<A> first, RangeBuffer<A> second)
    • write

      public void write(long offsetInBuffer, A arrayWithItemsOfTypeT, int arrOffset, int arrLength) throws IOException
      Description copied from interface: ArrayWritable
      The method that needs to be implemented; all other methods default-delegate to this one.
      Specified by:
      write in interface ArrayWritable<A>
      Throws:
      IOException
    • put

      public void put(long offset, Object item)
      Specified by:
      put in interface ArrayWritable<A>
    • getArrayOps

      public ArrayOps<A> getArrayOps()
      Specified by:
      getArrayOps in interface HasArrayOps<A>
    • getCoveredRanges

      public com.google.common.collect.RangeSet<Long> getCoveredRanges(com.google.common.collect.Range<Long> localRange)
      Description copied from interface: RangeBuffer
      Return a set of contributions by this buffer for the given lookup range While this method does not expose which parts of the global range are covered, this method allows to check whether there are any gaps in the read
      Specified by:
      getCoveredRanges in interface RangeBuffer<A>
    • readInto

      public int readInto(A tgt, int tgtOffset, long srcOffset, int length) throws IOException
      Specified by:
      readInto in interface ArrayReadable<A>
      Throws:
      IOException
    • get

      public Object get(long index)
      Specified by:
      get in interface ArrayReadable<A>
    • getCapacity

      public long getCapacity()
      Description copied from interface: BufferLike
      Buffers with 'unlimited' capacity should return Long.MAX_VALUE
      Specified by:
      getCapacity in interface BufferLike<A>
    • getRanges

      public com.google.common.collect.RangeSet<Long> getRanges()
      Description copied from interface: RangeBuffer
      A set of ranges from which reading is valid. The range set may be shared among several range buffers and may thus include ranges outside of the range formed by the buffer's offset and capacity
      Specified by:
      getRanges in interface RangeBuffer<A>
    • getOffsetInRanges

      public Long getOffsetInRanges()
      Description copied from interface: RangeBuffer
      The offset within the range set where this buffer starts; may be null if the offset cannot be represented in a single value such as in a union of two buffers which have different offsets
      Specified by:
      getOffsetInRanges in interface RangeBuffer<A>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getBackingBuffer

      public Buffer<A> getBackingBuffer()
      Specified by:
      getBackingBuffer in interface RangeBuffer<A>