org.apache.lucene.store.jdbc.index
Class JdbcBufferedIndexInput

java.lang.Object
  extended by org.apache.lucene.store.IndexInput
      extended by org.apache.lucene.store.jdbc.index.JdbcBufferedIndexInput
All Implemented Interfaces:
Cloneable, JdbcIndexConfigurable
Direct Known Subclasses:
FetchOnBufferReadJdbcIndexInput, FetchPerTransactionJdbcIndexInput

public abstract class JdbcBufferedIndexInput
extends IndexInput
implements JdbcIndexConfigurable

A simple base class that performs index input memory based buffering. The buffer size can be configured under the BUFFER_SIZE_SETTING name.

Author:
kimchy

Field Summary
protected  byte[] buffer
           
static String BUFFER_SIZE_SETTING
          The buffer size setting name.
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
JdbcBufferedIndexInput()
           
 
Method Summary
 Object clone()
           
 void configure(String name, JdbcDirectory jdbcDirectory, JdbcFileEntrySettings settings)
          Configures the newly created IndexInput or IndexOutput implementations.
 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.
 
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

BUFFER_SIZE_SETTING

public static final String BUFFER_SIZE_SETTING
The buffer size setting name. See JdbcFileEntrySettings.setIntSetting(String, int). Should be set in bytes.

See Also:
Constant Field Values

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

JdbcBufferedIndexInput

public JdbcBufferedIndexInput()
Method Detail

configure

public void configure(String name,
                      JdbcDirectory jdbcDirectory,
                      JdbcFileEntrySettings settings)
               throws IOException
Description copied from interface: JdbcIndexConfigurable
Configures the newly created IndexInput or IndexOutput implementations.

Specified by:
configure in interface JdbcIndexConfigurable
Parameters:
name - The name of the file entry
jdbcDirectory - The jdbc directory instance
settings - The relevant file entry settings
Throws:
IOException

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.