Commit | Line | Data |
---|---|---|
032ecd45 MAL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 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 | * Marc-Andre Laperle - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint; | |
14 | ||
15 | import java.util.Collections; | |
16 | ||
17 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; | |
18 | ||
19 | /** | |
20 | * A trace index contains the data (checkpoints) needed by the indexer so that it can perform | |
21 | * its operations. Implementors can store checkpoints in various ways and | |
22 | * optionally restore them later, see ({@link #isCreatedFromScratch}) | |
23 | * | |
24 | * @since 3.0 | |
25 | * @author Marc-Andre Laperle | |
26 | */ | |
27 | public interface ITmfCheckpointIndex { | |
28 | ||
29 | /** | |
30 | * Add a checkpoint to the index | |
31 | * | |
32 | * @param checkpoint | |
33 | * the checkpoint to add | |
34 | */ | |
35 | void insert(ITmfCheckpoint checkpoint); | |
36 | ||
37 | /** | |
38 | * Get a checkpoint by checkpoint rank | |
39 | * | |
40 | * @param checkpointRank | |
41 | * the checkpoint rank to search for | |
42 | * @return the checkpoint found for the given checkpoint rank | |
43 | */ | |
44 | ITmfCheckpoint get(long checkpointRank); | |
45 | ||
46 | /** | |
47 | * Find the checkpoint rank of a checkpoint. Implementors must respect the | |
48 | * contract of {@link Collections#binarySearch} | |
49 | * | |
50 | * @param checkpoint | |
51 | * the checkpoint to search for | |
52 | * @return the checkpoint rank of the searched checkpoint, if it is | |
53 | * contained in the index; otherwise, (-(insertion point) - 1). | |
54 | */ | |
55 | long binarySearch(ITmfCheckpoint checkpoint); | |
56 | ||
57 | /** | |
58 | * Returns whether or not the index is empty | |
59 | * | |
60 | * @return true if empty false otherwise | |
61 | */ | |
62 | boolean isEmpty(); | |
63 | ||
64 | /** | |
65 | * Returns the number of checkpoints in the index | |
66 | * | |
67 | * @return the number of checkpoints | |
68 | */ | |
69 | int size(); | |
70 | ||
71 | /** | |
72 | * Dispose the index and its resources | |
73 | */ | |
74 | void dispose(); | |
75 | ||
76 | /** | |
77 | * Returns whether or not the index was created from scratch. An index not | |
78 | * created from scratch was typically loaded from disk. | |
79 | * | |
80 | * @return true if the index was created from scratch, false otherwise | |
81 | */ | |
82 | boolean isCreatedFromScratch(); | |
83 | ||
84 | /** | |
85 | * Set trace time range to be stored in the index | |
86 | * | |
87 | * @param timeRange | |
88 | * the time range to be stored in the index | |
89 | */ | |
90 | void setTimeRange(TmfTimeRange timeRange); | |
91 | ||
92 | /** | |
93 | * Set the total number of events in the trace to be stored in the index | |
94 | * | |
95 | * @param nbEvents | |
96 | * the total number of events | |
97 | */ | |
98 | void setNbEvents(long nbEvents); | |
99 | ||
100 | /** | |
101 | * Get the trace time range stored in the index | |
102 | * | |
103 | * @return the trace time range | |
104 | */ | |
105 | TmfTimeRange getTimeRange(); | |
106 | ||
107 | /** | |
108 | * Get the total number of events in the trace stored in the index | |
109 | * | |
110 | * @return the total number of events | |
111 | */ | |
112 | long getNbEvents(); | |
113 | ||
114 | /** | |
115 | * Set the index as complete. No more checkpoints will be inserted. | |
116 | */ | |
117 | void setIndexComplete(); | |
118 | } |