java.lang.Object
org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer
All Implemented Interfaces:
ITmfTraceIndexer
Direct Known Subclasses:
TmfBTreeTraceIndexer, TmfFlatArrayTraceIndexer

public class TmfCheckpointIndexer extends Object implements ITmfTraceIndexer
A simple indexer that manages the trace index as an array of trace checkpoints. Checkpoints are stored in memory at fixed intervals (event rank) in ascending timestamp order.

The goal being to access a random trace event reasonably fast from the user's standpoint, picking the right interval value becomes a trade-off between speed and memory usage (a shorter inter-event interval is faster but requires more checkpoints).

Locating a specific checkpoint is trivial for both rank (rank % interval) and timestamp (bsearch in the array). *

Author:
Francois Chouinard
See Also:
  • Constructor Details

    • TmfCheckpointIndexer

      public TmfCheckpointIndexer(ITmfTrace trace)
      Basic constructor that uses the default trace block size as checkpoints intervals
      Parameters:
      trace - the trace to index
    • TmfCheckpointIndexer

      public TmfCheckpointIndexer(ITmfTrace trace, int interval)
      Full trace indexer
      Parameters:
      trace - the trace to index
      interval - the checkpoints interval
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: ITmfTraceIndexer
      Perform cleanup when the indexer is no longer required.
      Specified by:
      dispose in interface ITmfTraceIndexer
    • isIndexing

      public boolean isIndexing()
      Description copied from interface: ITmfTraceIndexer
      Indicates that the indexer is busy indexing the trace. Will always return false if the indexing is done synchronously.
      Specified by:
      isIndexing in interface ITmfTraceIndexer
      Returns:
      the state of the indexer (indexing or not)
    • buildIndex

      public void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion)
      Description copied from interface: ITmfTraceIndexer
      Start an asynchronous index building job and waits for the job completion if required. Typically, the indexing job sends notifications at regular intervals to indicate its progress.

      Example 1: Index a whole trace asynchronously

       trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
       
      Example 2: Index a whole trace synchronously
       trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
       
      Example 3: Index a trace asynchronously, starting at rank 100
       trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
       
      Example 4: Index a trace asynchronously, starting at rank 100 for events between T1 and T2 (inclusive). This is used for incremental indexing.
       TmfTimeRange range = new TmfTimeRange(T1, T2);
       trace.getIndexer().buildIndex(100, range, false);
       
      Specified by:
      buildIndex in interface ITmfTraceIndexer
      Parameters:
      offset - The offset of the first event to consider
      range - The time range to consider
      waitForCompletion - Should we block the calling thread until the build is complete?
    • updateIndex

      public void updateIndex(ITmfContext context, ITmfTimestamp timestamp)
      Description copied from interface: ITmfTraceIndexer
      Adds an entry to the trace index.
      Specified by:
      updateIndex in interface ITmfTraceIndexer
      Parameters:
      context - The trace context to save
      timestamp - The timestamp matching this context
    • seekIndex

      public ITmfContext seekIndex(ITmfTimestamp timestamp)
      Description copied from interface: ITmfTraceIndexer
      Returns the context of the checkpoint immediately preceding the requested timestamp (or at the timestamp if it coincides with a checkpoint).
      Specified by:
      seekIndex in interface ITmfTraceIndexer
      Parameters:
      timestamp - the requested timestamp
      Returns:
      the checkpoint context
    • seekIndex

      public ITmfContext seekIndex(long rank)
      Description copied from interface: ITmfTraceIndexer
      Returns the context of the checkpoint immediately preceding the requested rank (or at rank if it coincides with a checkpoint).
      Specified by:
      seekIndex in interface ITmfTraceIndexer
      Parameters:
      rank - the requested event rank
      Returns:
      the checkpoint context