com.sun.labs.minion.indexer.postings.io
Class StreamPostingsInput

java.lang.Object
  extended by com.sun.labs.minion.indexer.postings.io.StreamPostingsInput
All Implemented Interfaces:
PostingsInput

public class StreamPostingsInput
extends java.lang.Object
implements PostingsInput

A postings input that can be used when streaming through a lot of postings sequentially as when merging or evaluating field queries. Random access is not supported, but sequential access should work well.


Field Summary
protected  byte[] b
          Our in-memory buffer.
protected static java.lang.String logTag
           
protected  long me
          The offset of the end of our in-memory buffer.
protected  long ms
          The offset of the start of our in-memory buffer.
 
Constructor Summary
StreamPostingsInput(java.io.RandomAccessFile postFile, int buffSize)
          Creates a stream postings input.
StreamPostingsInput(java.io.RandomAccessFile postFile, long offset, int buffSize)
          Creates a stream postings input.
 
Method Summary
protected  int read(long off)
          Reads some bytes from the stream.
 ReadableBuffer read(long offset, int size)
          Returns a buffer constructed from our internal buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ms

protected long ms
The offset of the start of our in-memory buffer.


me

protected long me
The offset of the end of our in-memory buffer.


b

protected byte[] b
Our in-memory buffer.


logTag

protected static java.lang.String logTag
Constructor Detail

StreamPostingsInput

public StreamPostingsInput(java.io.RandomAccessFile postFile,
                           int buffSize)
                    throws java.io.IOException
Creates a stream postings input.

Parameters:
postFile - The file from which the postings should be read.
buffSize - The size of the buffer to use.
Throws:
java.io.IOException - If there is any error reading the postings.

StreamPostingsInput

public StreamPostingsInput(java.io.RandomAccessFile postFile,
                           long offset,
                           int buffSize)
                    throws java.io.IOException
Creates a stream postings input.

Parameters:
postFile - The file from which the postings should be read.
offset - The offset at which the postings start.
buffSize - The size of the buffer to use.
Throws:
java.io.IOException - If there is any error reading the postings.
Method Detail

read

protected int read(long off)
            throws java.io.IOException
Reads some bytes from the stream.

Parameters:
off - The offset in the file from which the bytes should be read.
Returns:
The number of bytes read.
Throws:
java.io.IOException - If there is any error reading from the stream.

read

public ReadableBuffer read(long offset,
                           int size)
                    throws java.io.IOException
Returns a buffer constructed from our internal buffer.

Specified by:
read in interface PostingsInput
Parameters:
offset - The offset in the input at which the postings can be found.
size - The number of bytes to read to get the postings.
Returns:
A readable buffer containing the postings.
Throws:
java.io.IOException - if there is any error reading the postings.