com.faunos.skwish.sys.mgr
Class MutableBaseIdIndex

java.lang.Object
  extended by com.faunos.skwish.sys.Index
      extended by com.faunos.skwish.sys.mgr.MutableBaseIdIndex
All Implemented Interfaces:
Closeable

public class MutableBaseIdIndex
extends Index

An index whose base ID can be adjusted.

Author:
Babak Farhang
See Also:
setBaseId(long)

Field Summary
protected  IndexMetrics mutableMetrics
           
 
Fields inherited from class com.faunos.skwish.sys.Index
BASEID_WIDTH, BASEOFFSET_WIDTH, ENTRYCOUNT_WIDTH, FIXED_HEADER_WIDTH, helper, indexFile, OFFSETWIDTH_WIDTH, validator
 
Constructor Summary
  MutableBaseIdIndex(FileChannel indexFile)
           
  MutableBaseIdIndex(FileChannel indexFile, boolean recover)
           
protected MutableBaseIdIndex(FileChannel indexFile, Word offsetWidth, long baseId, long baseOffset)
          Writes a new index to the specified file.
 
Method Summary
 IndexMetrics getMetrics()
          Returns the metrics of the index.
 void setBaseId(long baseId)
          Sets the base ID of the index by writing it to the backing file.
static MutableBaseIdIndex writeNewIndex(FileChannel indexFile, Word offsetWidth, long baseId, long baseOffset)
          Writes a new index to the specified file.
 
Methods inherited from class com.faunos.skwish.sys.Index
close, commit, delete, delete, flush, getContentsSize, getEntryCount, getIndexSize, getLastOffset, getNextId, isAutoCommit, killNext, killNext, pushNext, readOffsets, readOffsets, readOffsets, setAutoCommit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mutableMetrics

protected IndexMetrics mutableMetrics
Constructor Detail

MutableBaseIdIndex

public MutableBaseIdIndex(FileChannel indexFile)
                   throws IOException
Throws:
IOException

MutableBaseIdIndex

public MutableBaseIdIndex(FileChannel indexFile,
                          boolean recover)
                   throws IOException
Throws:
IOException

MutableBaseIdIndex

protected MutableBaseIdIndex(FileChannel indexFile,
                             Word offsetWidth,
                             long baseId,
                             long baseOffset)
                      throws IOException
Writes a new index to the specified file. This method was made protected in order to prevent the user from accidentally overwriting an existing index.

Throws:
IOException
See Also:
writeNewIndex(FileChannel, Word, long, long)
Method Detail

writeNewIndex

public static MutableBaseIdIndex writeNewIndex(FileChannel indexFile,
                                               Word offsetWidth,
                                               long baseId,
                                               long baseOffset)
                                        throws IOException
Writes a new index to the specified file.

Returns:
the newly created index instance
Throws:
IOException

setBaseId

public void setBaseId(long baseId)
               throws IOException
Sets the base ID of the index by writing it to the backing file. After this method returns, getMetrics() returns a new IndexMetrics instance reflecting the new base Id.

Throws:
IOException

getMetrics

public IndexMetrics getMetrics()
Description copied from class: Index
Returns the metrics of the index.

Overrides:
getMetrics in class Index


SourceForge.net Logo