com.timeindexing.index
Class IncoreIndex

java.lang.Object
  extended bycom.timeindexing.index.AbstractIndex
      extended bycom.timeindexing.index.AbstractManagedIndex
          extended bycom.timeindexing.index.IncoreIndex
All Implemented Interfaces:
ExtendedIndex, ExtendedIndexHeader, Index, IndexEventGenerator, IndexHeader, ManagedIndex, ManagedIndexHeader

public class IncoreIndex
extends AbstractManagedIndex
implements ManagedIndex

An implementation of an incore Index object. It represents the index header, the index stream and the data stream.


Constructor Summary
IncoreIndex()
          Create an IncoreIndex
 
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.
protected  void checkCreateProperties(java.util.Properties indexProperties)
           
protected  void checkOpenProperties(java.util.Properties indexProperties)
          Check that all the properties needed to open are passed in.
 boolean create(java.util.Properties properties)
          Create this index.
 java.net.URI generateURI(java.lang.String name)
          Construct a URI from a name
 Offset getFirstOffset()
          Get the Offset of the fisrt item.
 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.
protected  void init()
          Initialize the object.
 boolean isWriteLocked()
          Has the Index been write-locked.
 boolean open(java.util.Properties properties)
          Open this index.
 boolean reallyClose()
          Close this index.
 
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, commit, 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, locate, removeAccessEventListener, removeAddEventListener, removePrimaryEventListener, setAutoCommit, setCachePolicy, 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
getHeader, getTrackedIndex, isTrackingIndex, listTrackedIndexes, trackReferencedIndex
 
Methods inherited from interface com.timeindexing.index.ExtendedIndex
getIndexType
 
Methods inherited from interface com.timeindexing.index.Index
addDataType, asView, close, commit, contains, getAnnotationStyle, getDataType, getItem, getItem, getItemSize, getLastAccessTime, hasAnnotations, hasDataType, isActivated, isChanged, isClosed, iterator, locate, locate, setAutoCommit, setCachePolicy, 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

IncoreIndex

public IncoreIndex()
Create an IncoreIndex

Method Detail

init

protected void init()
Initialize the object.


open

public boolean open(java.util.Properties properties)
             throws IndexSpecificationException,
                    IndexOpenException
Open this index.

Specified by:
open in interface ManagedIndex
Throws:
IndexSpecificationException
IndexOpenException

create

public boolean create(java.util.Properties properties)
               throws IndexSpecificationException,
                      IndexCreateException
Create this index.

Specified by:
create in interface ManagedIndex
Throws:
IndexSpecificationException
IndexCreateException

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. There is nothing to flush in an IncoreIndex, so the Position of the last item is returned.

Specified by:
getLastFlushPosition in interface ExtendedIndex

getFirstOffset

public Offset getFirstOffset()
Get the Offset of the fisrt item. There are no file offsets for an IncoreIndex, so The offset into the index is returned.

Specified by:
getFirstOffset in interface ExtendedIndex

getLastOffset

public Offset getLastOffset()
Get the Offset of the last item. There are no file offsets for an IncoreIndex, so The offset into the index is returned.

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

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
Specified by:
getItem in class AbstractIndex
Throws:
GetItemException

reallyClose

public boolean reallyClose()
Close this index.

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

checkOpenProperties

protected void checkOpenProperties(java.util.Properties indexProperties)
                            throws IndexSpecificationException
Check that all the properties needed to open are passed in.

Throws:
IndexSpecificationException

checkCreateProperties

protected void checkCreateProperties(java.util.Properties indexProperties)
                              throws IndexSpecificationException
Throws:
IndexSpecificationException

generateURI

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

Throws:
java.net.URISyntaxException