com.timeindexing.index
Class FileIndex

java.lang.Object
  extended bycom.timeindexing.index.AbstractIndex
      extended bycom.timeindexing.index.AbstractManagedIndex
          extended bycom.timeindexing.index.FileIndex
All Implemented Interfaces:
ExtendedIndex, ExtendedIndexHeader, Index, IndexEventGenerator, IndexHeader, ManagedIndex, ManagedIndexHeader, StoredIndex
Direct Known Subclasses:
ExternalIndex, InlineIndex

public abstract class FileIndex
extends AbstractManagedIndex
implements StoredIndex

A place holder abstract class for stored Index objects that are stored in files.


Constructor Summary
FileIndex()
           
 
Method Summary
 Index activate()
          Make the Index activated.
 long addItem(DataItem dataitem)
          Add a Data Item to the Index.
 long addItem(DataItem dataitem, Timestamp dataTS)
          Add a Data Item to the Index plus a Timestamp from the Data.
 long addReference(IndexItem item, Index other)
          Add a Referemnce to an IndexItem in a Index.
 long addReference(IndexItem otherItem, Index otherIndex, Timestamp dataTS)
          Add a Referemnce to an IndexItem in a Index.
 long addReference(IndexReference reference, Timestamp dataTS)
          Add a Referemnce to an IndexItem in a Index.
 boolean flush()
          Flush this index.
 java.net.URI generateURI(java.lang.String pathname)
          Construct a URI from a pathname.
 Offset getFirstOffset()
          Get the Offset of the fisrt item.
 java.lang.String getHeaderPathName()
          Get the path of the index header.
 IndexItem getItem(long n)
          Get an Index Item from the Index.
 Position getLastFlushPosition()
          Get the IndexItem Position when the index was last flushed.
 Timestamp getLastFlushTime()
          Get the last time the index was flushed.
 Offset getLastOffset()
          Get the Offset of the last item.
 boolean isWriteLocked()
          Has the Index been write-locked.
 DataHolderObject readData(DataReference dataReference)
          Read data for an index item given a DataReference.
 boolean reallyClose()
          Close this index.
 long retrieveItem(IndexItem item, long position)
          Retrieve an Index Item into the Index.
protected  long writeItem(FileIndexItem item)
           
 
Methods inherited from class com.timeindexing.index.AbstractManagedIndex
addIndexURI, asView, close, getAllOptions, getHeader, getIndexURI, getOption, getTrackedIndex, hasIndexURI, hasOption, isOpen, isTrackingIndex, listOptions, listTrackedIndexes, notInTimeOrder, setDataPathName, setDataSize, setDescription, setEndTime, setFirstDataTime, setFirstOffset, setFirstTime, setID, setIndexDataType, setIndexPathName, setIndexType, setItemSize, setLastDataTime, setLastOffset, setLastTime, setLength, setName, setOption, setOptions, setReadOnly, setStartTime, setTerminated, setURI, syncHeader, trackReferencedIndex
 
Methods inherited from class com.timeindexing.index.AbstractIndex
addAccessEventListener, addAddEventListener, addDataType, addItem, addPrimaryEventListener, binarySearch, contains, eventMulticaster, getAnnotationStyle, getDataPathName, getDataSize, getDataType, getDescription, getEndTime, getFirstDataTime, getFirstTime, getID, getIndexDataType, getIndexPathName, getIndexType, getItem, getItem, getItemSize, getLastAccessTime, getLastDataTime, getLastTime, getLength, getName, getStartTime, getURI, hasAnnotations, hasDataType, isActivated, isChanged, isClosed, isFixedSizeData, isInTimeOrder, isReadOnly, isTerminated, iterator, locate, removeAccessEventListener, removeAddEventListener, removePrimaryEventListener, setLastAccessTime, terminate, updateDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.timeindexing.index.ManagedIndex
create, getHeader, getTrackedIndex, isTrackingIndex, listTrackedIndexes, open, trackReferencedIndex
 
Methods inherited from interface com.timeindexing.index.ExtendedIndex
getIndexType
 
Methods inherited from interface com.timeindexing.index.Index
addDataType, asView, close, contains, getAnnotationStyle, getDataType, getItem, getItem, getItemSize, getLastAccessTime, hasAnnotations, hasDataType, isActivated, isChanged, isClosed, iterator, locate, terminate, updateDescription
 
Methods inherited from interface com.timeindexing.index.IndexHeader
getDataPathName, getDataSize, getDescription, getEndTime, getFirstDataTime, getFirstTime, getID, getIndexDataType, getIndexPathName, getLastDataTime, getLastTime, getLength, getName, getStartTime, getURI, isFixedSizeData, isInTimeOrder, isReadOnly, isTerminated
 
Methods inherited from interface com.timeindexing.index.ExtendedIndexHeader
addDataType, addIndexURI, getAnnotationStyle, getDataSize, getDataType, getIndexURI, getItemSize, hasAnnotations, hasDataType, hasIndexURI
 
