Example #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;
  }
Example #2
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;
  }