Class BinarySearcherOverBlockSource
java.lang.Object
org.aksw.commons.io.hadoop.binseach.v2.BinarySearcherOverBlockSource
- All Implemented Interfaces:
AutoCloseable,BinarySearcher
Binary search implementation that finds lines matching a prefix in a
'block' source such as a bzip2 compressed file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BlockSourceprotected Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> -
Constructor Summary
ConstructorsConstructorDescriptionBinarySearcherOverBlockSource(BlockSource blockSource, Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier) -
Method Summary
Modifier and TypeMethodDescriptionstatic longadjustStart(BlockSource blockSource, long start, int depth, BinSearchLevelCache cache) Adjust a position to the next block.static MatchbinarySearch(BlockSource blockSource, byte[] prefix, BinSearchLevelCache cache) static MatchbinarySearch(BlockSource blockSource, SearchMode searchMode, int depth, long start, long startAfter, long end, byte delimiter, byte[] prefix, BinSearchLevelCache cache) When this method returns the input stream's position is unspecified.voidclose()Stream<ReadableChannelSupplier<byte[]>>parallelSearch(byte[] prefix) search(byte[] prefix) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aksw.commons.io.binseach.BinarySearcher
search
-
Field Details
-
blockSource
-
cacheSupplier
protected Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier
-
-
Constructor Details
-
BinarySearcherOverBlockSource
public BinarySearcherOverBlockSource(BlockSource blockSource, Supplier<org.aksw.commons.io.hadoop.binseach.v2.BinSearchResourceCache.CacheEntry> cacheSupplier)
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBinarySearcher- Throws:
Exception
-
search
- Specified by:
searchin interfaceBinarySearcher- Throws:
IOException
-
parallelSearch
- Specified by:
parallelSearchin interfaceBinarySearcher- Throws:
IOException
-
binarySearch
public static Match binarySearch(BlockSource blockSource, byte[] prefix, BinSearchLevelCache cache) throws IOException - Throws:
IOException
-
adjustStart
public static long adjustStart(BlockSource blockSource, long start, int depth, BinSearchLevelCache cache) throws IOException Adjust a position to the next block. It must hold that this function is idempotent: adjustStart(adjustStart(offset)) = adjustStart(offset)- Throws:
IOException
-
binarySearch
public static Match binarySearch(BlockSource blockSource, SearchMode searchMode, int depth, long start, long startAfter, long end, byte delimiter, byte[] prefix, BinSearchLevelCache cache) throws IOException When this method returns the input stream's position is unspecified.Note on cache semantics:
- Disposition is the mapping from the current offset to that of the next block (NOT the record).
- The header map maps the block id to the first record
- 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-startAfter- The adjusted start for the offset (start + 1)end-delimiter-prefix-- Returns:
- Throws:
IOException
-