Exemple #1
0
  /** @since 2.0 */
  @Override
  public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {

    // A null timestamp indicates to seek the first event
    if (timestamp == null) {
      ITmfContext context = seekEvent((ITmfLocation) null);
      context.setRank(0);
      return context;
    }

    // Position the trace at the checkpoint
    ITmfContext context = fIndexer.seekIndex(timestamp);

    // And locate the requested event context
    ITmfLocation previousLocation = context.getLocation();
    long previousRank = context.getRank();
    ITmfEvent event = getNext(context);
    while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
      previousLocation = context.getLocation();
      previousRank = context.getRank();
      event = getNext(context);
    }
    if (event == null) {
      context.setLocation(null);
      context.setRank(ITmfContext.UNKNOWN_RANK);
    } else {
      context.dispose();
      context = seekEvent(previousLocation);
      context.setRank(previousRank);
    }
    return context;
  }
Exemple #2
0
 /**
  * Update the trace attributes
  *
  * @param context the current trace context
  * @param timestamp the corresponding timestamp
  * @since 2.0
  */
 protected synchronized void updateAttributes(
     final ITmfContext context, final ITmfTimestamp timestamp) {
   if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp, false) > 0)) {
     fStartTime = timestamp;
   }
   if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp, false) < 0)) {
     fEndTime = timestamp;
   }
   if (context.hasValidRank()) {
     long rank = context.getRank();
     if (fNbEvents <= rank) {
       fNbEvents = rank + 1;
     }
     if (fIndexer != null) {
       fIndexer.updateIndex(context, timestamp);
     }
   }
 }
Exemple #3
0
  @Override
  public synchronized ITmfContext seekEvent(final long rank) {

    // A rank <= 0 indicates to seek the first event
    if (rank <= 0) {
      ITmfContext context = seekEvent((ITmfLocation) null);
      context.setRank(0);
      return context;
    }

    // Position the trace at the checkpoint
    final ITmfContext context = fIndexer.seekIndex(rank);

    // And locate the requested event context
    long pos = context.getRank();
    if (pos < rank) {
      ITmfEvent event = getNext(context);
      while ((event != null) && (++pos < rank)) {
        event = getNext(context);
      }
    }
    return context;
  }