Class XFastEventList

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class XFastEventList
    extends java.lang.Object
    implements java.lang.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

      Fields 
      Modifier and Type Field Description
      protected XAttributeMapSerializer attributeMapSerializer
      Attribute map serializer.
      protected XSequentialEventBuffer buffer
      Sequential event buffer used for raw buffered storage.
      protected java.util.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      java.lang.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.
      • holeFlags

        protected java.util.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 java.io.IOException
        Creates a new fast event list.
        Parameters:
        attributeMapSerializer - The attribute map serializer to be used.
        Throws:
        java.io.IOException
    • Method Detail

      • append

        public int append​(XEvent event)
                   throws java.io.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:
        java.io.IOException
      • cleanup

        public void cleanup()
                     throws java.io.IOException
        Cleans up this fast event list after use, frees all associated resources.
        Throws:
        java.io.IOException
      • consolidate

        public boolean consolidate()
                            throws java.io.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:
        java.io.IOException
      • get

        public XEvent get​(int index)
                   throws java.lang.IndexOutOfBoundsException,
                          java.io.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:
        java.lang.IndexOutOfBoundsException
        java.io.IOException
      • insert

        public void insert​(XEvent event,
                           int index)
                    throws java.lang.IndexOutOfBoundsException,
                           java.io.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:
        java.lang.IndexOutOfBoundsException
        java.io.IOException
      • insertOrdered

        public int insertOrdered​(XEvent event)
                          throws java.io.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:
        java.io.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 java.lang.IndexOutOfBoundsException,
                             java.io.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:
        java.lang.IndexOutOfBoundsException
        java.io.IOException
      • replace

        public XEvent replace​(XEvent event,
                              int index)
                       throws java.lang.IndexOutOfBoundsException,
                              java.io.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:
        java.lang.IndexOutOfBoundsException
        java.io.IOException
      • size

        public int size()
        Returns the size of this event list.
        Returns:
        The number of currently contained events.
      • clone

        public java.lang.Object clone()
        Creates a clone of this list.
        Overrides:
        clone in class java.lang.Object
      • finalize

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