Class TmfCheckpointIndexer
java.lang.Object
org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer
- All Implemented Interfaces:
ITmfTraceIndexer
- Direct Known Subclasses:
TmfBTreeTraceIndexer,TmfFlatArrayTraceIndexer
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 Summary
ConstructorsConstructorDescriptionTmfCheckpointIndexer(ITmfTrace trace) Basic constructor that uses the default trace block size as checkpoints intervalsTmfCheckpointIndexer(ITmfTrace trace, int interval) Full trace indexer -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildIndex(long offset, TmfTimeRange range, boolean waitForCompletion) Start an asynchronous index building job and waits for the job completion if required.voiddispose()Perform cleanup when the indexer is no longer required.booleanIndicates that the indexer is busy indexing the trace.seekIndex(long rank) Returns the context of the checkpoint immediately preceding the requested rank (or at rank if it coincides with a checkpoint).seekIndex(ITmfTimestamp timestamp) Returns the context of the checkpoint immediately preceding the requested timestamp (or at the timestamp if it coincides with a checkpoint).voidupdateIndex(ITmfContext context, ITmfTimestamp timestamp) Adds an entry to the trace index.
-
Constructor Details
-
TmfCheckpointIndexer
Basic constructor that uses the default trace block size as checkpoints intervals- Parameters:
trace- the trace to index
-
TmfCheckpointIndexer
Full trace indexer- Parameters:
trace- the trace to indexinterval- the checkpoints interval
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:ITmfTraceIndexerPerform cleanup when the indexer is no longer required.- Specified by:
disposein interfaceITmfTraceIndexer
-
isIndexing
public boolean isIndexing()Description copied from interface:ITmfTraceIndexerIndicates that the indexer is busy indexing the trace. Will always return false if the indexing is done synchronously.- Specified by:
isIndexingin interfaceITmfTraceIndexer- Returns:
- the state of the indexer (indexing or not)
-
buildIndex
Description copied from interface:ITmfTraceIndexerStart 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 synchronouslytrace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
Example 3: Index a trace asynchronously, starting at rank 100trace.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:
buildIndexin interfaceITmfTraceIndexer- Parameters:
offset- The offset of the first event to considerrange- The time range to considerwaitForCompletion- Should we block the calling thread until the build is complete?
-
updateIndex
Description copied from interface:ITmfTraceIndexerAdds an entry to the trace index.- Specified by:
updateIndexin interfaceITmfTraceIndexer- Parameters:
context- The trace context to savetimestamp- The timestamp matching this context
-
seekIndex
Description copied from interface:ITmfTraceIndexerReturns the context of the checkpoint immediately preceding the requested timestamp (or at the timestamp if it coincides with a checkpoint).- Specified by:
seekIndexin interfaceITmfTraceIndexer- Parameters:
timestamp- the requested timestamp- Returns:
- the checkpoint context
-
seekIndex
Description copied from interface:ITmfTraceIndexerReturns the context of the checkpoint immediately preceding the requested rank (or at rank if it coincides with a checkpoint).- Specified by:
seekIndexin interfaceITmfTraceIndexer- Parameters:
rank- the requested event rank- Returns:
- the checkpoint context
-