org.apache.lucene.util
Class FileSorter.BlockReader

Object
  extended by FileSorter.BlockReader
All Implemented Interfaces:
Comparable
Enclosing class:
FileSorter

private static class FileSorter.BlockReader
extends Object
implements Comparable

Reads a block of compressed lines from the temporary disk file, and feeds them out one at a time. Is Comparable (which compares the current line) so it can be used in a PriorityQueue.


Field Summary
(package private)  RandomAccessFile base
          The temporary file being read
(package private)  ArrayList buffer
          Buffer of lines
(package private)  int cur
          Position within buffer
(package private)  boolean eof
          Set to true when last line has been read
(package private)  DataInput in
          Input source that decompresses and reads UTF strings
(package private)  long memLimit
          Memory limit for this particular reader
(package private)  long pos
          Current position within the random access file
 
Constructor Summary
FileSorter.BlockReader(RandomAccessFile base, long pos, int memLimit)
          Construct the reader
 
Method Summary
 int compareTo(Object other)
          Compare the current line of this reader with that of another.
 String cur()
          Obtain the current line of the file.
private  boolean fill()
          Fill the buffer with more lines.
 boolean next()
          Advance to the next line.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

RandomAccessFile base
The temporary file being read


in

DataInput in
Input source that decompresses and reads UTF strings


pos

long pos
Current position within the random access file


memLimit

long memLimit
Memory limit for this particular reader


buffer

ArrayList buffer
Buffer of lines


cur

int cur
Position within buffer


eof

boolean eof
Set to true when last line has been read

Constructor Detail

FileSorter.BlockReader

public FileSorter.BlockReader(RandomAccessFile base,
                              long pos,
                              int memLimit)
                       throws IOException
Construct the reader

Throws:
IOException
Method Detail

next

public boolean next()
             throws IOException
Advance to the next line. Must be called at least once before calling cur().

Returns:
true if there is another line, false if EOF
Throws:
IOException

cur

public String cur()
Obtain the current line of the file. Only valid if the last call to next() returned true.


compareTo

public int compareTo(Object other)
Compare the current line of this reader with that of another.

Specified by:
compareTo in interface Comparable

fill

private boolean fill()
              throws IOException
Fill the buffer with more lines.

Returns:
true if at least one line was read
Throws:
IOException