Commit | Line | Data |
---|---|---|
20658947 | 1 | /******************************************************************************* |
61759503 | 2 | * Copyright (c) 2012, 2013 Ericsson |
9b749023 | 3 | * |
20658947 FC |
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 | |
9b749023 | 8 | * |
20658947 FC |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.core.trace; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; | |
3bd46eef AM |
16 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
17 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; | |
20658947 FC |
18 | |
19 | /** | |
9e0640dc | 20 | * The generic trace indexer in TMF with support for incremental indexing. |
9b749023 | 21 | * |
f7703ed6 FC |
22 | * @version 1.0 |
23 | * @author Francois Chouinard | |
24 | * | |
25 | * @see ITmfTrace | |
26 | * @see ITmfEvent | |
20658947 | 27 | */ |
6256d8ad | 28 | public interface ITmfTraceIndexer { |
20658947 FC |
29 | |
30 | /** | |
31 | * Start an asynchronous index building job and waits for the job completion | |
32 | * if required. Typically, the indexing job sends notifications at regular | |
33 | * intervals to indicate its progress. | |
9e0640dc FC |
34 | * <p> |
35 | * <b>Example 1</b>: Index a whole trace asynchronously | |
063f0d27 | 36 | * |
9e0640dc FC |
37 | * <pre> |
38 | * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false); | |
39 | * </pre> | |
063f0d27 | 40 | * |
9e0640dc | 41 | * <b>Example 2</b>: Index a whole trace synchronously |
063f0d27 | 42 | * |
9e0640dc FC |
43 | * <pre> |
44 | * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true); | |
45 | * </pre> | |
063f0d27 | 46 | * |
9e0640dc | 47 | * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100 |
063f0d27 | 48 | * |
9e0640dc FC |
49 | * <pre> |
50 | * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false); | |
51 | * </pre> | |
063f0d27 AM |
52 | * |
53 | * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for | |
54 | * events between T1 and T2 (inclusive). This is used for incremental | |
55 | * indexing. | |
56 | * | |
9e0640dc FC |
57 | * <pre> |
58 | * TmfTimeRange range = new TmfTimeRange(T1, T2); | |
59 | * trace.getIndexer().buildIndex(100, range, false); | |
60 | * </pre> | |
9b749023 | 61 | * |
063f0d27 AM |
62 | * @param offset |
63 | * The offset of the first event to consider | |
64 | * @param range | |
65 | * The time range to consider | |
20658947 | 66 | * @param waitForCompletion |
063f0d27 AM |
67 | * Should we block the calling thread until the build is |
68 | * complete? | |
3bd46eef | 69 | * @since 2.0 |
20658947 | 70 | */ |
57a2a5ca | 71 | void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion); |
9b749023 | 72 | |
9e0640dc FC |
73 | /** |
74 | * Indicates that the indexer is busy indexing the trace. | |
9b749023 AM |
75 | * Will always return false if the indexing is done synchronously. |
76 | * | |
9e0640dc FC |
77 | * @return the state of the indexer (indexing or not) |
78 | */ | |
57a2a5ca | 79 | boolean isIndexing(); |
9b749023 | 80 | |
20658947 | 81 | /** |
9b749023 AM |
82 | * Adds an entry to the trace index. |
83 | * | |
063f0d27 AM |
84 | * @param context The trace context to save |
85 | * @param timestamp The timestamp matching this context | |
3bd46eef | 86 | * @since 2.0 |
20658947 | 87 | */ |
57a2a5ca | 88 | void updateIndex(ITmfContext context, ITmfTimestamp timestamp); |
9b749023 | 89 | |
20658947 FC |
90 | /** |
91 | * Returns the context of the checkpoint immediately preceding the requested | |
92 | * timestamp (or at the timestamp if it coincides with a checkpoint). | |
9b749023 | 93 | * |
20658947 FC |
94 | * @param timestamp the requested timestamp |
95 | * @return the checkpoint context | |
3bd46eef | 96 | * @since 2.0 |
20658947 | 97 | */ |
57a2a5ca | 98 | ITmfContext seekIndex(ITmfTimestamp timestamp); |
20658947 FC |
99 | |
100 | /** | |
101 | * Returns the context of the checkpoint immediately preceding the requested | |
102 | * rank (or at rank if it coincides with a checkpoint). | |
9b749023 | 103 | * |
20658947 FC |
104 | * @param rank the requested event rank |
105 | * @return the checkpoint context | |
106 | */ | |
57a2a5ca | 107 | ITmfContext seekIndex(long rank); |
20658947 | 108 | |
b5ee6881 FC |
109 | /** |
110 | * Perform cleanup when the indexer is no longer required. | |
111 | */ | |
57a2a5ca | 112 | void dispose(); |
b5ee6881 | 113 | |
20658947 | 114 | } |