* @see ITmfTrace
* @see ITmfEvent
*/
-public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITmfTraceIndexer<T> {
+public class TmfCheckpointIndexer implements ITmfTraceIndexer {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
// The event trace to index
- protected final ITmfTrace<ITmfEvent> fTrace;
+ protected final ITmfTrace fTrace;
// The interval between checkpoints
private final int fCheckpointInterval;
/**
* The indexing request
*/
- private ITmfEventRequest<ITmfEvent> fIndexingRequest = null;
+ private ITmfEventRequest fIndexingRequest = null;
// ------------------------------------------------------------------------
// Construction
*
* @param trace the trace to index
*/
- public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace) {
+ public TmfCheckpointIndexer(final ITmfTrace trace) {
this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
}
* @param trace the trace to index
* @param interval the checkpoints interval
*/
- public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
+ public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) {
fTrace = trace;
fCheckpointInterval = interval;
fTraceIndex = new ArrayList<ITmfCheckpoint>();
// Build a background request for all the trace data. The index is
// updated as we go by readNextEvent().
- fIndexingRequest = new TmfEventRequest<ITmfEvent>(ITmfEvent.class,
+ fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
range, offset, TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
{
- private ITmfTimestamp startTime = null;
- private ITmfTimestamp lastTime = null;
-
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
if (event != null) {
- final ITmfTimestamp timestamp = event.getTimestamp();
- if (startTime == null) {
- startTime = timestamp.clone();
- }
- lastTime = timestamp.clone();
-
// Update the trace status at regular intervals
if ((getNbRead() % fCheckpointInterval) == 0) {
updateTraceStatus();
}
private void updateTraceStatus() {
- if (getNbRead() != 0) {
- signalNewTimeRange(startTime, lastTime);
+ if (fTrace.getNbEvents() > 0) {
+ signalNewTimeRange(fTrace.getStartTime(), fTrace.getEndTime());
}
}
};
final long position = rank / fCheckpointInterval;
// Add new entry at proper location (if empty)
if (fTraceIndex.size() == position) {
- fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), shrinkContext(context)));
+ fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), saveContext(context)));
}
}
}
* @return the corresponding context
*/
private ITmfContext restoreCheckpoint(final int checkpoint) {
- ITmfLocation<?> location = null;
+ ITmfLocation location = null;
int index = 0;
synchronized (fTraceIndex) {
if (!fTraceIndex.isEmpty()) {
// Context conversion functions
// ------------------------------------------------------------------------
- private static ITmfContext shrinkContext(ITmfContext context) {
+ private static ITmfContext saveContext(ITmfContext context) {
if (context instanceof TmfExperimentContext) {
- return shrinkExpContext(context);
+ return saveExpContext(context);
}
- TmfContext ctx = new TmfContext(context.getLocation().clone(), context.getRank());
+ TmfContext ctx = new TmfContext(context.getLocation(), context.getRank());
return ctx;
}
- private static ITmfContext shrinkExpContext(ITmfContext context) {
+ private static ITmfContext saveExpContext(ITmfContext context) {
TmfExperimentContext expContext = (TmfExperimentContext) context;
int size = expContext.getContexts().length;
ITmfContext[] trcCtxts = new TmfContext[size];
for (int i = 0; i < size; i++) {
ITmfContext ctx = expContext.getContexts()[i];
- trcCtxts[i] = (ctx != null) ? new TmfContext(ctx.getLocation().clone(), ctx.getRank()) : null;
+ trcCtxts[i] = (ctx != null) ? new TmfContext(ctx.getLocation(), ctx.getRank()) : null;
}
TmfExperimentContext expCtx = new TmfExperimentContext(trcCtxts);
- expCtx.setLocation(context.getLocation().clone());
+ expCtx.setLocation(context.getLocation());
expCtx.setRank(context.getRank());
ITmfEvent[] trcEvts = expCtx.getEvents();
for (int i = 0; i < size; i++) {
int size = expContext.getContexts().length;
ITmfContext[] trcCtxts = new ITmfContext[size];
for (int i = 0; i < size; i++) {
- ITmfTrace<?> trace = ((TmfExperiment<?>) fTrace).getTraces()[i];
+ ITmfTrace trace = ((TmfExperiment) fTrace).getTraces()[i];
ITmfContext ctx = expContext.getContexts()[i];
- trcCtxts[i] = trace.seekEvent(ctx.getLocation().clone());
+ trcCtxts[i] = trace.seekEvent(ctx.getLocation());
trcCtxts[i].setRank(ctx.getRank());
}
TmfExperimentContext ctx = new TmfExperimentContext(trcCtxts);
- ctx.setLocation(context.getLocation().clone());
+ ctx.setLocation(context.getLocation());
ctx.setRank(context.getRank());
ITmfEvent[] trcEvts = expContext.getEvents();
for (int i = 0; i < size; i++) {
}
return ctx;
}
+
}