Improve performance of seeks by a factor of approximately 8000.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 4 Jun 2012 20:50:55 +0000 (16:50 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 4 Jun 2012 20:55:15 +0000 (16:55 -0400)
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java

index 00842e8f7b7429a2fd064f713ffc61cd48487daf..816524285474b40b7ab7d81df60ec4b8304e8ecf 100644 (file)
@@ -57,8 +57,6 @@ public class StreamInputReader {
 
     private final long prevIndex;
 
-    private final boolean isthisthefirsttimewerereadingthisgivenstream;
-
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -72,7 +70,6 @@ public class StreamInputReader {
     public StreamInputReader(StreamInput streamInput) {
         this.streamInput = streamInput;
         this.packetReader = new StreamInputPacketReader(this);
-        this.isthisthefirsttimewerereadingthisgivenstream = true;
         /*
          * Get the iterator on the packet index.
          */
@@ -134,7 +131,6 @@ public class StreamInputReader {
      */
     public boolean readNextEvent() {
 
-
         /*
          * Change packet if needed
          */
@@ -163,8 +159,6 @@ public class StreamInputReader {
             }
             return true;
         }
-        final StreamInputPacketIndexEntry currentPacket = this
-                .getPacketReader().getCurrentPacket();
         this.setCurrentEvent(null);
         return false;
     }
@@ -219,6 +213,19 @@ public class StreamInputReader {
          */
         goToNextPacket();
 
+        /*
+         * index up to the desired timestamp.
+         */
+        while ((this.packetReader.getCurrentPacket() != null)
+                && (this.packetReader.getCurrentPacket().getTimestampEnd() < timestamp)) {
+            try {
+                this.streamInput.addPacketHeaderIndex();
+                goToNextPacket();
+            } catch (CTFReaderException e) {
+                // do nothing here
+            }
+        }
+
         /*
          * Advance until A. we reached the end of the trace file (which means
          * the given timestamp is after the last event), or B. we found the
This page took 0.025944 seconds and 5 git commands to generate.