Methods inherited from interface com.timeindexing.index.ManagedIndexHeader
addIndexURI, getAllOptions, getIndexURI, getOption, hasIndexURI, hasOption, listOptions, notInTimeOrder, setDataPathName, setDataSize, setDescription, setEndTime, setFirstDataTime, setFirstOffset, setFirstTime, setID, setIndexDataType, setIndexPathName, setIndexType, setItemSize, setLastDataTime, setLastOffset, setLastTime, setLength, setName, setOption, setOptions, setReadOnly, setStartTime, setTerminated, setURI, syncHeader
 
Methods inherited from interface com.timeindexing.event.IndexEventGenerator
addAccessEventListener, addAddEventListener, addPrimaryEventListener, removeAccessEventListener, removeAddEventListener, removePrimaryEventListener
 

Constructor Detail

FileIndex

public FileIndex()
Method Detail

flush

public boolean flush()
              throws IndexFlushException
Flush this index.

Specified by:
flush in interface Index
Overrides:
flush in class AbstractManagedIndex
Throws:
IndexFlushException

reallyClose

public boolean reallyClose()
                    throws IndexCloseException
Close this index.

Specified by:
reallyClose in interface ManagedIndex
Overrides:
reallyClose in class AbstractManagedIndex
Throws:
IndexCloseException

addItem

public long addItem(DataItem dataitem)
             throws IndexTerminatedException,
                    IndexClosedException,
                    IndexActivationException,
                    AddItemException
Add a Data Item to the Index. The data timestamp will be the same as the record timestamp. The ID will be generated. There are no annotations.

Specified by:
addItem in interface Index
Specified by:
addItem in class AbstractIndex
Returns:
the no of items in the index.
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addItem

public long addItem(DataItem dataitem,
                    Timestamp dataTS)
             throws IndexTerminatedException,
                    IndexClosedException,
                    IndexActivationException,
                    AddItemException
Add a Data Item to the Index plus a Timestamp from the Data. The ID will be generated. There are no annotations.

Specified by:
addItem in interface Index
Specified by:
addItem in class AbstractIndex
Parameters:
dataTS - the Timestamp for the data, null implies that the data Timestamp is the same as the record Timestamp
Returns:
the no of items in the index.
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addReference

public long addReference(IndexItem item,
                         Index other)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Add a Referemnce to an IndexItem in a Index.

Specified by:
addReference in interface Index
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addReference

public long addReference(IndexItem otherItem,
                         Index otherIndex,
                         Timestamp dataTS)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Add a Referemnce to an IndexItem in a Index.

Specified by:
addReference in interface Index
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addReference

public long addReference(IndexReference reference,
                         Timestamp dataTS)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Add a Referemnce to an IndexItem in a Index. This version takes the Index URI, the Index ID, the IndexItem's Position, and the IndexItem's data Timestamp. It is used internally when doing a TimeIndexFactory.save().

Specified by:
addReference in interface ManagedIndex
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

getItem

public IndexItem getItem(long n)
                  throws GetItemException
Get an Index Item from the Index.

Specified by:
getItem in interface Index
Overrides:
getItem in class AbstractIndex
Throws:
GetItemException

writeItem

protected long writeItem(FileIndexItem item)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

retrieveItem

public long retrieveItem(IndexItem item,
                         long position)
Retrieve an Index Item into the Index.

Specified by:
retrieveItem in interface StoredIndex
Parameters:
item - the IndexItem to add
position - the position to load the IndexItem at
Returns:
the no of items in the cache

readData

public DataHolderObject readData(DataReference dataReference)
Read data for an index item given a DataReference.

Specified by:
readData in interface StoredIndex

getHeaderPathName

public java.lang.String getHeaderPathName()
Get the path of the index header.


getLastFlushTime

public Timestamp getLastFlushTime()
Get the last time the index was flushed.

Specified by:
getLastFlushTime in interface ExtendedIndex

getLastFlushPosition

public Position getLastFlushPosition()
Get the IndexItem Position when the index was last flushed.

Specified by:
getLastFlushPosition in interface ExtendedIndex

getFirstOffset

public Offset getFirstOffset()
Get the Offset of the fisrt item.

Specified by:
getFirstOffset in interface ExtendedIndex

getLastOffset

public Offset getLastOffset()
Get the Offset of the last item.

Specified by:
getLastOffset in interface ExtendedIndex

activate

public Index activate()
               throws IndexReadOnlyException,
                      IndexWriteLockedException
Make the Index activated.

Specified by:
activate in interface Index
Throws:
IndexReadOnlyException
IndexWriteLockedException

isWriteLocked

public boolean isWriteLocked()
Has the Index been write-locked.

Specified by:
isWriteLocked in interface Index

generateURI

public java.net.URI generateURI(java.lang.String pathname)
                         throws java.net.URISyntaxException
Construct a URI from a pathname.

Throws:
java.net.URISyntaxException