com.timeindexing.index
Interface Index

All Superinterfaces:
IndexHeader
All Known Subinterfaces:
ExtendedIndex, IndexView, ManagedIndex, StoredIndex
All Known Implementing Classes:
AbstractIndex, AbstractManagedIndex, ExternalIndex, FileIndex, IncoreIndex, InlineIndex, ShadowIndex, SQLIndex, TimeIndex

public interface Index
extends IndexHeader

An index. This is the generic interface to an index. It has all the methods for the header and for all the data requests.


Method Summary
 Index activate()
          Make the Index activated.
 boolean addDataType(ID typeID, java.lang.String typeName)
          Add a new data type
 long addItem(DataItem item)
          Add a Data Item to the Index.
 long addItem(DataItem item, Timestamp dataTime)
          Add a Data Item to the Index with a speicifed Data Timestamp
 long addReference(IndexItem item, Index other)
          Add a Reference to an IndexItem in a Index.
 long addReference(IndexItem item, Index other, Timestamp dataTime)
          Add a Reference to an IndexItem in a Index.
 IndexView asView()
          Get a view onto the Index.
 boolean close()
          Close the index.
 boolean commit()
          Commit all changes to the index.
 boolean contains(Timestamp t, IndexTimestampSelector sel)
          Does a timestamp fall within the bounds of the Index.
 int getAnnotationStyle()
          Get the annotation style.
 java.lang.String getDataType(ID typeID)
          Get the type name of the things in the data stream.
 IndexItem getItem(long n)
          Get an Index Item from the Index.
 IndexItem getItem(Position p)
          Get an Index Item from the Index.
 IndexItem getItem(Timestamp t, IndexTimestampSelector sel, Lifetime lifetime)
          Get an Index Item from the Index.
 int getItemSize()
          Get the size of the index items.
 Timestamp getLastAccessTime()
          Get the last time an IndexItem was accessed from the index.
 boolean hasAnnotations()
          Does this index have annotations.
 boolean hasDataType(java.lang.String typeName)
          Does this index have a typed name.
 boolean isActivated()
          Is the Index activated.
 boolean isChanged()
          Has the index changed in any way.
 boolean isClosed()
          Is the Index closed.
 boolean isWriteLocked()
          Has the Index been write-locked.
 java.util.Iterator iterator()
          Get an iterator over the IndexItems in the Index.
 TimestampMapping locate(Position p, IndexTimestampSelector sel, Lifetime lifetime)
          Try and determine the Timestamp associated with the speicifed Position.
 TimestampMapping locate(Timestamp t, IndexTimestampSelector sel, Lifetime lifetime)
          Try and determine the position associated with the speicifed Timestamp.
 boolean setAutoCommit(boolean commit)
          Set auto commit to be true or false.
 boolean setCachePolicy(CachePolicy policy)
          Set a CachePolicy in order to manage the cache.
 Index terminate()
          Make the Index finalized.
 Index updateDescription(Description description)
          Update the description of this index.
 
Methods inherited from interface com.timeindexing.index.IndexHeader
getDataPathName, getDataSize, getDescription, getEndTime, getFirstDataTime, getFirstTime, getID, getIndexDataType, getIndexPathName, getIndexType, getLastDataTime, getLastTime, getLength, getName, getStartTime, getURI, isFixedSizeData, isInTimeOrder, isReadOnly, isTerminated
 

Method Detail

getItemSize

public int getItemSize()
Get the size of the index items.


getDataType

public java.lang.String getDataType(ID typeID)
Get the type name of the things in the data stream.


hasDataType

public boolean hasDataType(java.lang.String typeName)
Does this index have a typed name.


addDataType

public boolean addDataType(ID typeID,
                           java.lang.String typeName)
Add a new data type

Returns:
true, if a new type was added; false, if the index had this ID/typeName pair already

hasAnnotations

public boolean hasAnnotations()
Does this index have annotations.


getAnnotationStyle

public int getAnnotationStyle()
Get the annotation style. Either inline or external.


updateDescription

public Index updateDescription(Description description)
Update the description of this index.


addItem

public long addItem(DataItem item)
             throws IndexTerminatedException,
                    IndexClosedException,
                    IndexActivationException,
                    AddItemException
Add a Data Item to the Index.

Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addItem

public long addItem(DataItem item,
                    Timestamp dataTime)
             throws IndexTerminatedException,
                    IndexClosedException,
                    IndexActivationException,
                    AddItemException
Add a Data Item to the Index with a speicifed Data Timestamp

Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addReference

public long addReference(IndexItem item,
                         Index other)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Add a Reference to an IndexItem in a Index. The Data Timestamp of the IndexItem is passed into this Index.

Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

addReference

public long addReference(IndexItem item,
                         Index other,
                         Timestamp dataTime)
                  throws IndexTerminatedException,
                         IndexClosedException,
                         IndexActivationException,
                         AddItemException
Add a Reference to an IndexItem in a Index. The Data Timestamp of the IndexItem is the one specified.

Throws:
IndexTerminatedException
IndexClosedException
IndexActivationException
AddItemException

getItem

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

Throws:
GetItemException

getItem

public IndexItem getItem(Position p)
                  throws GetItemException
Get an Index Item from the Index.

Throws:
GetItemException

getItem

public IndexItem getItem(Timestamp t,
                         IndexTimestampSelector sel,
                         Lifetime lifetime)
                  throws GetItemException
Get an Index Item from the Index.

Throws:
GetItemException

contains

public boolean contains(Timestamp t,
                        IndexTimestampSelector sel)
Does a timestamp fall within the bounds of the Index. The bounds are the first time data is put in and the last time data is put in the Index.


locate

public TimestampMapping locate(Timestamp t,
                               IndexTimestampSelector sel,
                               Lifetime lifetime)
Try and determine the position associated with the speicifed Timestamp. Returns a TimestampMapping which contains the original time and the found position.


locate

public TimestampMapping locate(Position p,
                               IndexTimestampSelector sel,
                               Lifetime lifetime)
Try and determine the Timestamp associated with the speicifed Position. Returns a TimestampMapping which contains the original Position and the found Timestamp.


getLastAccessTime

public Timestamp getLastAccessTime()
Get the last time an IndexItem was accessed from the index.


isActivated

public boolean isActivated()
Is the Index activated.


activate

public Index activate()
               throws IndexReadOnlyException,
                      IndexWriteLockedException
Make the Index activated. It is not possible to add items to an Index that is not active.

Throws:
IndexReadOnlyException
IndexWriteLockedException

terminate

public Index terminate()
Make the Index finalized. It is not possible to add items ever again to an Index that has been terminated.


commit

public boolean commit()
               throws IndexCommitException
Commit all changes to the index. Intened to sync all associated streams and files, and this sets the end time too.

Throws:
IndexCommitException

setAutoCommit

public boolean setAutoCommit(boolean commit)
Set auto commit to be true or false. When auto commit is true, then every addItem() is automatically committed.

Returns:
the previous value of auto commit.

isClosed

public boolean isClosed()
Is the Index closed.


close

public boolean close()
              throws IndexCloseException
Close the index. Intened to close all associated streams and files, and this sets the end time too.

Throws:
IndexCloseException

isChanged

public boolean isChanged()
Has the index changed in any way.


isWriteLocked

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


iterator

public java.util.Iterator iterator()
Get an iterator over the IndexItems in the Index.


asView

public IndexView asView()
Get a view onto the Index.


setCachePolicy

public boolean setCachePolicy(CachePolicy policy)
Set a CachePolicy in order to manage the cache.