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

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

public class ChannelPostingsInput
extends java.lang.Object
implements PostingsInput

A class for reading postings from a channel.

This implementation is most useful for reading postings that will be used in evaluating queries.


Field Summary
protected  java.nio.channels.FileChannel chan
          The channel.
protected  boolean full
          If true, full buffers will be read from the channel.
 
Constructor Summary
ChannelPostingsInput(java.nio.channels.FileChannel chan, boolean full)
          Creates a postings channel that will read postings from the given channel, using the given base offset.
 
Method Summary
 ReadableBuffer read(long offset, int size)
          Reads postings from the channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chan

protected java.nio.channels.FileChannel chan
The channel.


full

protected boolean full
If true, full buffers will be read from the channel.

Constructor Detail

ChannelPostingsInput

public ChannelPostingsInput(java.nio.channels.FileChannel chan,
                            boolean full)
Creates a postings channel that will read postings from the given channel, using the given base offset.

Parameters:
chan - The channel from which we'll read postings.
full - If true, then we will fully read postings from the postings file before returning them. In this case, an instance of NIOBuffer is returned. If false, then postings will be only partially read from the file. In this case, an instance of ChannelReadableBuffer is returned.
Method Detail

read

public ReadableBuffer read(long offset,
                           int size)
                    throws java.io.IOException
Reads postings from the channel.

Specified by:
read in interface PostingsInput
Parameters:
offset - The offset from which the postings will be read.
size - The size of the postings to read.
Returns:
A readable buffer containing the postings.
Throws:
java.io.IOException - If there is any error reading from the channel.
See Also:
ReadableBuffer