Class BinarySearcherOverPlainSource

java.lang.Object
org.aksw.commons.io.hadoop.binseach.v2.BinarySearcherOverPlainSource
All Implemented Interfaces:
AutoCloseable, org.aksw.commons.io.binseach.BinarySearcher

public class BinarySearcherOverPlainSource extends Object implements org.aksw.commons.io.binseach.BinarySearcher
Binary search over an non-encoded SeekableInputStreams. Non-encoded means that every byte is individually addressable (in contrast to block-based stream/channels).
  • Field Details

    • source

      protected org.aksw.commons.io.input.SeekableReadableChannelSource<byte[]> source
    • cacheSupplier

      protected Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier
  • Constructor Details

    • BinarySearcherOverPlainSource

      protected BinarySearcherOverPlainSource(org.aksw.commons.io.input.SeekableReadableChannelSource<byte[]> source, Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier)
  • Method Details

    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.aksw.commons.io.binseach.BinarySearcher
      Throws:
      Exception
    • binarySearch

      public static Match binarySearch(SeekableInputStream channel, long end, byte[] prefix) throws IOException
      Throws:
      IOException
    • of

      public static BinarySearcherOverPlainSource of(org.aksw.commons.io.input.SeekableReadableChannelSource<byte[]> source, Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier)
    • of

      public static BinarySearcherOverPlainSource of(Path path, Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier)
    • search

      public InputStream search(byte[] prefix) throws IOException
      Specified by:
      search in interface org.aksw.commons.io.binseach.BinarySearcher
      Throws:
      IOException
    • parallelSearch

      public Stream<org.aksw.commons.io.input.ReadableChannelSupplier<byte[]>> parallelSearch(byte[] prefix) throws IOException
      Specified by:
      parallelSearch in interface org.aksw.commons.io.binseach.BinarySearcher
      Throws:
      IOException
    • binarySearch

      public static Match binarySearch(SeekableInputStream in, SearchMode searchMode, int depth, long start, long end, long knownDelimPos, byte delimiter, byte[] prefix, BinSearchLevelCache cache) throws IOException
      When this method returns the input stream's position is unspecified.
      Parameters:
      in - The seekable input stream on which to perform binary search for the given prefix.
      searchMode - Whether we are searching the initial match, or the start or end of a run of matches.
      start -
      end -
      delimiter -
      prefix -
      Returns:
      Throws:
      IOException