net.jot.persistance
Class JOTFSIndex

java.lang.Object
  extended by net.jot.persistance.JOTFSIndex

public class JOTFSIndex
extends java.lang.Object

Represents an index for an FSDB database Used to find data faster and index/vacuum it. Note that the data file contains all it needs on it's own. The index can actually be rebuilt from the data file (ie: using JOTFSQueryImpl.vacuum())

Author:
tcolar

Field Summary
 long highestId
          Stores the current highest ID found in the data file, so we can get the next unique higher value using nextval()
 
Constructor Summary
JOTFSIndex()
           
 
Method Summary
 void addEntry(long id, long offset)
          hen a new entry is added to the data file(table), this should be called as well to update the index with it.
 void closeFile()
           
 void deleteEntry(long id)
          Call this after removing an entry from the data(table) This will remove it from the index as well.
 long getIndexValue(long index)
          Returns the position od a data row given it's index
 long nextVal()
          When adding a new entry, call this method to get the next unique index value.
 void setDataOffset(long id, long offset)
          Updates the offset of a data file row in the index
 void setFile(java.io.RandomAccessFile indexFile)
          Sets the index file
 void setIndexIndexOffset(long id, long indexPos)
          Updates the IndexIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

highestId

public long highestId
Stores the current highest ID found in the data file, so we can get the next unique higher value using nextval()

Constructor Detail

JOTFSIndex

public JOTFSIndex()
Method Detail

getIndexValue

public long getIndexValue(long index)
Returns the position od a data row given it's index

Parameters:
index -
Returns:

setDataOffset

public void setDataOffset(long id,
                          long offset)
                   throws java.lang.Exception
Updates the offset of a data file row in the index

Parameters:
index -
value -
Throws:
java.lang.Exception

nextVal

public long nextVal()
When adding a new entry, call this method to get the next unique index value.

Returns:

setFile

public void setFile(java.io.RandomAccessFile indexFile)
Sets the index file

Parameters:
indexFile -

addEntry

public void addEntry(long id,
                     long offset)
              throws java.lang.Exception
hen a new entry is added to the data file(table), this should be called as well to update the index with it.

Parameters:
indexFile -
id -
offset -
Throws:
java.lang.Exception

closeFile

public void closeFile()

deleteEntry

public void deleteEntry(long id)
                 throws java.lang.Exception
Call this after removing an entry from the data(table) This will remove it from the index as well.

Parameters:
id -
Throws:
java.lang.Exception

setIndexIndexOffset

public void setIndexIndexOffset(long id,
                                long indexPos)
Updates the IndexIndex

Parameters:
id -
indexPos -