org.mbari.siam.core
Class DeviceLogIndex

java.lang.Object
  extended by org.mbari.siam.core.DeviceLogIndex

public class DeviceLogIndex
extends java.lang.Object

This class is utilized along with DeviceLogData to implement an indexed data store capability. Query over a range of possible keys is also supported. The database key is assumed to be a long quantity. NOTE: THIS IMPLEMENTATION ASSUMES THAT INDEX IS SORTED IN ASCENDING KEY ORDER!!!

Author:
Tim Meese
See Also:
DeviceLogData, DeviceLog

Nested Class Summary
protected static class DeviceLogIndex.Entry
          This class provides a container for each indexing information entry.
protected static class DeviceLogIndex.JournalEntry
          This class provides a container for log journal information.
 
Field Summary
protected  long _currentIdxFileExtent
          Current size of index file (bytes)
protected  java.io.RandomAccessFile _idxFile
           
 
Constructor Summary
protected DeviceLogIndex(long deviceId, int segmentNum, java.lang.String directory)
          default constructor
protected DeviceLogIndex(long deviceId, int segmentNum, java.lang.String suffix, java.lang.String directory)
           
 
Method Summary
protected  void addIndexEntry(DeviceLogIndex.Entry entry)
          adds a Entry object to the current index file
protected  void close()
          Close the index file.
protected  java.util.Vector getEntries(int beginIndex, long nEntries)
          returns a Vector object populated with Entry objects (i.e.
protected  java.util.Vector getEntries(long beginKey, long nEntries)
          returns a Vector object populated with Entry objects (i.e.
protected  java.lang.String getFileName(int segmentNum, java.lang.String directory)
          Return name of index file.
protected  java.lang.String getFileName(int segmentNum, java.lang.String suffix, java.lang.String directory)
           
protected  DeviceLogIndex.Entry getIndexEntry(int entryIndex, DeviceLogIndex.Entry entry)
          retrieve the Entry corresponding to the given entryIndex in the index file
protected  DeviceLogIndex.JournalEntry getJournalEntry()
           
protected  DeviceLogIndex.JournalEntry getJournalEntry(DeviceLogIndex.JournalEntry journalEntry)
           
protected  long getLastMetadataRef()
          get the lastMetadataRef value that has been registered
protected  long getLastSequenceNumber()
          get the lastSequenceNumber value that has been registered
protected  int getMaxIndex()
          Return maximum index in log.
protected  long getMaxTimestamp()
          get the maximum key value that has been registered by all index add operations
protected  long getMinTimestamp()
          get the minimum key value that has been registered by all index add operations
protected  DeviceLogIndex.Entry getNextIndexEntry()
          returns the next Entry in the index file according to a sequential access method.
protected  int nEntries(long beginKey, long endKey)
          Returns the number of entries that match the key comparison criteria specified by the parameters
protected  int nUnreadEntries()
          returns the number of unread DeviceLog objects by returning the number of index entries that have not yet been accessed using the sequential retrieval method (i.e.
protected  void updateMetadataRef(long mdref)
          set the lastMetadataRef value that has been registered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_idxFile

protected java.io.RandomAccessFile _idxFile

_currentIdxFileExtent

protected long _currentIdxFileExtent
Current size of index file (bytes)

Constructor Detail

DeviceLogIndex

protected DeviceLogIndex(long deviceId,
                         int segmentNum,
                         java.lang.String directory)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
default constructor

Parameters:
deviceId - ISI Device ID
segmentNum - segement number
Throws:
java.io.FileNotFoundException
java.io.IOException

DeviceLogIndex

protected DeviceLogIndex(long deviceId,
                         int segmentNum,
                         java.lang.String suffix,
                         java.lang.String directory)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

getFileName

protected java.lang.String getFileName(int segmentNum,
                                       java.lang.String directory)
Return name of index file.


getFileName

protected java.lang.String getFileName(int segmentNum,
                                       java.lang.String suffix,
                                       java.lang.String directory)

addIndexEntry

protected void addIndexEntry(DeviceLogIndex.Entry entry)
adds a Entry object to the current index file

Parameters:
entry - index entry to add to the current index file

getIndexEntry

protected DeviceLogIndex.Entry getIndexEntry(int entryIndex,
                                             DeviceLogIndex.Entry entry)
                                      throws NoDataException
retrieve the Entry corresponding to the given entryIndex in the index file

Parameters:
entryIndex - number (1-based) of the index entry to retrieve
entry - Entry object to use
Throws:
NoDataException

getJournalEntry

protected DeviceLogIndex.JournalEntry getJournalEntry(DeviceLogIndex.JournalEntry journalEntry)

getJournalEntry

protected DeviceLogIndex.JournalEntry getJournalEntry()

getMinTimestamp

protected long getMinTimestamp()
get the minimum key value that has been registered by all index add operations


getMaxTimestamp

protected long getMaxTimestamp()
get the maximum key value that has been registered by all index add operations


getLastSequenceNumber

protected long getLastSequenceNumber()
get the lastSequenceNumber value that has been registered


getLastMetadataRef

protected long getLastMetadataRef()
get the lastMetadataRef value that has been registered


updateMetadataRef

protected void updateMetadataRef(long mdref)
set the lastMetadataRef value that has been registered


nEntries

protected int nEntries(long beginKey,
                       long endKey)
                throws NoDataException
Returns the number of entries that match the key comparison criteria specified by the parameters

Parameters:
beginKey - starting key value (inclusive) of the result set
endKey - ending key value (inclusive) of the result set
Throws:
NoDataException
See Also:
DeviceLogIndex.JournalEntry

getEntries

protected java.util.Vector getEntries(long beginKey,
                                      long nEntries)
                               throws NoDataException
returns a Vector object populated with Entry objects (i.e. the result set) that match the key comparison criteria specified by the parameters

Parameters:
beginKey - starting key value (inclusive) of the result set
nEntries - number of entries to read
Throws:
NoDataException
See Also:
Vector, DeviceLogIndex.JournalEntry

getEntries

protected java.util.Vector getEntries(int beginIndex,
                                      long nEntries)
                               throws NoDataException
returns a Vector object populated with Entry objects (i.e. the result set) from the log, starting at index and consisting of nEntries.

Parameters:
beginIndex - starting index of the result set
nEntries - number of entries to read
Throws:
NoDataException
See Also:
Vector, DeviceLogIndex.JournalEntry

getNextIndexEntry

protected DeviceLogIndex.Entry getNextIndexEntry()
                                          throws NoDataException
returns the next Entry in the index file according to a sequential access method. Note that index entries obtained with key range queries do not effect sequential queries.

Throws:
NoDataException

nUnreadEntries

protected int nUnreadEntries()
returns the number of unread DeviceLog objects by returning the number of index entries that have not yet been accessed using the sequential retrieval method (i.e. getNextEntry())


close

protected void close()
              throws java.io.IOException
Close the index file. This DeviceLogIndex instance is no longer usable after close() has been called.

Throws:
java.io.IOException

getMaxIndex

protected int getMaxIndex()
Return maximum index in log.



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.