dk.netarkivet.common.utils.cdx
Class BinSearch

java.lang.Object
  extended by dk.netarkivet.common.utils.cdx.BinSearch

public class BinSearch
extends java.lang.Object

Performs a binary search through .cdx files for a given prefix string. Currently only handles a single .cdx file.


Constructor Summary
BinSearch()
           
 
Method Summary
static java.lang.Iterable<java.lang.String> getLinesInFile(java.io.File file, java.lang.String prefix)
          Given a file in sorted order and a prefix to search for, return a an iterable that will return the lines in the files that start with the prefix, in order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinSearch

public BinSearch()
Method Detail

getLinesInFile

public static java.lang.Iterable<java.lang.String> getLinesInFile(java.io.File file,
                                                                  java.lang.String prefix)
Given a file in sorted order and a prefix to search for, return a an iterable that will return the lines in the files that start with the prefix, in order. They will be read lazily from the file. If no matches are found, it will still return an iterable with no entries.

Parameters:
file - A CDX file to search in.
prefix - The line prefix to search for.
Returns:
An Iterable object that will return the lines matching the prefix in the file.