27349c22d988767ba248b2022c7000983f2721e1
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / trace / indexer / ITmfTraceIndexer.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.trace.indexer;
14
15 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
16 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
17 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
18 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
19 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
20
21 /**
22 * The generic trace indexer in TMF with support for incremental indexing.
23 *
24 * @see ITmfTrace
25 * @see ITmfEvent
26 *
27 * @author Francois Chouinard
28 */
29 public interface ITmfTraceIndexer {
30
31 /**
32 * Start an asynchronous index building job and waits for the job completion
33 * if required. Typically, the indexing job sends notifications at regular
34 * intervals to indicate its progress.
35 * <p>
36 * <b>Example 1</b>: Index a whole trace asynchronously
37 *
38 * <pre>
39 * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
40 * </pre>
41 *
42 * <b>Example 2</b>: Index a whole trace synchronously
43 *
44 * <pre>
45 * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
46 * </pre>
47 *
48 * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
49 *
50 * <pre>
51 * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
52 * </pre>
53 *
54 * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
55 * events between T1 and T2 (inclusive). This is used for incremental
56 * indexing.
57 *
58 * <pre>
59 * TmfTimeRange range = new TmfTimeRange(T1, T2);
60 * trace.getIndexer().buildIndex(100, range, false);
61 * </pre>
62 *
63 * @param offset
64 * The offset of the first event to consider
65 * @param range
66 * The time range to consider
67 * @param waitForCompletion
68 * Should we block the calling thread until the build is
69 * complete?
70 */
71 void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
72
73 /**
74 * Indicates that the indexer is busy indexing the trace.
75 * Will always return false if the indexing is done synchronously.
76 *
77 * @return the state of the indexer (indexing or not)
78 */
79 boolean isIndexing();
80
81 /**
82 * Adds an entry to the trace index.
83 *
84 * @param context The trace context to save
85 * @param timestamp The timestamp matching this context
86 */
87 void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
88
89 /**
90 * Returns the context of the checkpoint immediately preceding the requested
91 * timestamp (or at the timestamp if it coincides with a checkpoint).
92 *
93 * @param timestamp the requested timestamp
94 * @return the checkpoint context
95 */
96 ITmfContext seekIndex(ITmfTimestamp timestamp);
97
98 /**
99 * Returns the context of the checkpoint immediately preceding the requested
100 * rank (or at rank if it coincides with a checkpoint).
101 *
102 * @param rank the requested event rank
103 * @return the checkpoint context
104 */
105 ITmfContext seekIndex(long rank);
106
107 /**
108 * Perform cleanup when the indexer is no longer required.
109 */
110 void dispose();
111
112 }
This page took 0.035697 seconds and 4 git commands to generate.