aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2012-03-23 14:36:41 (EDT)
committerFrancois Chouinard2012-04-16 14:20:08 (EDT)
commit099df0107b394ad0abd9f40e88919052b6f7766d (patch)
tree12f126a7aca3bfec94ab7c0856643dd047cd4840
parent408f27d3450e68e9bbc3a543ef925fed170e2bb9 (diff)
downloadorg.eclipse.linuxtools-099df0107b394ad0abd9f40e88919052b6f7766d.zip
org.eclipse.linuxtools-099df0107b394ad0abd9f40e88919052b6f7766d.tar.gz
org.eclipse.linuxtools-099df0107b394ad0abd9f40e88919052b6f7766d.tar.bz2
Fix seek bug.
Adds indexing. Conflicts: lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java22
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketIndexEntry.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java24
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java40
4 files changed, 47 insertions, 45 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
index deabd94..83d289c 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
@@ -65,7 +65,7 @@ public class CTFTraceReader {
*/
private long index;
- private long startIndex;
+ private final long startIndex[];
// ------------------------------------------------------------------------
// Constructors
@@ -97,6 +97,11 @@ public class CTFTraceReader {
this.startTime = prio.peek().getCurrentEvent().timestamp;
this.endTime = this.startTime;
this.index = 0;
+ startIndex = new long[prio.size()];
+ for( int i = 0; i < prio.size(); i++ )
+ {
+ startIndex[i] = 0;
+ }
}
/**
@@ -254,12 +259,14 @@ public class CTFTraceReader {
*/
index++;
StreamInputPacketReader packetReader = top.getPacketReader();
+
if (packetReader.hasMoreEvents() == false) {
+ int n = this.streamInputReaders.indexOf(packetReader);
StreamInputPacketIndexEntry currentPacket = packetReader
.getCurrentPacket();
- currentPacket.indexBegin = startIndex;
- currentPacket.rankEnd = index;
- startIndex = index + 1;
+ currentPacket.indexBegin = startIndex[n];
+ currentPacket.indexEnd = index;
+ startIndex[n] = index + 1;
}
}
/*
@@ -306,22 +313,25 @@ public class CTFTraceReader {
*/
this.prio.clear();
index = 0;
+ long offset = 0;
for (StreamInputReader streamInputReader : this.streamInputReaders) {
/*
* Seek the trace reader.
*/
- long offset = streamInputReader.seek(timestamp);
+ offset += streamInputReader.seek(timestamp);
/*
* Add it to the priority queue if there is a current event.
*/
+
+ }
+ for (StreamInputReader streamInputReader : this.streamInputReaders ) {
if (streamInputReader.getCurrentEvent() != null) {
this.prio.add(streamInputReader);
index = Math.max(index, streamInputReader.getPacketReader()
.getCurrentPacket().indexBegin + offset);
}
}
-
return hasMoreEvents();
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketIndexEntry.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketIndexEntry.java
index 4efd3ee..e94b212 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketIndexEntry.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketIndexEntry.java
@@ -56,7 +56,7 @@ public class StreamInputPacketIndexEntry {
public long indexBegin = 0;
- public long rankEnd = 0;
+ public long indexEnd = 0;
// ------------------------------------------------------------------------
// Constructors
@@ -89,8 +89,8 @@ public class StreamInputPacketIndexEntry {
return (ts >= timestampBegin) && (ts <= timestampEnd);
}
- boolean includesRank(long rank){
- return (rank >= indexBegin) && (rank <= rankEnd);
+ boolean includesIndex(long index){
+ return (index >= indexBegin) && (index <= indexEnd);
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
index 972f97e..d37a3ef 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
@@ -11,7 +11,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
private final CtfTmfTrace ctfTmfTrace;
private CtfLocation curLocation;
- private long curRank;
+ private final long curRank;
/**
* Create a new CTF trace iterator, which initially points at the first
@@ -68,18 +68,24 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
return ret;
}
+ public boolean seekRank(long rank) {
+ boolean ret = false;
+ ret = super.seekIndex(rank);
+
+ if (ret) {
+ curLocation.setLocation(getCurrentEvent().getTimestampValue());
+ }
+ return ret;
+ }
+
@Override
public long getRank() {
- final CtfTmfEvent current = getCurrentEvent();
- if (current != null) {
- return getCurrentEvent().getRank();
- }
- return 0;
+ return super.getIndex();
}
@Override
public void setRank(long rank) {
- // FIXME NYI
+ seekRank( rank );
}
/*
@@ -115,12 +121,12 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
@Override
public void updateRank(int rank) {
- curRank = rank;
+ // not needed I think
}
@Override
public boolean isValidRank() {
- return true;
+ return (getRank() > -1);
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
index 65e7998..7183885 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
@@ -1,7 +1,6 @@
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;
@@ -18,7 +17,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
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> {
@@ -27,10 +25,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
// 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
// ------------------------------------------------------------------------
@@ -38,12 +32,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
// 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;
@@ -124,7 +112,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
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;
@@ -213,10 +200,14 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
@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());
@@ -225,10 +216,10 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
/**
* 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.
*/
@@ -250,7 +241,10 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
@Override
public double getLocationRatio(ITmfLocation<?> location) {
- return 0;
+ CtfIterator curLocation = (CtfIterator) location;
+ return ((double) curLocation.getCurrentEvent().getTimestampValue() -
+ curLocation.getStartTime())
+ / (curLocation.getEndTime() - curLocation.getStartTime());
}
@Override
@@ -293,14 +287,6 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
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;