com.timeindexing.io
Interface IndexFileReader

All Known Subinterfaces:
IndexFileInteractor
All Known Implementing Classes:
AbstractFileIO, ExternalIndexIO, InlineIndexIO, ShadowIndexIO

public interface IndexFileReader

An interface for readers of indexes.


Method Summary
 long close()
          Close the index.
 DataHolderObject convertDataReference(DataReference ref)
          Read some data, given a DataReference and return it as a DataHolderObject.
 ManagedIndexItem getItem(long position, boolean withData)
          Get the item
 boolean gotoAppendPosition()
          Goto the append position
 boolean gotoFirstPosition()
          Goto the first position.
 long loadIndex(LoadStyle loadStyle)
          Load the index data, based on a specified LoadStyle.
 long open(IndexProperties indexProperties)
           
 java.nio.ByteBuffer readData(DataReference ref)
          Read some data, given a DataReferenceObject
 java.nio.ByteBuffer readData(long offset, long size)
          Read some data, given an offset and a size.
 java.nio.ByteBuffer readData(Offset offset, long size)
          Read some data, given an offset and a size.
 long readHeader(byte headerType)
          Read an index header from the header stream.
 ManagedIndexItem readItem(long offset, boolean withData)
          Read the contents of the item It assumes the index file is alreayd open for writing.
 ManagedIndexItem readItem(Offset offset, boolean withData)
          Read the contents of the item It assumes the index file is alreayd open for writing.
 long readMetaData()
          Read all the meta data.
 boolean setAppendPosition()
          Set the append position
 

Method Detail

open

public long open(IndexProperties indexProperties)
          throws java.io.IOException,
                 IndexOpenException
Throws:
java.io.IOException
IndexOpenException

readHeader

public long readHeader(byte headerType)
                throws java.io.IOException,
                       IndexOpenException
Read an index header from the header stream.

Parameters:
headerType - the type of header, e.g FileType.INLINE_INDEX or FileType.EXTERNAL_INDEX
Throws:
java.io.IOException
IndexOpenException

readMetaData

public long readMetaData()
                  throws java.io.IOException,
                         IndexOpenException
Read all the meta data.

Throws:
java.io.IOException
IndexOpenException

getItem

public ManagedIndexItem getItem(long position,
                                boolean withData)
                         throws java.io.IOException
Get the item

Parameters:
position - the position of the index item to get
withData - read the data for this IndexItem if withData is true, the data needs to be read at a later time, otherwise
Throws:
java.io.IOException

readItem

public ManagedIndexItem readItem(Offset offset,
                                 boolean withData)
                          throws java.io.IOException
Read the contents of the item It assumes the index file is alreayd open for writing.

Parameters:
offset - the byte offset in the file to start reading an item from
withData - read the data for this IndexItem if withData is true, the data needs to be read at a later time, otherwise
Throws:
java.io.IOException

readItem

public ManagedIndexItem readItem(long offset,
                                 boolean withData)
                          throws java.io.IOException
Read the contents of the item It assumes the index file is alreayd open for writing.

Parameters:
offset - the byte offset in the file to start reading an item from
withData - read the data for this IndexItem if withData is true, the data needs to be read at a later time, otherwise
Throws:
java.io.IOException

readData

public java.nio.ByteBuffer readData(Offset offset,
                                    long size)
                             throws java.io.IOException
Read some data, given an offset and a size.

Parameters:
offset - the byte offset in the file to start reading an item from
size - the number of bytes to read
Throws:
java.io.IOException

readData

public java.nio.ByteBuffer readData(long offset,
                                    long size)
                             throws java.io.IOException
Read some data, given an offset and a size.

Parameters:
offset - the byte offset in the file to start reading an item from
size - the number of bytes to read
Throws:
java.io.IOException

readData

public java.nio.ByteBuffer readData(DataReference ref)
                             throws java.io.IOException
Read some data, given a DataReferenceObject

Throws:
java.io.IOException

convertDataReference

public DataHolderObject convertDataReference(DataReference ref)
Read some data, given a DataReference and return it as a DataHolderObject.


loadIndex

public long loadIndex(LoadStyle loadStyle)
               throws java.io.IOException
Load the index data, based on a specified LoadStyle.

Throws:
java.io.IOException

gotoFirstPosition

public boolean gotoFirstPosition()
                          throws java.io.IOException
Goto the first position.

Throws:
java.io.IOException

gotoAppendPosition

public boolean gotoAppendPosition()
                           throws java.io.IOException
Goto the append position

Throws:
java.io.IOException

setAppendPosition

public boolean setAppendPosition()
                          throws java.io.IOException
Set the append position

Throws:
java.io.IOException

close

public long close()
           throws java.io.IOException
Close the index.

Throws:
java.io.IOException