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:
FSTransLog.TransDirectory.TransIndexInput, 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
           
protected  int bufferLength
           
protected  int bufferPosition
           
protected  int bufferSize
           
protected  long bufferStart
           
static int DEFAULT_BUFFER_SIZE
          The default value for the buffer size (in bytes).
 
Constructor Summary
ConfigurableBufferedIndexInput()
           
 
Method Summary
 Object clone()
           
 long getFilePointer()
           
protected  void initBuffer(int bufferSize)
           
 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.
 
Methods inherited from class org.apache.lucene.store.IndexInput
close, length, readChars, readInt, readLong, readString, readVInt, readVLong
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default value for the buffer size (in bytes). Currently 1024.

See Also:
Constant Field Values

buffer

protected byte[] buffer

bufferStart

protected long bufferStart

bufferLength

protected int bufferLength

bufferPosition

protected int bufferPosition

bufferSize

protected int bufferSize
Constructor Detail

ConfigurableBufferedIndexInput

public ConfigurableBufferedIndexInput()
Method Detail

initBuffer

protected void initBuffer(int bufferSize)

readByte

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

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-2006 The Compass Project.