org.archive.wayback.util.flatfile
Class FlatFile
java.lang.Object
org.archive.wayback.util.flatfile.FlatFile
- Direct Known Subclasses:
- CachedFile, CDXIndex
public class FlatFile
- extends java.lang.Object
Subclass of File, which allows binary searching, returning Iterators
that allow scanning forwards and backwards thru the (sorted) file starting
from a particular prefix.
- Version:
- $Date: 2008-06-03 17:08:01 -0700 (Tue, 03 Jun 2008) $, $Revision: 2279 $
- Author:
- brad
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FlatFile
public FlatFile()
FlatFile
public FlatFile(java.io.File parent,
java.lang.String child)
- Parameters:
parent - child -
FlatFile
public FlatFile(java.lang.String path)
- Parameters:
path -
setPath
public void setPath(java.lang.String path)
- Parameters:
path - to set
getPath
public java.lang.String getPath()
- Returns:
- current String path, or null if none has been set
findKeyOffset
public long findKeyOffset(java.io.RandomAccessFile fh,
java.lang.String key)
throws java.io.IOException
- Binary search thru RandomAccessFile argument to locate the first line
prefixed by key argument. As a side effect, the RandomAccessFile's
position is also set to the start of the first matching line.
- Parameters:
fh - key -
- Returns:
- long offset where first record prefixed with key is found
- Throws:
java.io.IOException
getLastMatchOffset
public long getLastMatchOffset()
- Returns:
- Returns the lastMatchOffset.
getSequentialIterator
public CloseableIterator<java.lang.String> getSequentialIterator()
throws java.io.IOException
- Returns:
- Iterator returning one String object for each line in the file.
- Throws:
java.io.IOException
getRecordIterator
public java.util.Iterator<java.lang.String> getRecordIterator(java.lang.String prefix)
throws java.io.IOException
- Parameters:
prefix -
- Returns:
- Iterator for records beggining with key
- Throws:
java.io.IOException
getReverseRecordIterator
public ReverseRecordIterator getReverseRecordIterator(java.lang.String prefix)
throws java.io.IOException
- Parameters:
prefix -
- Returns:
- ReverseRecordIterator positioned to return the first line BEFORE
prefix at the first call to readPrevLine().
- Throws:
java.io.IOException
store
public void store(java.util.Iterator<java.lang.String> itr)
throws java.io.IOException
- Throws:
java.io.IOException
main
public static void main(java.lang.String[] args)
- Parameters:
args -
Copyright © 2005-2009 Internet Archive. All Rights Reserved.