import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
public class CtfTmfTrace extends TmfTrace<CtfTmfEvent> implements ITmfEventParser<CtfTmfEvent>{
+ //-------------------------------------------
+ // Constants
+ //-------------------------------------------
+ /**
+ * Default cache size for CTF traces
+ */
+ protected static final int DEFAULT_CACHE_SIZE = 50000;
+
//-------------------------------------------
// Fields
//-------------------------------------------
- /* Reference to the state system assigned to this trace */
+ /** Reference to the state system assigned to this trace */
protected IStateSystemQuerier ss = null;
/* Reference to the CTF Trace */
@Override
public void initTrace(final IResource resource, final String path, final Class<CtfTmfEvent> eventType)
throws TmfTraceException {
+ /*
+ * Set the cache size. This has to be done before the call to super()
+ * because the super needs to know the cache size.
+ */
+ setCacheSize();
super.initTrace(resource, path, eventType);
EventDeclaration ed;
ITmfEventField eventField;
+
@SuppressWarnings("unused")
CtfTmfEventType type;
this.setStartTime(TmfTimestamp.BIG_BANG);
} else {
this.setStartTime(iterator.getCurrentEvent().getTimestamp());
- /*
- * is the trace empty
- */
- if( iterator.hasMoreEvents()){
- iterator.goToLastEvent();
- }
this.setEndTime(iterator.getCurrentEvent().getTimestamp());
}
throw new TmfTraceException(e.getMessage(), e);
}
- TmfSignalManager.register(this);
//FIXME This should be called via the ExperimentUpdated signal
buildStateSystem();
@Override
public ITmfContext seekEvent(final ITmfLocation<?> location) {
CtfLocation currentLocation = (CtfLocation) location;
+ CtfIterator context = new CtfIterator(this);
+ /*
+ * The rank is set to 0 if the iterator seeks the beginning. If not, it
+ * will be set to UNKNOWN_RANK, since CTF traces don't support seeking
+ * by rank for now.
+ */
if (currentLocation == null) {
currentLocation = new CtfLocation(0L);
+ context.setRank(0);
}
- CtfIterator context = new CtfIterator(this);
-
if (currentLocation.getLocation() == CtfLocation.INVALID_LOCATION) {
((CtfTmfTimestamp) getEndTime()).setType(TimestampType.NANOS);
currentLocation.setLocation(getEndTime().getValue() + 1);
}
context.setLocation(currentLocation);
+ if(context.getRank() != 0)
context.setRank(ITmfContext.UNKNOWN_RANK);
return context;
}
if (context instanceof CtfIterator) {
CtfIterator ctfIterator = (CtfIterator) context;
event = ctfIterator.getCurrentEvent();
- ctfIterator.advance();
+
+ if (event != null) {
+ updateAttributes(context, event.getTimestamp());
+ ctfIterator.advance();
+ ctfIterator.increaseRank();
+ }
}
+
return event;
}
}
return event;
}
+
+ /**
+ * Sets the cache size for a CtfTmfTrace.
+ */
+ protected void setCacheSize() {
+ setCacheSize(DEFAULT_CACHE_SIZE);
+ }
}