org.apache.lucene.store
Class ConfigurableBufferedIndexInput

java.lang.Object
  extended by org.apache.lucene.store.IndexInput
      extended by org.apache.lucene.store.ConfigurableBufferedIndexInput
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
JdbcBufferedIndexInput

public abstract class ConfigurableBufferedIndexInput
extends IndexInput

A simple base class that performs index input memory based buffering. Allows the buffer size to be configurable.

Author:
kimchy

Field Summary
protected  byte[] buffer
           
static int BUFFER_SIZE
          Default buffer size
protected  int bufferLength
           
protected  int bufferPosition
           
protected  int bufferSize
           
protected  long bufferStart
           
 
Constructor Summary
ConfigurableBufferedIndexInput()
           
ConfigurableBufferedIndexInput(int bufferSize)
          Inits BufferedIndexInput with a specific bufferSize
 
Method Summary
 Object clone()
           
 int getBufferSize()
          Returns buffer size.
 long getFilePointer()
           
 byte readByte()
           
 void readBytes(byte[] b, int offset, int len)
           
protected abstract  void readInternal(byte[] b, int offset, int length)
          Expert: implements buffer refill.
protected  void refill()
           
 void seek(long pos)
           
protected abstract  void seekInternal(long pos)
          Expert: implements seek.
 void setBufferSize(int newSize)
          Change the buffer size used by this IndexInput
 
Methods inherited from class org.apache.lucene.store.IndexInput
close, length, readBytes, readChars, readInt, readLong, readString, readVInt, readVLong, setModifiedUTF8StringsMode, skipChars
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
Default buffer size

See Also:
Constant Field Values

bufferSize

protected int bufferSize

buffer

protected byte[] buffer

bufferStart

protected long bufferStart

bufferLength

protected int bufferLength

bufferPosition

protected int bufferPosition
Constructor Detail

ConfigurableBufferedIndexInput

public ConfigurableBufferedIndexInput()

ConfigurableBufferedIndexInput

public ConfigurableBufferedIndexInput(int bufferSize)
Inits BufferedIndexInput with a specific bufferSize

Method Detail

readByte

public byte readByte()
              throws IOException
Specified by:
readByte in class IndexInput
Throws:
IOException

setBufferSize

public void setBufferSize(int newSize)
Change the buffer size used by this IndexInput


getBufferSize

public int getBufferSize()
Returns buffer size. @see #setBufferSize


readBytes

public void readBytes(byte[] b,
                      int offset,
                      int len)
               throws IOException
Specified by:
readBytes in class IndexInput
Throws:
IOException

refill

protected void refill()
               throws IOException
Throws:
IOException

readInternal

protected abstract void readInternal(byte[] b,
                                     int offset,
                                     int length)
                              throws IOException
Expert: implements buffer refill. Reads bytes from the current position in the input.

Parameters:
b - the array to read bytes into
offset - the offset in the array to start storing bytes
length - the number of bytes to read
Throws:
IOException

getFilePointer

public long getFilePointer()
Specified by:
getFilePointer in class IndexInput

seek

public void seek(long pos)
          throws IOException
Specified by:
seek in class IndexInput
Throws:
IOException

seekInternal

protected abstract void seekInternal(long pos)
                              throws IOException
Expert: implements seek. Sets current position in this file, where the next readInternal(byte[],int,int) will occur.

Throws:
IOException
See Also:
readInternal(byte[],int,int)

clone

public Object clone()
Overrides:
clone in class IndexInput


Copyright (c) 2004-2008 The Compass Project.