package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import java.io.FileNotFoundException;
-import java.util.Vector;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
ITmfTrace<CtfTmfEvent> {
// Constants
// ------------------------------------------------------------------------
- // The default number of events to cache
- // TODO: Make the DEFAULT_CACHE_SIZE a preference
- public static final int DEFAULT_INDEX_PAGE_SIZE = 50000;
-
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
// the Ctf Trace
private CTFTrace fTrace;
- // The cache page size AND checkpoints interval
- protected int fIndexPageSize = DEFAULT_INDEX_PAGE_SIZE;
-
- // The set of event stream checkpoints (for random access)
- private Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
-
// The number of events collected
protected long fNbEvents = 0;
super();
}
+ @SuppressWarnings("unused")
@Override
public void initTrace(String name, String path, Class<CtfTmfEvent> eventType)
throws FileNotFoundException {
* was not found or was not recognized as a CTF trace. Throw into
* the new type of exception expected by the rest of TMF.
*/
- System.err.println("Cannot find file " + path); //$NON-NLS-1$
throw new FileNotFoundException(e.getMessage());
}
this.iterator = new CtfIterator(this, 0, 0);
// this.fEndTime.clone()));
}
+ @SuppressWarnings("unused")
@Override
- public void initTrace(String name, String path,
- Class<CtfTmfEvent> eventType, int cacheSize)
- throws FileNotFoundException {
- this.initTrace(name, path, eventType);
- }
-
- @Override
- public void initTrace(String name, String path,
- Class<CtfTmfEvent> eventType, boolean indexTrace)
- throws FileNotFoundException {
- this.initTrace(name, path, eventType);
- }
-
- @Override
- public void initTrace(String name, String path,
- Class<CtfTmfEvent> eventType, int cacheSize, boolean indexTrace)
- throws FileNotFoundException {
- this.initTrace(name, path, eventType);
+ public void indexTrace(boolean waitForCompletion) {
+ // do nothing
}
@Override
TmfSignalManager.dispatchSignal(signal);
}
+ @SuppressWarnings("unused")
@Override
public boolean validate(IProject project, String path) {
try {
public CtfTmfTrace clone() throws CloneNotSupportedException {
CtfTmfTrace clone = null;
clone = (CtfTmfTrace) super.clone();
- clone.setfCheckpoints(this.fCheckpoints);
clone.fStartTime = this.fStartTime.clone();
clone.fEndTime = this.fEndTime.clone();
clone.fTrace = this.fTrace;
return clone;
}
- @Override
- public ITmfTrace<CtfTmfEvent> copy() {
- // FIXME not yet implemented
- return null;
- }
-
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
+ public int getNbEnvVars() {
+ return this.fTrace.getEnvironment().size();
+ }
+
+
+ public String[] getEnvNames() {
+ String[] s = new String[getNbEnvVars()];
+ return this.fTrace.getEnvironment().keySet().toArray(s);
+ }
+
+ public String getEnvValue(String key) {
+ return this.fTrace.getEnvironment().get(key);
+ }
+
+
/**
* @return the trace path
*/
}
@Override
- public int getCacheSize() {
- return this.fIndexPageSize;
+ public int getIndexPageSize() {
+ return 50000; // not true, but it works
}
@Override
@Override
public ITmfContext armRequest(ITmfDataRequest<CtfTmfEvent> request) {
if ((request instanceof ITmfEventRequest<?>)
- && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<CtfTmfEvent>) request).getRange().getStartTime())
+ && !TmfTimestamp.BIG_BANG
+ .equals(((ITmfEventRequest<CtfTmfEvent>) request)
+ .getRange().getStartTime())
&& (request.getIndex() == 0)) {
- ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request).getRange().getStartTime());
- ((ITmfEventRequest<CtfTmfEvent>) request).setStartIndex((int) context.getRank());
+ ITmfContext context = seekEvent(((ITmfEventRequest<CtfTmfEvent>) request)
+ .getRange().getStartTime());
+ ((ITmfEventRequest<CtfTmfEvent>) request)
+ .setStartIndex((int) context.getRank());
return context;
}
return seekEvent(request.getIndex());
/**
* The trace reader keeps its own iterator: the "context" parameter here
* will be ignored.
- *
+ *
* If you wish to specify a new context, instantiate a new CtfIterator and
* seek() it to where you want, and use that to read events.
- *
+ *
* FIXME merge with getNextEvent below once they both use the same parameter
* type.
*/
+ @SuppressWarnings("unused")
@Override
public CtfTmfEvent getNext(ITmfContext context) {
iterator.advance();
@Override
public ITmfContext seekLocation(ITmfLocation<?> location) {
- iterator.setLocation(location);
+ CtfLocation currentLocation = (CtfLocation) location;
+ if (currentLocation == null) {
+ currentLocation = new CtfLocation(0L);
+ }
+ iterator.setLocation(currentLocation);
return iterator;
}
@Override
public double getLocationRatio(ITmfLocation<?> location) {
- return 0;
+ CtfLocation curLocation = (CtfLocation) location;
+ iterator.seek(curLocation.getLocation());
+ return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator
+ .getStartTime())
+ / (iterator.getEndTime() - iterator.getStartTime());
}
@Override
return iterator;
}
+ @SuppressWarnings("unused")
@Override
public CtfTmfEvent getNextEvent(ITmfContext context) {
iterator.advance();
return iterator.getCurrentEvent();
}
+ @SuppressWarnings("unused")
@Override
public CtfTmfEvent parseEvent(ITmfContext context) {
return iterator.getCurrentEvent();
}
- public Vector<TmfCheckpoint> getfCheckpoints() {
- return this.fCheckpoints;
- }
-
- public void setfCheckpoints(Vector<TmfCheckpoint> fCheckpoints) {
- this.fCheckpoints = fCheckpoints;
- }
-
@Override
public IResource getResource() {
return this.fResource;
CTFTrace getCTFTrace() {
return fTrace;
}
+
+
+
}