1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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
10 * Marc-Andre Laperle - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.trace
.indexer
.checkpoint
;
15 import java
.util
.Collections
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
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})
24 * @author Marc-Andre Laperle
26 public interface ITmfCheckpointIndex
{
29 * Add a checkpoint to the index
32 * the checkpoint to add
34 void insert(ITmfCheckpoint checkpoint
);
37 * Get a checkpoint by checkpoint rank
39 * @param checkpointRank
40 * the checkpoint rank to search for
41 * @return the checkpoint found for the given checkpoint rank
43 ITmfCheckpoint
get(long checkpointRank
);
46 * Find the checkpoint rank of a checkpoint. Implementors must respect the
47 * contract of {@link Collections#binarySearch}
50 * the checkpoint to search for
51 * @return the checkpoint rank of the searched checkpoint, if it is
52 * contained in the index; otherwise, (-(insertion point) - 1).
54 long binarySearch(ITmfCheckpoint checkpoint
);
57 * Returns whether or not the index is empty
59 * @return true if empty false otherwise
64 * Returns the number of checkpoints in the index
66 * @return the number of checkpoints
71 * Dispose the index and its resources
76 * Returns whether or not the index was created from scratch. An index not
77 * created from scratch was typically loaded from disk.
79 * @return true if the index was created from scratch, false otherwise
81 boolean isCreatedFromScratch();
84 * Set trace time range to be stored in the index
87 * the time range to be stored in the index
89 void setTimeRange(TmfTimeRange timeRange
);
92 * Set the total number of events in the trace to be stored in the index
95 * the total number of events
97 void setNbEvents(long nbEvents
);
100 * Get the trace time range stored in the index
102 * @return the trace time range
104 TmfTimeRange
getTimeRange();
107 * Get the total number of events in the trace stored in the index
109 * @return the total number of events
114 * Set the index as complete. No more checkpoints will be inserted.
116 void setIndexComplete();