org.deckfour.xes.model.buffered
Class XFastEventList

java.lang.Object
  extended by org.deckfour.xes.model.buffered.XFastEventList
All Implemented Interfaces:
Cloneable

public class XFastEventList
extends Object
implements Cloneable

Implements a fast list of events stored in disk buffers, by using the means of the NikeFS2 virtual file system for event logs. Frees main memory for other tasks, while guaranteeing quick sequential and random access to event log data.

Author:
Christian W. Guenther (christian@deckfour.org)

Field Summary
protected  XAttributeMapSerializer attributeMapSerializer
          Attribute map serializer.
protected  XSequentialEventBuffer buffer
          Sequential event buffer used for raw buffered storage.
protected  BitSet holeFlags
          Indicates the positions in the list which are no longer valid, i.e.
static int OVERFLOW_LIMIT
          Maximal number of buffered edit operations on the list, before it is consolidated to the disk buffer.
protected  XEvent[] overflowEntries
          Array of additional overflow entries.
protected  int[] overflowIndices
          Array of list indices for additional overflow entries.
protected  int overflowSize
          Current, actual size of the overflow data structures.
protected  int size
          Size of the list.
 
Constructor Summary
XFastEventList(XAttributeMapSerializer attributeMapSerializer)
          Creates a new fast event list.
 
Method Summary
 int append(XEvent event)
          Appends the given event to the end of this fast event list.
 void cleanup()
          Cleans up this fast event list after use, frees all associated resources.
 Object clone()
          Creates a clone of this list.
 boolean consolidate()
          Consolidates this fast event list.
protected  void finalize()
           
 XEvent get(int index)
          Retrieves an event at a specific index in the list.
 void insert(XEvent event, int index)
          Inserts an event at a given index into the list.
 int insertOrdered(XEvent event)
          Inserts the given event at its logical position in the list.
 boolean isTainted()
          Checks whether this list needs consolidation, i.e.
 XEvent remove(int index)
          Removes the event at the given index from this list.
 XEvent replace(XEvent event, int index)
          Replaces the event at the given index with another event.
 int size()
          Returns the size of this event list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERFLOW_LIMIT

public static int OVERFLOW_LIMIT
Maximal number of buffered edit operations on the list, before it is consolidated to the disk buffer.


size

protected int size
Size of the list.


buffer

protected XSequentialEventBuffer buffer
Sequential event buffer used for raw buffered storage.


attributeMapSerializer

protected XAttributeMapSerializer attributeMapSerializer
Attribute map serializer.


holeFlags

protected BitSet holeFlags
Indicates the positions in the list which are no longer valid, i.e. need to be skipped.


overflowIndices

protected int[] overflowIndices
Array of list indices for additional overflow entries.


overflowEntries

protected XEvent[] overflowEntries
Array of additional overflow entries.


overflowSize

protected int overflowSize
Current, actual size of the overflow data structures.

Constructor Detail

XFastEventList

public XFastEventList(XAttributeMapSerializer attributeMapSerializer)
               throws IOException
Creates a new fast event list.

Parameters:
attributeMapSerializer - The attribute map serializer to be used.
Throws:
IOException
Method Detail

append

public int append(XEvent event)
           throws IOException
Appends the given event to the end of this fast event list.

Parameters:
event - Event to be added.
Returns:
Index of the added event.
Throws:
IOException

cleanup

public void cleanup()
             throws IOException
Cleans up this fast event list after use, frees all associated resources.

Throws:
IOException

consolidate

public boolean consolidate()
                    throws IOException
Consolidates this fast event list. Consolidation implies, that all overflow and skipping data structures are freed, and the buffered representation is brought completely in-line with the virtual current contents of the list. The actual consolidation will be skipped, if no need for it is detected by the algorithm.

Returns:
Whether consolidation has been performed.
Throws:
IOException

get

public XEvent get(int index)
           throws IndexOutOfBoundsException,
                  IOException
Retrieves an event at a specific index in the list.

Parameters:
index - Index of the required event in the list.
Returns:
The requested event.
Throws:
IndexOutOfBoundsException
IOException

insert

public void insert(XEvent event,
                   int index)
            throws IndexOutOfBoundsException,
                   IOException
Inserts an event at a given index into the list.

Parameters:
event - The event to be inserted.
index - Requested index of the inserted event.
Throws:
IndexOutOfBoundsException
IOException

insertOrdered

public int insertOrdered(XEvent event)
                  throws IOException
Inserts the given event at its logical position in the list. The logical position is determined from timestamp information, if available. Otherwise, the event is appended to the end of the list.

Parameters:
event - Event to be inserted.
Returns:
Position of the event after insertion.
Throws:
IOException

isTainted

public boolean isTainted()
Checks whether this list needs consolidation, i.e. whether the overflow and skipping structures have any content.

Returns:
Whether this list is tainted.

remove

public XEvent remove(int index)
              throws IndexOutOfBoundsException,
                     IOException
Removes the event at the given index from this list.

Parameters:
index - Index of the event to be removed.
Returns:
The removed event.
Throws:
IndexOutOfBoundsException
IOException

replace

public XEvent replace(XEvent event,
                      int index)
               throws IndexOutOfBoundsException,
                      IOException
Replaces the event at the given index with another event.

Parameters:
event - Event to be inserted at the given position.
index - Position to replace event at.
Returns:
The removed event, which has been replaced.
Throws:
IndexOutOfBoundsException
IOException

size

public int size()
Returns the size of this event list.

Returns:
The number of currently contained events.

clone

public Object clone()
Creates a clone of this list.

Overrides:
clone in class Object

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable