Refactor TmfTrace and dependencies - move parseEvent to ITmfEventParser
authorFrancois Chouinard <fchouinard@gmail.com>
Tue, 24 Apr 2012 11:40:31 +0000 (07:40 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Tue, 24 Apr 2012 11:40:31 +0000 (07:40 -0400)
35 files changed:
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngTimestampTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/headless/LttngTraceTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTextTraceTest.java
org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/trace/LTTngTraceTest.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTextTrace.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/trace/LTTngTrace.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngEventParserStub.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTraceStub.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/experiment/TmfMultiTraceExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfEventParserStub.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/experiment/TmfExperiment.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java [deleted file]
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/Uml2SDTestFacility.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfRawEventViewer.java

index 4a2f5e4eb6ef9c21a301a2498843c0c4fb41ffb4..a11b8c433685eec097e0a77b72a101b826407246 100644 (file)
@@ -86,7 +86,7 @@ public class LttngEventContentTest extends TestCase {
         try {
             testStream = null;
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEventContent = (LttngEventContent)tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
+            tmpEventContent = (LttngEventContent)tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get content!");
@@ -148,7 +148,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
         testContent = prepareToTest();
         // getFieldS()
         assertNotSame("getFields() returned null!", null, testContent.getFields() );
@@ -177,10 +177,10 @@ public class LttngEventContentTest extends TestCase {
         // Skip first events and seek to event pass metadata
         tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) );
         // Skip first one
-        tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
 
         // Second event past metadata should have more fields
-        tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
         // Get the content
         testContent = tmpEvent.getContent();
 
@@ -211,7 +211,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
 
         final LttngEventContent tmpContent = prepareToTest();
         try {
@@ -240,7 +240,7 @@ public class LttngEventContentTest extends TestCase {
         // Require an event
         tmpStream = initializeEventStream();
         tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
-        tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+        tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
         // Get the content
         testContent = tmpEvent.getContent();
         // Get all the fields to make sure there is something in the HashMap
index ac542bdfd86fd3a9bb78ca8671406be9478f1272..1801b1a9665dcf7f074a34b728e4cfcbbcc17bbf 100644 (file)
@@ -56,7 +56,7 @@ public class LttngEventFieldTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpField = (LttngEventField)tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+            tmpField = (LttngEventField)tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get field!");
@@ -94,7 +94,7 @@ public class LttngEventFieldTest extends TestCase {
 
         LttngEventField testField = null;
         //        try {
-        testField = (LttngEventField) tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+        testField = (LttngEventField) tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
         //        } catch (TmfNoSuchFieldException e) {
         //            e.printStackTrace();
         //        }
index 713949d33b86ade332200f07f23b9bc2f7f8bdea..9843ae4df5090922a4c2e0e201afac72e74c0f8f 100644 (file)
@@ -77,7 +77,7 @@ public class LttngEventTest extends TestCase {
 
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEvent = (LttngEvent)tmpStream.getNextEvent(new TmfContext(new TmfLocation<Long>(0L), 0) );
+            tmpEvent = (LttngEvent)tmpStream.readEvent(new TmfContext(new TmfLocation<Long>(0L), 0) );
         }
         catch (final Exception e) {
             System.out.println("ERROR : Could not open " + tracepath1);
index a877c7434e4c8a1c297b26820726be3bf2b92cd6..515efa5df05f755f0afd18ad8a8313668ebee776 100644 (file)
@@ -59,7 +59,7 @@ public class LttngEventTypeTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpEventType = (LttngEventType)tmpStream.getNextEvent( new TmfContext(null, 0) ).getType();
+            tmpEventType = (LttngEventType)tmpStream.readEvent( new TmfContext(null, 0) ).getType();
         }
         catch (final Exception e) {
             fail("ERROR : Failed to get reference!");
index 37800c7e8d7873782afb6df65e6b19660e2c9982..c5db31ce837cfe6dac6828351eaab4aac5eee367 100644 (file)
@@ -58,7 +58,7 @@ public class LttngTimestampTest extends TestCase {
         // This trace should be valid
         try {
             final LTTngTextTrace tmpStream = initializeEventStream();
-            tmpTime = (LttngTimestamp) tmpStream.getNextEvent(new TmfContext(null, 0)).getTimestamp();
+            tmpTime = (LttngTimestamp) tmpStream.readEvent(new TmfContext(null, 0)).getTimestamp();
         } catch (final Exception e) {
             fail("ERROR : Failed to get reference!");
         }
index cb034a90530a5b93f147f7f620413321c1fe0470..6cf8f48dfe93fe7e8926f80836baecc84f0dc3a3 100644 (file)
@@ -67,10 +67,10 @@ public class LttngTraceTest {
 
                 // Seek to the beginning of the trace
                 tmpContext = tmptrace.seekEvent( tmpTime  );
-                tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+                tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext);
 
                 while ( tmpevent != null ) {
-                    tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+                    tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext);
 
                     // Parse the events if it was asked
                     if ( (tmpevent != null) && (PARSE_EVENTS) )
index 8a3281e4dff64aee05bc78c9e77ac17c2489d0ca..f9e939e225ac9c02fb5e2dcc835e7c0605ad7edc 100644 (file)
@@ -116,12 +116,12 @@ public class LTTngTextTraceTest extends TestCase {
         final TmfContext tmpContext = new TmfContext(null, 0);
         // We should be at the beginning of the trace, so we will just read the
         // first event now
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpEvent is null after first getNextEvent()", null, tmpEvent);
         assertEquals("tmpEvent has wrong timestamp after first getNextEvent()", firstEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Read the next event as well
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpEvent is null after second getNextEvent()", null, tmpEvent);
         assertEquals("tmpEvent has wrong timestamp after second getNextEvent()", secondEventTimestamp, tmpEvent.getTimestamp().getValue());
     }
@@ -151,7 +151,7 @@ public class LTTngTextTraceTest extends TestCase {
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
@@ -159,7 +159,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after seekEvent() to last", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after seekEvent() to last", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
@@ -167,7 +167,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
         assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
         assertNotSame("tmpContext is null after seekEvent() to first", null, tmpContext);
@@ -182,7 +182,7 @@ public class LTTngTextTraceTest extends TestCase {
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
         tmpContext = testStream1.seekEvent(indexToSeekTest1);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
@@ -190,7 +190,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(indexToSeekLast);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
@@ -198,7 +198,7 @@ public class LTTngTextTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(indexToSeekFirst);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
@@ -212,24 +212,24 @@ public class LTTngTextTraceTest extends TestCase {
 
         // We should be at the beginning of the trace, we will seek at a certain
         // timestamp
-        tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekTest1));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekTest1));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after first seekLocation()", null, tmpEvent);
         assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference()));
 
         // Seek to the last timestamp
-        tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekLast));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekLast));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekLocation() to last ", null, tmpEvent);
         assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference()));
 
         // Seek to the first timestamp (startTime)
-        tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekFirst));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekFirst));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
         assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
         assertNotSame("tmpEvent is null after seekLocation() to start ", null, tmpEvent);
index 471863b456aa77d7b1ad45793faa74df517e9b16..0982407c91a6f44901e324a4adc89f6c692b561d 100644 (file)
@@ -116,12 +116,12 @@ public class LTTngTraceTest extends TestCase {
 
         final TmfContext tmpContext = new TmfContext(null, 0);
         // We should be at the beginning of the trace, so we will just read the first event now
-        tmpEvent = testStream1.getNextEvent(tmpContext );
+        tmpEvent = testStream1.readEvent(tmpContext );
         assertNotSame("tmpEvent is null after first getNextEvent()",null,tmpEvent );
         assertEquals("tmpEvent has wrong timestamp after first getNextEvent()",firstEventTimestamp,tmpEvent.getTimestamp().getValue() );
 
         // Read the next event as well
-        tmpEvent = testStream1.getNextEvent( tmpContext);
+        tmpEvent = testStream1.readEvent( tmpContext);
         assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent );
         assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp,tmpEvent.getTimestamp().getValue() );
     }
@@ -149,7 +149,7 @@ public class LTTngTraceTest extends TestCase {
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
@@ -157,7 +157,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after seekEvent() to last",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after seekEvent() to last",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
@@ -165,7 +165,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
         assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
         assertNotSame("tmpContext is null after seekEvent() to first",null,tmpContext );
@@ -179,7 +179,7 @@ public class LTTngTraceTest extends TestCase {
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
         tmpContext = testStream1.seekEvent(indexToSeekTest1);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
@@ -187,7 +187,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the last timestamp
         tmpContext = testStream1.seekEvent(indexToSeekLast);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
@@ -195,7 +195,7 @@ public class LTTngTraceTest extends TestCase {
 
         // Seek to the first timestamp (startTime)
         tmpContext = testStream1.seekEvent(indexToSeekFirst);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
@@ -208,24 +208,24 @@ public class LTTngTraceTest extends TestCase {
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // We should be at the beginning of the trace, we will seek at a certain timestamp
-        tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekTest1));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekTest1));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent );
         assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference()));
 
         // Seek to the last timestamp
-        tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekLast));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekLast));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent );
         assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference()));
 
         // Seek to the first timestamp (startTime)
-        tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekFirst));
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekFirst));
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
         assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
         assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent );
@@ -238,41 +238,41 @@ public class LTTngTraceTest extends TestCase {
         final LTTngTrace testStream1 = prepareStreamToTest();
 
         // Test LttngLocation after a seek
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         LttngLocation location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationSeek());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a parse and parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
@@ -280,88 +280,88 @@ public class LTTngTraceTest extends TestCase {
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext and getNext
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext and parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a parse and getNext
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a parse, getNext and parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a parse, getNext and getNext
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, parse and parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
@@ -370,40 +370,40 @@ public class LTTngTraceTest extends TestCase {
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, parse and getNext
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationReadNext());
         assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
 
         // Test LttngLocation after a getNext, getNext and parse
-        tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
-        tmpEvent = testStream.getNextEvent(tmpContext);
+        tmpEvent = testStream.readEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
         tmpEvent = testStream.parseEvent(tmpContext);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
         location = (LttngLocation) tmpContext.getLocation().clone();
         assertTrue("location has wrong flag", location.isLastOperationParse());
         assertEquals("location has wrong operation time", nextnextEventTimestamp, location.getOperationTimeValue());
-        tmpContext = testStream1.seekLocation(location);
-        tmpEvent = testStream1.getNextEvent(tmpContext);
+        tmpContext = testStream1.seekEvent(location);
+        tmpEvent = testStream1.readEvent(tmpContext);
         assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
         assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
     }
index c757bc783ed029569526f117be5459d6d3e7f5cd..085dc358f7b856c3c249f652181dbc24d109266d 100644 (file)
@@ -26,12 +26,13 @@ import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.lttng.jni.JniEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
 
-public class LTTngTextTrace extends TmfTrace<LttngEvent> {
+public class LTTngTextTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
     private LttngTimestamp                  eventTimestamp   = null;
     private String                          eventSource      = null;
     private LttngEventType                  eventType        = null;
@@ -81,6 +82,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> {
 //            fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L), new TmfLocation<Long>(0L)));
             ITmfContext context = new TmfContext(new TmfLocation<Long>(0L), 0);
             fIndexer.updateIndex(context, new LttngTimestamp(0L));
+            fParser = (ITmfEventParser) this;
             //         }
             //         else {
             //                 indexTrace(true);
@@ -89,7 +91,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> {
             final Long endTime = currentLttngEvent.getTimestamp().getValue();
             positionToFirstEvent();
 
-            getNextEvent(new TmfContext(null, 0));
+            readEvent(new TmfContext(null, 0));
             final Long starTime = currentLttngEvent.getTimestamp().getValue();
             positionToFirstEvent();
 
@@ -160,7 +162,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> {
 
     @Override
     @SuppressWarnings("unchecked")
-    public TmfContext seekLocation(ITmfLocation<?> location) {
+    public TmfContext seekEvent(ITmfLocation<?> location) {
         if (location == null)
             location = new TmfLocation<Long>(0L);
 
@@ -173,7 +175,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> {
     }
 
     @Override
-    public TmfContext seekLocation(final double ratio) {
+    public TmfContext seekEvent(final double ratio) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -407,7 +409,7 @@ public class LTTngTextTrace extends TmfTrace<LttngEvent> {
 
     @Override
     public LttngEvent parseEvent(ITmfContext context) {
-        context = seekLocation(context.getLocation());
+        context = seekEvent(context.getLocation());
         return parseMyNextEvent(context);
 
     }
index cc65e7ae9b691372332f310b11bac56da57bdc2f..dfaf4c90881b27f409820d0ab0209a1b302ba41c 100644 (file)
@@ -43,6 +43,7 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
@@ -63,7 +64,7 @@ class LTTngTraceException extends LttngException {
  * LTTng trace implementation. It accesses the C trace handling library
  * (seeking, reading and parsing) through the JNI component.
  */
-public class LTTngTrace extends TmfTrace<LttngEvent> {
+public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
 
     public final static boolean PRINT_DEBUG = false;
     public final static boolean UNIQUE_EVENT = true;
@@ -151,6 +152,8 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         // Set the currentEvent to the eventContent
         eventContent.setEvent(currentLttngEvent);
 
+        fParser = (ITmfEventParser) this;
+        
         // // Bypass indexing if asked
         // if ( bypassIndexing == false ) {
         // indexTrace(true);
@@ -168,8 +171,8 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         if (jniTrace == null
                 || (!jniTrace.isLiveTraceSupported() || !LiveTraceManager.isLiveTrace(jniTrace.getTracepath()))) {
             // Set the time range of the trace
-            final TmfContext context = seekLocation(null);
-            final LttngEvent event = getNextEvent(context);
+            final TmfContext context = seekEvent(0);
+            final LttngEvent event = readEvent(context);
             final LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp());
             final LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime());
             setTimeRange(new TmfTimeRange(startTime, endTime));
@@ -179,8 +182,8 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         }
 
         // Set the time range of the trace
-        final TmfContext context = seekLocation(null);
-        final LttngEvent event = getNextEvent(context);
+        final TmfContext context = seekEvent(0);
+        final LttngEvent event = readEvent(context);
         setEndTime(TmfTimestamp.BIG_BANG);
         final long startTime = event != null ? event.getTimestamp().getValue() : TmfTimestamp.BIG_BANG.getValue();
         fStreamingInterval = LTTNG_STREAMING_INTERVAL;
@@ -440,7 +443,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
      * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext
      */
     @Override
-    public synchronized TmfContext seekLocation(final ITmfLocation<?> location) {
+    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {
 
         // // [lmcfrch]
         // lastTime = 0;
@@ -468,7 +471,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
         // If the location is marked with the read next flag
         // then it is pointing to the next event following the operation time
         if (curLocation.isLastOperationReadNext())
-            getNextEvent(context);
+            readEvent(context);
 
         return context;
     }
@@ -584,7 +587,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
     }
 
     @Override
-    public TmfContext seekLocation(final double ratio) {
+    public TmfContext seekEvent(final double ratio) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -613,7 +616,7 @@ public class LTTngTrace extends TmfTrace<LttngEvent> {
     public int nbEventsRead = 0;
 
     @Override
-    public synchronized LttngEvent getNextEvent(final ITmfContext context) {
+    public synchronized LttngEvent readEvent(final ITmfContext context) {
 
         if (PRINT_DEBUG)
             System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$
index d5e0979ad77a90b58096ae1ac7fe3d2740f15ac3..6a3415b6852b5c9b425e7607f6977725266b98c4 100644 (file)
@@ -16,9 +16,8 @@ import java.io.IOException;
 
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 
 /**
  * <b><u>TmfEventParserStub</u></b>
@@ -31,8 +30,7 @@ public class LTTngEventParserStub implements ITmfEventParser<LttngEvent> {
      * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext)
      */
     @Override
-    public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, ITmfContext context)
-                    throws IOException {
+    public ITmfEvent parseEvent(ITmfContext context) {
         // TODO Auto-generated method stub
         return null;
     }
index e88fa9d96f5a9974e2623ca9910a1558f34b33b2..4c3d4dadf767b2ab223581e4409a3d81711d1a07 100644 (file)
@@ -19,8 +19,8 @@ import java.io.RandomAccessFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
@@ -32,7 +32,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
  * Dummy test trace. Use in conjunction with LTTngEventParserStub.
  */
 @SuppressWarnings("nls")
-public class LTTngTraceStub extends TmfTrace<LttngEvent> {
+public class LTTngTraceStub extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
 
     // ========================================================================
     // Attributes
@@ -91,7 +91,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> {
      */
     @Override
     @SuppressWarnings("unchecked")
-    public TmfContext seekLocation(final ITmfLocation<?> location) {
+    public TmfContext seekEvent(final ITmfLocation<?> location) {
         TmfContext context = null;
         try {
             synchronized(fTrace) {
@@ -109,7 +109,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> {
     }
 
     @Override
-    public TmfContext seekLocation(final double ratio) {
+    public TmfContext seekEvent(final double ratio) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -139,18 +139,18 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> {
      */
     @Override
     public ITmfEvent parseEvent(final ITmfContext context) {
-        try {
+//        try {
             // paserNextEvent updates the context
-            final LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context);
+            final LttngEvent event = (LttngEvent) fParser.parseEvent(context);
             //                         if (event != null) {
             //                                 context.setTimestamp(event.getTimestamp());
             //                         }
             return event;
-        }
-        catch (final IOException e) {
-            e.printStackTrace();
-        }
-        return null;
+//        }
+//        catch (final IOException e) {
+//            e.printStackTrace();
+//        }
+//        return null;
     }
 
     /* (non-Javadoc)
index f80d2c704e6f6f191f0a3871c8b0420a3ab2f1bc..ea72941947585a4aee2d9e265653527be8806a29 100644 (file)
@@ -130,7 +130,7 @@ public class TmfExperimentTest extends TestCase {
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
             final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
             final ITmfEvent event = fExperiment.parseEvent(context);
             assertEquals("Event rank", i * pageSize, context.getRank());
             assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
@@ -144,52 +144,52 @@ public class TmfExperimentTest extends TestCase {
     public void testSeekLocationOnCacheBoundary() throws Exception {
 
         // Position trace at event rank 0
-        TmfContext context = fExperiment.seekLocation(null);
+        TmfContext context = fExperiment.seekEvent(0);
         assertEquals("Event rank", 0, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
         // Position trace at event rank 1000
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 1000, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
         // Position trace at event rank 4000
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 4000, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
         assertEquals("Event rank", 4002, context.getRank());
     }
@@ -198,53 +198,53 @@ public class TmfExperimentTest extends TestCase {
 
         // Position trace at event rank 9
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 9, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
         // Position trace at event rank 999
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 999, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
         // Position trace at event rank 1001
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 1001, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
         // Position trace at event rank 4500
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 4500, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -252,15 +252,15 @@ public class TmfExperimentTest extends TestCase {
     public void testSeekLocationOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekLocation(null);
-        final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+        TmfContext tmpContext = fExperiment.seekEvent(0);
+        final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 0, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -284,7 +284,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -296,7 +296,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -308,7 +308,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -323,7 +323,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
@@ -335,7 +335,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -347,7 +347,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -359,7 +359,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -371,7 +371,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -386,7 +386,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -410,7 +410,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -422,7 +422,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -434,7 +434,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -449,7 +449,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -461,7 +461,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -473,7 +473,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -485,7 +485,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -500,7 +500,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -525,7 +525,7 @@ public class TmfExperimentTest extends TestCase {
         // Read NB_EVENTS
         ITmfEvent event = null;;
         for (int i = 0; i < NB_READS; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
             assertEquals("Event rank", i + 1, context.getRank());
         }
@@ -544,11 +544,11 @@ public class TmfExperimentTest extends TestCase {
 
         // On lower bound, returns the first event (ts = 0)
         final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.getNextEvent(context);
+        ITmfEvent event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 2; i < 20; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
     }
index a51241131b519a275483b9b60735a6438cffe01a..9b291307dc928a0fb4d8a952f2d9ee82ad05f3a3 100644 (file)
@@ -134,7 +134,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
             final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
             final ITmfEvent event = fExperiment.parseEvent(context);
             assertEquals("Event rank", context.getRank(), i * pageSize);
             assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
@@ -148,52 +148,52 @@ public class TmfMultiTraceExperimentTest extends TestCase {
     public void testSeekLocationOnCacheBoundary() throws Exception {
 
         // Position trace at event rank 0
-        TmfContext context = fExperiment.seekLocation(null);
+        TmfContext context = fExperiment.seekEvent(0);
         assertEquals("Event rank", 0, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
         // Position trace at event rank 1000
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 1000, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
         // Position trace at event rank 4000
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 4000, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
         assertEquals("Event rank", 4002, context.getRank());
     }
@@ -202,53 +202,53 @@ public class TmfMultiTraceExperimentTest extends TestCase {
 
         // Position trace at event rank 9
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 9, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
         // Position trace at event rank 999
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 999, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
         // Position trace at event rank 1001
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 1001, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
         // Position trace at event rank 4500
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation());
+        context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 4500, context.getRank());
 
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -256,15 +256,15 @@ public class TmfMultiTraceExperimentTest extends TestCase {
     public void testSeekLocationOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekLocation(null);
-        final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+        TmfContext tmpContext = fExperiment.seekEvent(0);
+        final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
         assertEquals("Event rank", 0, context.getRank());
 
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -288,7 +288,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -300,7 +300,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -312,7 +312,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -327,7 +327,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
@@ -339,7 +339,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -351,7 +351,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -363,7 +363,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -375,7 +375,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -390,7 +390,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -414,7 +414,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -426,7 +426,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -438,7 +438,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -453,7 +453,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -465,7 +465,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -477,7 +477,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -489,7 +489,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -504,7 +504,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -529,7 +529,7 @@ public class TmfMultiTraceExperimentTest extends TestCase {
         // Read NB_EVENTS
         ITmfEvent event = null;;
         for (int i = 0; i < NB_READS; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
             assertEquals("Event rank", i + 1, context.getRank());
         }
@@ -548,11 +548,11 @@ public class TmfMultiTraceExperimentTest extends TestCase {
 
         // On lower bound, returns the first event (ts = 0)
         final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.getNextEvent(context);
+        ITmfEvent event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 2; i < 20; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
     }
index 2b21a106b6b7ca2fe90fcb13b2e105a100d34ff7..e5d304222d82db2e34be50e08f03d816e9f844d6 100644 (file)
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Adjusted for new Trace Model
+ *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.core.tests.trace;
 
 import junit.framework.Test;
@@ -5,6 +18,10 @@ import junit.framework.TestSuite;
 
 import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin;
 
+/**
+ * <b><u>AllTests</u></b>
+ * <p>
+ */
 @SuppressWarnings("nls")
 public class AllTests {
 
@@ -12,8 +29,9 @@ public class AllTests {
                TestSuite suite = new TestSuite("Test suite for " + TmfCorePlugin.PLUGIN_ID + ".trace"); //$NON-NLS-1$);
                //$JUnit-BEGIN$
                suite.addTestSuite(TmfLocationTest.class);
+        suite.addTestSuite(TmfContextTest.class);
                suite.addTestSuite(TmfCheckpointTest.class);
-               suite.addTestSuite(TmfContextTest.class);
+        suite.addTestSuite(TmfCheckpointIndexTest.class);
                suite.addTestSuite(TmfTraceTest.class);
                //$JUnit-END$
                return suite;
index b8015603b20ba3d086eab0a66e129ae54e9b877a..c26f6c5089f89eea53bbe9403cfd6d1d81ad6000 100644 (file)
@@ -126,7 +126,7 @@ public class TmfExperimentTest extends TestCase {
         // Validate that each checkpoint points to the right event
         for (int i = 0; i < checkpoints.size(); i++) {
             final TmfCheckpoint checkpoint = checkpoints.get(i);
-            final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+            final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
             final ITmfEvent event = fExperiment.parseEvent(context);
             //                 assertEquals("Event rank", context.getRank(), i * pageSize);
             assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
@@ -152,7 +152,7 @@ public class TmfExperimentTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 1; i < 20; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
 
@@ -171,11 +171,11 @@ public class TmfExperimentTest extends TestCase {
 
         // On lower bound, returns the first event (ts = 0)
         final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
-        ITmfEvent event = fExperiment.getNextEvent(context);
+        ITmfEvent event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
 
         for (int i = 2; i < 20; i++) {
-            event = fExperiment.getNextEvent(context);
+            event = fExperiment.readEvent(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
     }
@@ -188,34 +188,34 @@ public class TmfExperimentTest extends TestCase {
     public void testSeekLocationOnCacheBoundary() throws Exception {
 
         // Position trace at event rank 0
-        TmfContext context = fExperiment.seekLocation(null);
+        TmfContext context = fExperiment.seekEvent(0);
         //        assertEquals("Event rank", 0, context.getRank());
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1, context.getRank());
 
         // Position trace at event rank 1000
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 1000, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1001, context.getRank());
 
         // Position trace at event rank 4000
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 4000, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 4001, context.getRank());
     }
@@ -224,45 +224,45 @@ public class TmfExperimentTest extends TestCase {
 
         // Position trace at event rank 9
         TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
-        TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 9, context.getRank());
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 10, context.getRank());
 
         // Position trace at event rank 999
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 999, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1000, context.getRank());
 
         // Position trace at event rank 1001
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 1001, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1002, context.getRank());
 
         // Position trace at event rank 4500
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 4500, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 4501, context.getRank());
     }
@@ -270,24 +270,24 @@ public class TmfExperimentTest extends TestCase {
     public void testSeekLocationOutOfScope() throws Exception {
 
         // Position trace at beginning
-        TmfContext tmpContext = fExperiment.seekLocation(null);
-        TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        TmfContext tmpContext = fExperiment.seekEvent(0);
+        TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", 0, context.getRank());
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         //        assertEquals("Event rank", 1, context.getRank());
 
         // Position trace at event passed the end
         tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+        context = fExperiment.seekEvent(tmpContext.getLocation().clone());
         //        assertEquals("Event rank", NB_EVENTS, context.getRank());
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", null, event);
         //        assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", null, event);
         //        assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
@@ -304,7 +304,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -314,7 +314,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -324,7 +324,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -337,7 +337,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
@@ -347,7 +347,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -357,7 +357,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -367,7 +367,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -377,7 +377,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -390,7 +390,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -400,7 +400,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
@@ -417,7 +417,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -427,7 +427,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -437,7 +437,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -450,7 +450,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -460,7 +460,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -470,7 +470,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -480,7 +480,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -493,7 +493,7 @@ public class TmfExperimentTest extends TestCase {
         ITmfEvent event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -503,7 +503,7 @@ public class TmfExperimentTest extends TestCase {
         event = fExperiment.parseEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
-        event = fExperiment.getNextEvent(context);
+        event = fExperiment.readEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
index a2a58ec2cd38daa99a59b529b44a66231ca25d48..f1c4e43998b4dc57c22c39f49078a308c0022b0b 100644 (file)
@@ -27,15 +27,17 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
 import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceIndexer;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 /**
@@ -253,7 +255,7 @@ public class TmfTraceTest extends TestCase {
         try {
             final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
             testfile = new File(FileLocator.toFileURL(location).toURI());
-            original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfTraceIndexer(null));
+            original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null));
             trace = new TmfTraceStub(original);
             trace.indexTrace();
         } catch (final URISyntaxException e) {
@@ -495,13 +497,147 @@ public class TmfTraceTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // seekEvent on timestamp
+    // seekEvent on location (note: does not reliably set the rank)
+    // ------------------------------------------------------------------------
+
+    public void testSeekEventOnCacheBoundary() throws Exception {
+
+        // Position trace at event rank 0
+        ITmfContext context = fTrace.seekEvent(0);
+        ITmfEvent event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        assertEquals("Event rank", 0, context.getRank());
+
+        context = fTrace.seekEvent(context.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event rank 1000
+        ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event rank 4000
+        tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+    }
+
+    public void testSeekEventNotOnCacheBoundary() throws Exception {
+
+        // Position trace at event rank 9
+        ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
+        TmfContext context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        ITmfEvent event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event rank 999
+        tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event rank 1001
+        tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event rank 4500
+        tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+    }
+
+    public void testSeekEventOutOfScope() throws Exception {
+
+        // Position trace at beginning
+        ITmfContext tmpContext = fTrace.seekEvent(0);
+        ITmfContext context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        ITmfEvent event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        // Position trace at event passed the end
+        tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+        context = fTrace.seekEvent(tmpContext.getLocation());
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.parseEvent(context);
+        assertEquals("Event timestamp", null, event);
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+        event = fTrace.readEvent(context);
+        assertEquals("Event timestamp", null, event);
+        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+    }
+
+    // ------------------------------------------------------------------------
+    // seekEvent on timestamp (note: does not reliably set the rank)
     // ------------------------------------------------------------------------
 
     public void testSeekEventOnNullTimestamp() throws Exception {
 
         // Position trace at event rank 0
-        ITmfContext context = fTrace.seekEvent(null);
+        ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null);
         assertEquals("Event rank", 0, context.getRank());
 
         ITmfEvent event = fTrace.parseEvent(context);
@@ -519,7 +655,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -531,7 +667,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -543,7 +679,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -558,7 +694,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
         assertEquals("Event rank", 2, context.getRank());
 
@@ -570,7 +706,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -582,7 +718,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -594,7 +730,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -606,7 +742,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -621,7 +757,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -633,7 +769,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
@@ -663,7 +799,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -675,7 +811,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
@@ -687,7 +823,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4000, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
         assertEquals("Event rank", 4001, context.getRank());
     }
@@ -702,7 +838,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 9, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
         assertEquals("Event rank", 10, context.getRank());
 
@@ -714,7 +850,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 999, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
         assertEquals("Event rank", 1000, context.getRank());
 
@@ -726,7 +862,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1001, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
         assertEquals("Event rank", 1002, context.getRank());
 
@@ -738,7 +874,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4500, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
         assertEquals("Event rank", 4501, context.getRank());
     }
@@ -753,7 +889,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 0, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
         assertEquals("Event rank", 1, context.getRank());
 
@@ -765,7 +901,7 @@ public class TmfTraceTest extends TestCase {
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
 
-        event = fTrace.getNextEvent(context);
+        event = fTrace.readEvent(context);
         assertEquals("Event timestamp", null, event);
         assertEquals("Event rank", NB_EVENTS, context.getRank());
     }
@@ -799,7 +935,7 @@ public class TmfTraceTest extends TestCase {
 
         // Position the trace at event NB_READS
         for (int i = 1; i < NB_READS; i++) {
-            event = fTrace.getNextEvent(context);
+            event = fTrace.readEvent(context);
             assertEquals("Event timestamp", i, event.getTimestamp().getValue());
         }
 
@@ -816,10 +952,10 @@ public class TmfTraceTest extends TestCase {
     }
 
     // ------------------------------------------------------------------------
-    // getNextEvent - updates the context
+    // readEvent - updates the context
     // ------------------------------------------------------------------------
 
-    public void testGetNextEvent() throws Exception {
+    public void testGetEvent() throws Exception {
 
         final int NB_READS = 20;
 
@@ -829,7 +965,7 @@ public class TmfTraceTest extends TestCase {
         // Read NB_EVENTS
         ITmfEvent event;
         for (int i = 0; i < NB_READS; i++) {
-            event = fTrace.getNextEvent(context);
+            event = fTrace.readEvent(context);
             assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
             assertEquals("Event rank", i + 1, context.getRank());
         }
@@ -845,7 +981,35 @@ public class TmfTraceTest extends TestCase {
     // ------------------------------------------------------------------------
 
     @SuppressWarnings("unchecked")
-    public void testProcessRequestForNbEvents() throws Exception {
+    public void testProcessEventRequestForAllEvents() throws Exception {
+        final int BLOCK_SIZE =  1;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
+        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void handleData(final TmfEvent event) {
+                super.handleData(event);
+                requestedEvents.add(event);
+            }
+        };
+        final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+        providers[0].sendRequest(request);
+        request.waitForCompletion();
+
+        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+        assertTrue("isCompleted",  request.isCompleted());
+        assertFalse("isCancelled", request.isCancelled());
+
+        // Ensure that we have distinct events.
+        // Don't go overboard: we are not validating the stub!
+        for (int i = 0; i < NB_EVENTS; i++) {
+            assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testProcessEventRequestForNbEvents() throws Exception {
         final int BLOCK_SIZE = 100;
         final int NB_EVENTS  = 1000;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
@@ -869,16 +1033,18 @@ public class TmfTraceTest extends TestCase {
         // Ensure that we have distinct events.
         // Don't go overboard: we are not validating the stub!
         for (int i = 0; i < NB_EVENTS; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+            assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
         }
     }
 
     @SuppressWarnings("unchecked")
-    public void testProcessRequestForAllEvents() throws Exception {
+    public void testProcessEventRequestForSomeEvents() throws Exception {
         final int BLOCK_SIZE =  1;
+        final long startTime = 100;
+        final int NB_EVENTS  = 1000;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
-        final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
+        final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
         final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void handleData(final TmfEvent event) {
@@ -897,7 +1063,66 @@ public class TmfTraceTest extends TestCase {
         // Ensure that we have distinct events.
         // Don't go overboard: we are not validating the stub!
         for (int i = 0; i < NB_EVENTS; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+            assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testProcessEventRequestForOtherEvents() throws Exception {
+        final int BLOCK_SIZE =  1;
+        final int startIndex = 99;
+        final long startTime = 100;
+        final int NB_EVENTS  = 1000;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
+        final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void handleData(final TmfEvent event) {
+                super.handleData(event);
+                requestedEvents.add(event);
+            }
+        };
+        final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+        providers[0].sendRequest(request);
+        request.waitForCompletion();
+
+        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+        assertTrue("isCompleted",  request.isCompleted());
+        assertFalse("isCancelled", request.isCancelled());
+
+        // Ensure that we have distinct events.
+        // Don't go overboard: we are not validating the stub!
+        for (int i = 0; i < NB_EVENTS; i++) {
+            assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testProcessDataRequestForSomeEvents() throws Exception {
+        final int startIndex = 100;
+        final int NB_EVENTS  = 1000;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, startIndex, NB_EVENTS) {
+            @Override
+            public void handleData(final TmfEvent event) {
+                super.handleData(event);
+                requestedEvents.add(event);
+            }
+        };
+        final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+        providers[0].sendRequest(request);
+        request.waitForCompletion();
+
+        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+        assertTrue("isCompleted",  request.isCompleted());
+        assertFalse("isCancelled", request.isCancelled());
+
+        // Ensure that we have distinct events.
+        // Don't go overboard: we are not validating the stub!
+        for (int i = 0; i < NB_EVENTS; i++) {
+            assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue());
         }
     }
 
@@ -955,166 +1180,4 @@ public class TmfTraceTest extends TestCase {
         assertEquals("toString", expected, fTrace.toString());
     }
 
-
-//    // ------------------------------------------------------------------------
-//    // seekLocation
-//    // Note: seekLocation() does not reliably set the rank
-//    // ------------------------------------------------------------------------
-//
-//    public void testSeekLocationOnCacheBoundary() throws Exception {
-//
-//        // Position trace at event rank 0
-//        TmfContext context = fTrace.seekLocation(null);
-//        ITmfEvent event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-//        assertEquals("Event rank", 0, context.getRank());
-//
-//        context = fTrace.seekLocation(context.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event rank 1000
-//        ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event rank 4000
-//        tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//    }
-//
-//    public void testSeekLocationNotOnCacheBoundary() throws Exception {
-//
-//        // Position trace at event rank 9
-//        ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
-//        TmfContext context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        ITmfEvent event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event rank 999
-//        tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event rank 1001
-//        tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event rank 4500
-//        tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//    }
-//
-//    public void testSeekLocationOutOfScope() throws Exception {
-//
-//        // Position trace at beginning
-//        ITmfContext tmpContext = fTrace.seekLocation(null);
-//        ITmfContext context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        ITmfEvent event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        // Position trace at event passed the end
-//        tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-//        context = fTrace.seekLocation(tmpContext.getLocation());
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.parseEvent(context);
-//        assertEquals("Event timestamp", null, event);
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-//        event = fTrace.getNextEvent(context);
-//        assertEquals("Event timestamp", null, event);
-//        assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//    }
-
-    // ------------------------------------------------------------------------
-    // Verify checkpoints
-    // ------------------------------------------------------------------------
-
-    //    public void testTmfTraceIndexing() throws Exception {
-    //        assertEquals("getCacheSize",   BLOCK_SIZE, fTrace.getIndexPageSize());
-    //        assertEquals("getTraceSize",   NB_EVENTS,  fTrace.getNbEvents());
-    //        assertEquals("getRange-start", 1,          fTrace.getTimeRange().getStartTime().getValue());
-    //        assertEquals("getRange-end",   NB_EVENTS,  fTrace.getTimeRange().getEndTime().getValue());
-    //        assertEquals("getStartTime",   1,          fTrace.getStartTime().getValue());
-    //        assertEquals("getEndTime",     NB_EVENTS,  fTrace.getEndTime().getValue());
-    //
-    //        final Vector<TmfCheckpoint> checkpoints = fTrace.getCheckpoints();
-    //        final int pageSize = fTrace.getIndexPageSize();
-    //        assertTrue("Checkpoints exist",  checkpoints != null);
-    //
-    //        // Validate that each checkpoint points to the right event
-    //        for (int i = 0; i < checkpoints.size(); i++) {
-    //            final TmfCheckpoint checkpoint = checkpoints.get(i);
-    //            final TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
-    //            final ITmfEvent event = fTrace.parseEvent(context);
-    //            assertTrue(context.getRank() == i * pageSize);
-    //            assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
-    //        }
-    //    }
-
 }
\ No newline at end of file
index fcf8dfbf3583f05e1e53e37d2572d58a9dbe86fb..70b3b6c45a119f5b50cf823c6cdef3b207b2f325 100644 (file)
@@ -23,8 +23,8 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 
@@ -34,7 +34,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
  * TODO: Implement me. Please.
  */
 @SuppressWarnings("nls")
-public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
+public class TmfEventParserStub implements ITmfEventParser<ITmfEvent> {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -42,12 +42,14 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
 
     private static final int NB_TYPES = 10;
     private final TmfEventType[] fTypes;
+    private ITmfTrace<TmfEvent> fEventStream;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
-    public TmfEventParserStub() {
+    public TmfEventParserStub(final ITmfTrace<TmfEvent> eventStream) {
+        fEventStream = eventStream;
         fTypes = new TmfEventType[NB_TYPES];
         for (int i = 0; i < NB_TYPES; i++) {
             final Vector<String> fields = new Vector<String>();
@@ -68,13 +70,13 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
     static final String typePrefix = "Type-";
     @Override
     @SuppressWarnings("unchecked")
-    public ITmfEvent parseNextEvent(final ITmfTrace<TmfEvent> eventStream, final ITmfContext context) throws IOException {
+    public ITmfEvent parseEvent(final ITmfContext context) {
 
-        if (! (eventStream instanceof TmfTraceStub))
+        if (! (fEventStream instanceof TmfTraceStub))
             return null;
 
         // Highly inefficient...
-        final RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream();
+        final RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
         //             String name = eventStream.getName();
         //             name = name.substring(name.lastIndexOf('/') + 1);
 
@@ -83,9 +85,10 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
         long location = 0;
         if (context != null)
             location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
-        stream.seek(location);
 
         try {
+            stream.seek(location);
+
             final long ts        = stream.readLong();
             final String source  = stream.readUTF();
             final String type    = stream.readUTF();
@@ -103,11 +106,12 @@ public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
             content.append("]");
 
             final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString());
-            final ITmfEvent event = new TmfEvent(eventStream,
+            final ITmfEvent event = new TmfEvent(fEventStream,
                     new TmfTimestamp(ts, -3, 0),     // millisecs
                     source, fTypes[typeIndex], root, reference.toString());
             return event;
         } catch (final EOFException e) {
+        } catch (final IOException e) {
         }
         return null;
     }
index c9d032d4e6780cce4848d9bf057646a08a00036d..69d3a87424e81ad84504ace5d4e28437677af46d 100644 (file)
@@ -22,8 +22,8 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
@@ -36,7 +36,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
  * Dummy test trace. Use in conjunction with TmfEventParserStub.
  */
 @SuppressWarnings("nls")
-public class TmfTraceStub extends TmfTrace<TmfEvent> {
+public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<TmfEvent> {
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -45,8 +45,8 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     // The actual stream
     private RandomAccessFile fTrace;
 
-    // The associated event parser
-    private ITmfEventParser<TmfEvent> fParser;
+//    // The associated event parser
+//    private ITmfEventParser<TmfEvent> fParser;
 
     // The synchronization lock
     private final ReentrantLock fLock = new ReentrantLock();
@@ -61,7 +61,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
      */
     public TmfTraceStub() {
         super();
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
     }
 
     /**
@@ -89,7 +89,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     public TmfTraceStub(final String path, final int cacheSize, final long interval) throws FileNotFoundException {
         super(null, TmfEvent.class, path, cacheSize, interval);
         fTrace = new RandomAccessFile(path, "r");
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
     }
 
     /**
@@ -119,7 +119,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
         super(null, TmfEvent.class, path, cacheSize);
         fTrace = new RandomAccessFile(path, "r");
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
     }
 
     /**
@@ -131,7 +131,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     public TmfTraceStub(final IResource resource,  final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
         super(resource, TmfEvent.class, path, cacheSize);
         fTrace = new RandomAccessFile(path, "r");
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
     }
 
     /**
@@ -141,11 +141,12 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
      * @param parser
      * @throws FileNotFoundException
      */
+    @SuppressWarnings("unchecked")
     public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
             final ITmfEventParser<TmfEvent> parser, final ITmfTraceIndexer<?> indexer) throws FileNotFoundException {
         super(null, TmfEvent.class, path, cacheSize, 0, indexer);
         fTrace = new RandomAccessFile(path, "r");
-        fParser = (parser != null) ? parser : new TmfEventParserStub();
+        fParser = (ITmfEventParser<ITmfEvent>) ((parser != null) ? parser : new TmfEventParserStub(this));
     }
 
     /**
@@ -154,7 +155,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     public TmfTraceStub(final TmfTraceStub trace) throws FileNotFoundException {
         super(trace);
         fTrace = new RandomAccessFile(getPath(), "r");
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
     }
 
     public void indexTrace() {
@@ -164,7 +165,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
     @Override
     public void initTrace(final IResource resource, final String path, final Class<TmfEvent> type) throws FileNotFoundException {
         fTrace = new RandomAccessFile(path, "r");
-        fParser = new TmfEventParserStub();
+        fParser = new TmfEventParserStub(this);
         super.initTrace(resource, path, type);
     }
 
@@ -187,7 +188,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
 
     @Override
     @SuppressWarnings("unchecked")
-    public TmfContext seekLocation(final ITmfLocation<?> location) {
+    public TmfContext seekEvent(final ITmfLocation<?> location) {
         try {
             fLock.lock();
             try {
@@ -222,12 +223,12 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
 
 
     @Override
-    public TmfContext seekLocation(final double ratio) {
+    public TmfContext seekEvent(final double ratio) {
         fLock.lock();
         try {
             if (fTrace != null) {
                 final ITmfLocation<?> location = new TmfLocation<Long>(Long.valueOf((long) (ratio * fTrace.length())));
-                final TmfContext context = seekLocation(location);
+                final TmfContext context = seekEvent(location);
                 context.setRank(ITmfContext.UNKNOWN_RANK);
                 return context;
             }
@@ -276,12 +277,12 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
         try {
             // parseNextEvent will update the context
             if (fTrace != null) {
-                final ITmfEvent event = fParser.parseNextEvent(this, context.clone());
+                final ITmfEvent event = fParser.parseEvent(context.clone());
                 return event;
             }
-        }
-        catch (final IOException e) {
-            e.printStackTrace();
+//        }
+//        catch (final IOException e) {
+//            e.printStackTrace();
         } finally {
             fLock.unlock();
         }
index fd0d769f748e5f84ae319f1f8fa7e80a9acac8a8..3bf8d3f11465258de21aea3611ef7cf452469453 100644 (file)
@@ -23,7 +23,6 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse
  org.eclipse.linuxtools.tmf.core.filter.xml,
  org.eclipse.linuxtools.tmf.core.interval,
  org.eclipse.linuxtools.tmf.core.io,
- org.eclipse.linuxtools.tmf.core.parser,
  org.eclipse.linuxtools.tmf.core.request,
  org.eclipse.linuxtools.tmf.core.signal,
  org.eclipse.linuxtools.tmf.core.statesystem,
index 9481d2d3e237be7c1855f5cea161db4d40dacfed..1a57e6e5fb879c7f1fd44581673d21c1ebfa71bd 100644 (file)
@@ -245,7 +245,7 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements ITmfTr
     // ------------------------------------------------------------------------
 
     @Override
-    public ITmfContext seekLocation(final ITmfLocation<?> location) {
+    public ITmfContext seekEvent(final ITmfLocation<?> location) {
         CtfLocation currentLocation = (CtfLocation) location;
         if (currentLocation == null)
             currentLocation = new CtfLocation(0L);
@@ -286,21 +286,21 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements ITmfTr
      * Seek rank ratio
      */
     @Override
-    public ITmfContext seekLocation(final double ratio) {
+    public ITmfContext seekEvent(final double ratio) {
         iterator.seek((long) (this.fNbEvents * ratio));
         return iterator;
     }
 
     @Override
-    public CtfTmfEvent getNextEvent(final ITmfContext context) {
+    public CtfTmfEvent readEvent(final ITmfContext context) {
         iterator.advance();
         return iterator.getCurrentEvent();
     }
 
-    @Override
-    public CtfTmfEvent parseEvent(final ITmfContext context) {
-        return iterator.getCurrentEvent();
-    }
+//    @Override
+//    public CtfTmfEvent parseEvent(final ITmfContext context) {
+//        return iterator.getCurrentEvent();
+//    }
 
     @Override
     public IResource getResource() {
index ed9758506814cb13c0e189eac25d42957f71cecb..4b4cb226392732876501579b0d555daf603600ae 100644 (file)
@@ -247,7 +247,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      */
     public ITmfTimestamp getTimestamp(final int index) {
         final TmfExperimentContext context = seekEvent(index);
-        final ITmfEvent event = getNextEvent(context);
+        final ITmfEvent event = readEvent(context);
         return (event != null) ? event.getTimestamp() : null;
     }
 
@@ -302,7 +302,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     @SuppressWarnings("unchecked")
     public T getNext(final ITmfContext context) {
         if (context instanceof TmfExperimentContext)
-            return (T) getNextEvent(context);
+            return (T) readEvent(context);
         return null;
     }
 
@@ -313,7 +313,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     // Returns a brand new context based on the location provided
     // and initializes the event queues
     @Override
-    public synchronized TmfExperimentContext seekLocation(final ITmfLocation<?> location) {
+    public synchronized TmfExperimentContext seekEvent(final ITmfLocation<?> location) {
         // Validate the location
         if (location != null && !(location instanceof TmfExperimentLocation))
             return null; // Throw an exception?
@@ -336,7 +336,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
             final long traceRank = expLocation.getRanks()[i];
 
             // Set the corresponding sub-context
-            context.getContexts()[i] = fTraces[i].seekLocation(traceLocation);
+            context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
             context.getContexts()[i].setRank(traceRank);
             rank += traceRank;
 
@@ -346,7 +346,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
              * ourselves higher up.
              */
             expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone();
-            context.getEvents()[i] = fTraces[i].getNextEvent(context.getContexts()[i]);
+            context.getEvents()[i] = fTraces[i].readEvent(context.getContexts()[i]);
         }
 
         // Tracer.trace("Ctx: SeekLocation - done");
@@ -392,13 +392,13 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
                 location = null;
         }
 
-        final TmfExperimentContext context = seekLocation(location);
+        final TmfExperimentContext context = seekEvent(location);
         context.setRank((long) index * fIndexPageSize);
 
         // And locate the event
         ITmfEvent event = parseEvent(context);
         while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) {
-            getNextEvent(context);
+            readEvent(context);
             event = parseEvent(context);
         }
 
@@ -431,14 +431,14 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
             }
         }
 
-        final TmfExperimentContext context = seekLocation(location);
+        final TmfExperimentContext context = seekEvent(location);
         context.setRank((long) index * fIndexPageSize);
 
         // And locate the event
         ITmfEvent event = parseEvent(context);
         long pos = context.getRank();
         while ((event != null) && (pos++ < rank)) {
-            getNextEvent(context);
+            readEvent(context);
             event = parseEvent(context);
         }
 
@@ -451,7 +451,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     }
 
     @Override
-    public TmfContext seekLocation(final double ratio) {
+    public TmfContext seekEvent(final double ratio) {
         final TmfContext context = seekEvent((long) (ratio * getNbEvents()));
         return context;
     }
@@ -459,7 +459,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     @Override
     public double getLocationRatio(final ITmfLocation<?> location) {
         if (location instanceof TmfExperimentLocation)
-            return (double) seekLocation(location).getRank() / getNbEvents();
+            return (double) seekEvent(location).getRank() / getNbEvents();
         return 0;
     }
 
@@ -494,7 +494,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
      * @return the next event
      */
     @Override
-    public synchronized ITmfEvent getNextEvent(final ITmfContext context) {
+    public synchronized ITmfEvent readEvent(final ITmfContext context) {
 
         // Validate the context
         if (!(context instanceof TmfExperimentContext))
@@ -502,7 +502,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
 
         if (!context.equals(fExperimentContext))
             // Tracer.trace("Ctx: Restoring context");
-            fExperimentContext = seekLocation(context.getLocation());
+            fExperimentContext = seekEvent(context.getLocation());
 
         final TmfExperimentContext expContext = (TmfExperimentContext) context;
 
@@ -512,7 +512,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         final int lastTrace = expContext.getLastTrace();
         if (lastTrace != TmfExperimentContext.NO_TRACE) {
             final ITmfContext traceContext = expContext.getContexts()[lastTrace];
-            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext);
             expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
         }
 
@@ -585,7 +585,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
      */
-    @Override
+//    @Override
     public ITmfEvent parseEvent(final ITmfContext context) {
 
         // Validate the context
@@ -594,7 +594,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
 
         if (!context.equals(fExperimentContext))
             // Tracer.trace("Ctx: Restoring context");
-            seekLocation(context.getLocation());
+            seekEvent(context.getLocation());
 
         final TmfExperimentContext expContext = (TmfExperimentContext) context;
 
@@ -602,7 +602,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         final int lastTrace = expContext.getLastTrace();
         if (lastTrace != TmfExperimentContext.NO_TRACE) {
             final ITmfContext traceContext = expContext.getContexts()[lastTrace];
-            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+            expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext);
             expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
             fExperimentContext = (TmfExperimentContext) context;
         }
@@ -647,7 +647,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfEventProvider<T> impl
         fInitialized = true;
 
         if (getStreamingInterval() == 0) {
-            final TmfContext context = seekLocation(null);
+            final TmfContext context = seekEvent(0);
             final ITmfEvent event = getNext(context);
             if (event == null)
                 return;
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parser/ITmfEventParser.java
deleted file mode 100644 (file)
index abb07bf..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Ericsson
- * 
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.parser;
-
-import java.io.IOException;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-
-/**
- * <b><u>ITmfEventParser</u></b>
- * <p>
- */
-public interface ITmfEventParser<T extends ITmfEvent> {
-
-    /**
-     * @return a parsed event
-     * @throws IOException 
-     */
-       /**
-        * Parses the trace event referenced by the context.
-        * 
-        * @param trace the event stream
-        * @param context the trace context
-        * @return the parsed event
-        * @throws IOException
-        */
-       public ITmfEvent parseNextEvent(ITmfTrace<T> trace, ITmfContext context) throws IOException;
-}
index eb5f9d5987c2e0c7ad747554334c222304c41ddf..d490bb007f63a8b68e935a7bfea86d54eb557d87 100644 (file)
@@ -114,6 +114,20 @@ public abstract class TmfEventRequest<T extends ITmfEvent> extends TmfDataReques
        this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
     }
 
+    /**
+     * Request 'n' events of a given type for the given time range (high priority).
+     * Events are returned in blocks of the given size.
+     * 
+     * @param dataType the requested data type
+     * @param range the time range of the requested events
+     * @param index the index of the first event to retrieve
+     * @param nbRequested the number of events requested
+     * @param blockSize the number of events per block
+     */
+    public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int index, int nbRequested, int blockSize) {
+        this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
+    }
+
     /**
      * Request 'n' events of a given type for the given time range (given priority).
      * Events are returned in blocks of the given size.
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfEventParser.java
new file mode 100644 (file)
index 0000000..74fa648
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *   Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * <b><u>ITmfEventParser</u></b>
+ * <p>
+ */
+public interface ITmfEventParser<T extends ITmfEvent> {
+
+       /**
+        * Parses the trace event referenced by the context.
+        * 
+        * @param context
+        * @return
+        */
+       public ITmfEvent parseEvent(ITmfContext context);
+
+}
index befb513660ae0a9497fbad0db30710809383b5fc..2ea567caa8d2aa2ca14bf1ce3510227e175416a7 100644 (file)
@@ -21,22 +21,23 @@ import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
 
 /**
  * <b><u>ITmfTrace</u></b>
  * <p>
  * The event stream structure in TMF. In its basic form, a trace has:
  * <ul>
- * <li> the associated Eclipse resource
- * <li> the path to its location on the file system
+ * <li> an associated Eclipse resource
+ * <li> a path to its location on the file system
  * <li> the type of the events it contains
  * <li> the number of events it contains
  * <li> the time range (span) of the events it contains
  * </ul>
  * Concrete ITmfTrace classes have to provide a parameter-less constructor and
- * an initialization method (initTace())if they are to be opened from the
- * Project View. Also, a validation (validate()) method has to be provided to
- * ensure that the trace is of the correct type.
+ * an initialization method (<i>initTrace</i>) if they are to be opened from
+ * the Project View. Also, a validation method (<i>validate</i>) has to be 
+ * provided to ensure that the trace is of the correct type.
  * <p>
  * A trace can be accessed simultaneously from multiple threads by various
  * application components. To avoid obvious multi-threading issues, the trace
@@ -48,22 +49,22 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  * <p>
  * <b>Example 1</b>: Process a whole trace
  * <pre>
- * ITmfContext context = trace.seekLocationt(null);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfContext context = trace.seekEvent(0);
+ * ITmfEvent event = trace.getEvent(context);
  * while (event != null) {
  *     processEvent(event);
- *     event = trace.getNextEvent(context);
+ *     event = trace.getEvent(context);
  * }
  * </pre>
  * <b>Example 2</b>: Process 50 events starting from the 1000th event
  * <pre>
  * int nbEventsRead = 0;
  * ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfEvent event = trace.getEvent(context);
  * while (event != null && nbEventsRead < 50) {
  *     nbEventsRead++;
  *     processEvent(event);
- *     event = trace.getNextEvent(context);
+ *     event = trace.getEvent(context);
  * }
  * </pre>
  * <b>Example 3</b>: Process the events between 2 timestamps (inclusive)
@@ -71,17 +72,17 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  * ITmfTimestamp startTime = ...;
  * ITmfTimestamp endTime = ...;
  * ITmfContext context = trace.seekEvent(startTime);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfEvent event = trace.getEvent(context);
  * while (event != null && event.getTimestamp().compareTo(endTime) <= 0) {
  *     processEvent(event);
- *     event = trace.getNextEvent(context);
+ *     event = trace.getEvent(context);
  * }
  * </pre>
  * A trace is also an event provider so it can process event requests
- * asynchronously (and coalesce compatible requests).
+ * asynchronously (and coalesce compatible, concurrent requests).
  * <p>
  * </pre>
- * <b>Example 4</b>: Process a whole trace
+ * <b>Example 4</b>: Process a whole trace (see ITmfEventRequest for variants)
  * <pre>
  * ITmfRequest request = new TmfEventRequest&lt;MyEventType&gt;(MyEventType.class) {
  *     &#64;Override
@@ -95,6 +96,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  *         super.handleCompleted();
  *     }
  * };
+ * 
  * fTrace.handleRequest(request);
  * if (youWant) {
  *     request.waitForCompletion();
@@ -102,7 +104,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
  * </pre>
  * @see ITmfEvent
  * @see ITmfEventProvider
- * @see ITmfRequest
+ * @see ITmfEventRequest
  */
 public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
 
@@ -201,35 +203,36 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
     public double getLocationRatio(ITmfLocation<?> location);
 
     // ------------------------------------------------------------------------
-    // Seek operations (returning a reading context)
+    // SeekEvent operations (returning a trace context)
     // ------------------------------------------------------------------------
 
     /**
-     * Position the trace at the specified location. The null location
-     * is used to indicate that the first trace event is requested.
+     * Position the trace at the specified (trace specific) location.
+     * <p>
+     * A null location is interpreted as seeking for the first event of the
+     * trace.
      * <p>
-     * <ul>
-     * <li> a <b>null</b> location returns the context of the first event
-     * <li> an invalid location, including beyond the last event, returns a null context
-     * </ul>
+     * If not null, the location requested must be valid otherwise the returned
+     * context is undefined (up to the implementation to recover if possible).
      * <p>
-     * @param location the trace specific location (null for 1st event)
+     * @param location the trace specific location
      * @return a context which can later be used to read the corresponding event
      */
-    public ITmfContext seekLocation(ITmfLocation<?> location);
+    public ITmfContext seekEvent(ITmfLocation<?> location);
 
     /**
-     * Position the trace at the event located at the specified ratio in the
-     * trace file.
+     * Position the trace at the 'rank'th event in the trace.
      * <p>
-     * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
-     * voluntarily vague. Typically, it would refer to the event proportional
-     * rank (arguably more intuitive) or timestamp in the trace file.
+     * A rank <= 0 is interpreted as seeking for the first event of the
+     * trace.
+     * <p>
+     * If the requested rank is beyond the last trace event, the context
+     * returned will yield a null event if used in a subsequent read.
      * 
-     * @param ratio the proportional 'rank' in the trace
+     * @param rank the event rank
      * @return a context which can later be used to read the corresponding event
      */
-    public ITmfContext seekLocation(double ratio);
+    public ITmfContext seekEvent(long rank);
 
     /**
      * Position the trace at the first event with the specified timestamp. If
@@ -248,15 +251,17 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
     public ITmfContext seekEvent(ITmfTimestamp timestamp);
 
     /**
-     * Position the trace at the 'rank'th event in the trace.
+     * Position the trace at the event located at the specified ratio in the
+     * trace file.
      * <p>
-     * If the requested rank is beyond the last trace event, the context
-     * returned will yield a null event if used in a subsequent read.
+     * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
+     * voluntarily vague. Typically, it would refer to the event proportional
+     * rank (arguably more intuitive) or timestamp in the trace file.
      * 
-     * @param rank the event rank
+     * @param ratio the proportional 'rank' in the trace
      * @return a context which can later be used to read the corresponding event
      */
-    public ITmfContext seekEvent(long rank);
+    public ITmfContext seekEvent(double ratio);
 
     // ------------------------------------------------------------------------
     // Read operations (returning an actual event)
@@ -269,18 +274,19 @@ public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
      * @param context the read context (will be updated)
      * @return the event pointed to by the context
      */
-    public ITmfEvent getNextEvent(ITmfContext context);
+    public ITmfEvent readEvent(ITmfContext context);
 
-    /**
-     * Return the event pointed by the supplied context (or null if no event
-     * left) and *does not* update the context.
-     * 
-     * @param context the read context
-     * @return the next event in the stream
-     */
-    public ITmfEvent parseEvent(ITmfContext context);
+//    /**
+//     * Return the event pointed by the supplied context (or null if no event
+//     * left) and *does not* update the context.
+//     * 
+//     * @param context the read context
+//     * @return the next event in the stream
+//     */
+//    public ITmfEvent parseEvent(ITmfContext context);
 
     // ------------------------------------------------------------------------
+    //
     // ------------------------------------------------------------------------
 
     /**
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfCheckpointIndexer.java
new file mode 100644 (file)
index 0000000..2b35e0a
--- /dev/null
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace;
+
+import java.util.Collections;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+
+/**
+ * <b><u>TmfTraceIndexer</u></b>
+ * <p>
+ * A simple trace indexer that builds an array of trace checkpoints. Checkpoints
+ * are stored at fixed intervals (event rank) in ascending timestamp order.
+ * <p>
+ * The goal being to access a random trace event reasonably fast from the user's
+ * standpoint, picking the right interval value becomes a trade-off between speed
+ * and memory usage (a shorter inter-event interval is faster but requires more
+ * checkpoints).
+ * <p>
+ * Locating a specific checkpoint is trivial for both rank (rank % interval) and
+ * timestamp (bsearch in the array).
+ */
+public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITmfTraceIndexer<T> {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    /**
+     * The event trace to index
+     */
+    private final ITmfTrace<ITmfEvent> fTrace;
+
+    /**
+     * The interval between checkpoints
+     */
+    protected final int fCheckpointInterval;
+
+    /**
+     * The trace index. It is composed of checkpoints taken at intervals of
+     * fCheckpointInterval events.
+     */
+    protected final Vector<TmfCheckpoint> fTraceIndex;
+
+    // ------------------------------------------------------------------------
+    // Construction
+    // ------------------------------------------------------------------------
+
+    /**
+     * Basic constructor that uses the default trace block size as checkpoints
+     * intervals
+     * 
+     * @param trace the trace to index
+     */
+    public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace) {
+        this(trace, TmfTrace.DEFAULT_BLOCK_SIZE);
+    }
+
+    /**
+     * Full trace indexer
+     * 
+     * @param trace the trace to index
+     * @param interval the checkpoints interval
+     */
+    public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
+        fTrace = trace;
+        fCheckpointInterval = interval;
+        fTraceIndex = new Vector<TmfCheckpoint>();
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfTraceIndexer - buildIndex
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#indexTrace(boolean)
+     * 
+     * The index is a list of contexts that point to events at regular interval
+     * (rank-wise) in the trace. After it is built, the index can be used to
+     * quickly access any event by rank or timestamp (using seekIndex()).
+     * 
+     * The index is built simply by reading the trace
+     */
+    @Override
+    public void buildIndex(final boolean waitForCompletion) {
+
+        // The monitoring job
+        final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+            @Override
+            protected IStatus run(final IProgressMonitor monitor) {
+                while (!monitor.isCanceled()) {
+                    try {
+                        Thread.sleep(100);
+                    } catch (final InterruptedException e) {
+                        return Status.OK_STATUS;
+                    }
+                }
+                monitor.done();
+                return Status.OK_STATUS;
+            }
+        };
+        job.schedule();
+
+        // Clear the checkpoints
+        fTraceIndex.clear();
+
+        // Build a background request for all the trace data. The index is
+        // updated as we go by getNextEvent().
+        final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, TmfTimeRange.ETERNITY,
+                TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
+        {
+            ITmfTimestamp startTime = null;
+            ITmfTimestamp lastTime = null;
+
+            @Override
+            public void handleData(final ITmfEvent event) {
+                super.handleData(event);
+                if (event != null) {
+                    final ITmfTimestamp timestamp = event.getTimestamp();
+                    if (startTime == null) {
+                        startTime = timestamp.clone();
+                    }
+                    lastTime = timestamp.clone();
+
+                    // Update the trace status at regular intervals
+                    if ((getNbRead() % fCheckpointInterval) == 0) {
+                        updateTraceStatus();
+                    }
+                }
+            }
+
+            @Override
+            public void handleSuccess() {
+                updateTraceStatus();
+            }
+
+            @Override
+            public void handleCompleted() {
+                job.cancel();
+                super.handleCompleted();
+            }
+
+            private void updateTraceStatus() {
+                if (getNbRead() != 0) {
+                    signalNewTimeRange(startTime, lastTime);
+                }
+            }
+        };
+
+        // Submit the request and wait for completion if required
+        fTrace.sendRequest(request);
+        if (waitForCompletion) {
+            try {
+                request.waitForCompletion();
+            } catch (final InterruptedException e) {
+            }
+        }
+    }
+
+    /**
+     * Notify the interested parties that the trace time range has changed
+     * 
+     * @param startTime the new start time
+     * @param endTime the new end time
+     */
+    private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
+        fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfTraceIndexer - updateIndex
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#updateIndex(org.eclipse.linuxtools.tmf.core.trace.ITmfContext, org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+     */
+    @Override
+    public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+        final long rank = context.getRank();
+        if ((rank % fCheckpointInterval) == 0) {
+            // Determine the table position
+            final long position = rank / fCheckpointInterval;
+            // Add new entry at proper location (if empty)
+            if (fTraceIndex.size() == position) {
+                final ITmfLocation<?> location = context.getLocation().clone();
+                fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), location));
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfTraceIndexer - seekIndex
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+     */
+    @Override
+    public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
+
+        // A null timestamp indicates to seek the first event
+        if (timestamp == null)
+            return fTrace.seekEvent(0);
+
+        // Find the checkpoint at or before the requested timestamp.
+        // In the very likely event that the timestamp is not at a checkpoint
+        // boundary, bsearch will return index = (- (insertion point + 1)).
+        // It is then trivial to compute the index of the previous checkpoint.
+        int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
+        if (index < 0) {
+            index = Math.max(0, -(index + 2));
+        }
+
+        // Position the trace at the checkpoint
+        return seekCheckpoint(index);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(long)
+     */
+    @Override
+    public ITmfContext seekIndex(final long rank) {
+
+      // A rank < 0 indicates to seek the first event
+      if (rank < 0)
+          return fTrace.seekEvent(0);
+
+      // Find the checkpoint at or before the requested rank.
+      final int index = (int) rank / fCheckpointInterval;
+
+      // Position the trace at the checkpoint
+      return seekCheckpoint(index);
+    }
+
+    /**
+     * Position the trace at the given checkpoint
+     * 
+     * @param index
+     *            the checkpoint index
+     * @return the corresponding context
+     */
+    private ITmfContext seekCheckpoint(int index) {
+        ITmfLocation<?> location;
+        synchronized (fTraceIndex) {
+            if (!fTraceIndex.isEmpty()) {
+                if (index >= fTraceIndex.size()) {
+                    index = fTraceIndex.size() - 1;
+                }
+                location = fTraceIndex.elementAt(index).getLocation();
+            } else {
+                location = null;
+            }
+        }
+        final ITmfContext context = fTrace.seekEvent(location);
+        context.setRank(index * fCheckpointInterval);
+        return context;
+    }
+
+}
index 0f2063a5a16cf12ea89bc5df8b67a7ce07ba6b71..75891a7a0a71d00415832d2351295338a249c727 100644 (file)
@@ -56,14 +56,13 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     private String fPath;
 
     /**
-     * The cache page size AND trace checkpoints interval
+     * The cache page size
      */
     protected int fCacheSize = DEFAULT_TRACE_CACHE_SIZE;
 
-    // The set of event stream checkpoints
-//    protected Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
-
-    // The number of events collected
+    /**
+     * The number of events collected so far
+     */
     protected long fNbEvents = 0;
 
     // The time span of the event stream
@@ -80,6 +79,11 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
      */
     protected ITmfTraceIndexer<ITmfTrace<ITmfEvent>> fIndexer;
 
+    /**
+     * The trace parser
+     */
+    protected ITmfEventParser<ITmfEvent> fParser;
+
     // ------------------------------------------------------------------------
     // Construction
     // ------------------------------------------------------------------------
@@ -90,7 +94,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public TmfTrace() {
         super();
-        fIndexer = new TmfTraceIndexer(this);
+        fIndexer = new TmfCheckpointIndexer(this);
     }
 
     /**
@@ -136,7 +140,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         super();
         fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE;
         fStreamingInterval = interval;
-        fIndexer = (indexer != null) ? indexer : new TmfTraceIndexer(this, fCacheSize);
+        fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize);
         initialize(resource, path, type);
     }
 
@@ -152,10 +156,23 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
             throw new IllegalArgumentException();
         fCacheSize = trace.getCacheSize();
         fStreamingInterval = trace.getStreamingInterval();
-        fIndexer = new TmfTraceIndexer(this);
+        fIndexer = new TmfCheckpointIndexer(this);
         initialize(trace.getResource(), trace.getPath(), trace.getType());
     }
 
+    // ------------------------------------------------------------------------
+    // ITmfTrace - Initializers
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
+     */
+    @Override
+    public void initTrace(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
+        initialize(resource, path, type);
+        fIndexer.buildIndex(false);
+    }
+
     /**
      * Initialize the trace common attributes and the base component.
      * 
@@ -179,19 +196,6 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
         super.init(traceName, type);
     }
 
-    // ------------------------------------------------------------------------
-    // ITmfTrace - Initializers
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
-     */
-    @Override
-    public void initTrace(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
-        initialize(resource, path, type);
-        fIndexer.buildIndex(false);
-    }
-
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
      * 
@@ -326,53 +330,53 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     }
 
     // ------------------------------------------------------------------------
-    // ITmfTrace - Seek operations (returning a reading context)
+    // ITmfTrace - SeekEvent operations (returning a trace context)
     // ------------------------------------------------------------------------
 
     /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long)
      */
     @Override
-    public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
+    public synchronized ITmfContext seekEvent(final long rank) {
 
-        // A null timestamp indicates to seek the first event
-        if (timestamp == null)
-            return seekLocation(null);
+        // A rank <= 0 indicates to seek the first event
+        if (rank <= 0)
+            return seekEvent((ITmfLocation<?>) null);
 
         // Position the trace at the checkpoint
-        final ITmfContext context = fIndexer.seekIndex(timestamp);
+        final ITmfContext context = fIndexer.seekIndex(rank);
 
         // And locate the requested event context
-        final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
-        ITmfEvent event = getNextEvent(nextEventContext);
-        while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
-            context.setLocation(nextEventContext.getLocation().clone());
-            context.increaseRank();
-            event = getNextEvent(nextEventContext);
+        long pos = context.getRank();
+        if (pos < rank) {
+            ITmfEvent event = readEvent(context);
+            while (event != null && ++pos < rank) {
+                event = readEvent(context);
+            }
         }
         return context;
     }
 
     /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
      */
     @Override
-    public synchronized ITmfContext seekEvent(final long rank) {
+    public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
 
-        // A rank <= 0 indicates to seek the first event
-        if (rank <= 0)
-            return seekLocation(null);
+        // A null timestamp indicates to seek the first event
+        if (timestamp == null)
+            return seekEvent(0);
 
         // Position the trace at the checkpoint
-        final ITmfContext context = fIndexer.seekIndex(rank);
+        final ITmfContext context = fIndexer.seekIndex(timestamp);
 
         // And locate the requested event context
-        long pos = context.getRank();
-        if (pos < rank) {
-            ITmfEvent event = getNextEvent(context);
-            while (event != null && ++pos < rank) {
-                event = getNextEvent(context);
-            }
+        final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
+        ITmfEvent event = readEvent(nextEventContext);
+        while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
+            context.setLocation(nextEventContext.getLocation().clone());
+            context.increaseRank();
+            event = readEvent(nextEventContext);
         }
         return context;
     }
@@ -382,22 +386,12 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     // ------------------------------------------------------------------------
 
     /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
-     */
-    @Override
-    public synchronized ITmfEvent parseEvent(final ITmfContext context) {
-        final ITmfContext tmpContext = context.clone();
-        final ITmfEvent event = getNextEvent(tmpContext);
-        return event;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
      */
     @Override
-    public synchronized ITmfEvent getNextEvent(final ITmfContext context) {
+    public synchronized ITmfEvent readEvent(final ITmfContext context) {
         // parseEvent() does not update the context
-        final ITmfEvent event = parseEvent(context);
+        final ITmfEvent event = fParser.parseEvent(context);
         if (event != null) {
             updateAttributes(context, event.getTimestamp());
             context.setLocation(getCurrentLocation());
@@ -409,7 +403,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
 
     /**
      * Hook for special event processing by the concrete class
-     * (called by TmfTrace.getNextEvent())
+     * (called by TmfTrace.getEvent())
      * 
      * @param event the event
      */
@@ -467,7 +461,7 @@ public abstract class TmfTrace<T extends ITmfEvent> extends TmfEventProvider<T>
     @SuppressWarnings("unchecked")
     public T getNext(final ITmfContext context) {
         if (context instanceof TmfContext)
-            return (T) getNextEvent(context);
+            return (T) readEvent(context);
         return null;
     }
 
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceIndexer.java
deleted file mode 100644 (file)
index 65b2f83..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Ericsson
- * 
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import java.util.Collections;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
-
-/**
- * <b><u>TmfTraceIndexer</u></b>
- * <p>
- * A simple trace indexer that builds an array of trace checkpoints. Checkpoints
- * are stored at fixed intervals (event rank) in ascending timestamp order.
- * <p>
- * The goal being to access a random trace event reasonably fast from the user's
- * standpoint, picking the right interval value becomes a trade-off between speed
- * and memory usage (a shorter inter-event interval is faster but requires more
- * checkpoints).
- * <p>
- * Locating a specific checkpoint is trivial for both rank (rank % interval) and
- * timestamp (bsearch in the array).
- */
-public class TmfTraceIndexer<T extends ITmfTrace<ITmfEvent>> implements ITmfTraceIndexer<T> {
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    /**
-     * The event trace to index
-     */
-    private final ITmfTrace<ITmfEvent> fTrace;
-
-    /**
-     * The interval between checkpoints
-     */
-    protected final int fCheckpointInterval;
-
-    /**
-     * The trace index. It is composed of checkpoints taken at intervals of
-     * fCheckpointInterval events.
-     */
-    protected final Vector<TmfCheckpoint> fTraceIndex;
-
-    // ------------------------------------------------------------------------
-    // Construction
-    // ------------------------------------------------------------------------
-
-    /**
-     * Basic constructor that uses the default trace block size as checkpoints
-     * intervals
-     * 
-     * @param trace the trace to index
-     */
-    public TmfTraceIndexer(final ITmfTrace<ITmfEvent> trace) {
-        this(trace, TmfTrace.DEFAULT_BLOCK_SIZE);
-    }
-
-    /**
-     * Full trace indexer
-     * 
-     * @param trace the trace to index
-     * @param interval the checkpoints interval
-     */
-    public TmfTraceIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
-        fTrace = trace;
-        fCheckpointInterval = interval;
-        fTraceIndex = new Vector<TmfCheckpoint>();
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfTraceIndexer - buildIndex
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#indexTrace(boolean)
-     * 
-     * The index is a list of contexts that point to events at regular interval
-     * (rank-wise) in the trace. After it is built, the index can be used to
-     * quickly access any event by rank or timestamp (using seekIndex()).
-     * 
-     * The index is built simply by reading the trace
-     */
-    @Override
-    public void buildIndex(final boolean waitForCompletion) {
-
-        // The monitoring job
-        final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
-            @Override
-            protected IStatus run(final IProgressMonitor monitor) {
-                while (!monitor.isCanceled()) {
-                    try {
-                        Thread.sleep(100);
-                    } catch (final InterruptedException e) {
-                        return Status.OK_STATUS;
-                    }
-                }
-                monitor.done();
-                return Status.OK_STATUS;
-            }
-        };
-        job.schedule();
-
-        // Clear the checkpoints
-        fTraceIndex.clear();
-
-        // Build a background request for all the trace data. The index is
-        // updated as we go by getNextEvent().
-        final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, TmfTimeRange.ETERNITY,
-                TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
-        {
-            ITmfTimestamp startTime = null;
-            ITmfTimestamp lastTime = null;
-
-            @Override
-            public void handleData(final ITmfEvent event) {
-                super.handleData(event);
-                if (event != null) {
-                    final ITmfTimestamp timestamp = event.getTimestamp();
-                    if (startTime == null) {
-                        startTime = timestamp.clone();
-                    }
-                    lastTime = timestamp.clone();
-
-                    // Update the trace status at regular intervals
-                    if ((getNbRead() % fCheckpointInterval) == 0) {
-                        updateTraceStatus();
-                    }
-                }
-            }
-
-            @Override
-            public void handleSuccess() {
-                updateTraceStatus();
-            }
-
-            @Override
-            public void handleCompleted() {
-                job.cancel();
-                super.handleCompleted();
-            }
-
-            private void updateTraceStatus() {
-                if (getNbRead() != 0) {
-                    notifyListeners(startTime, lastTime);
-                }
-            }
-        };
-
-        // Submit the request and wait for completion if required
-        fTrace.sendRequest(request);
-        if (waitForCompletion) {
-            try {
-                request.waitForCompletion();
-            } catch (final InterruptedException e) {
-            }
-        }
-    }
-
-    private void notifyListeners(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
-        fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfTraceIndexer - updateIndex
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#updateIndex(org.eclipse.linuxtools.tmf.core.trace.ITmfContext, org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
-     */
-    @Override
-    public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
-        final long rank = context.getRank();
-        if ((rank % fCheckpointInterval) == 0) {
-            // Determine the table position
-            final long position = rank / fCheckpointInterval;
-            // Add new entry at proper location (if empty)
-            if (fTraceIndex.size() == position) {
-                final ITmfLocation<?> location = context.getLocation().clone();
-                fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), location));
-            }
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfTraceIndexer - seekIndex
-    // ------------------------------------------------------------------------
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
-     */
-    @Override
-    public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
-
-        // A null timestamp indicates to seek the first event
-        if (timestamp == null)
-            return fTrace.seekLocation(null);
-
-        // Find the checkpoint at or before the requested timestamp.
-        // In the very likely event that the timestamp is not at a checkpoint
-        // boundary, bsearch will return index = (- (insertion point + 1)).
-        // It is then trivial to compute the index of the previous checkpoint.
-        int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
-        if (index < 0) {
-            index = Math.max(0, -(index + 2));
-        }
-
-        // Position the trace at the checkpoint
-        return seekCheckpoint(index);
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(long)
-     */
-    @Override
-    public ITmfContext seekIndex(final long rank) {
-
-      // A rank <= 0 indicates to seek the first event
-      if (rank <= 0)
-          return fTrace.seekLocation(null);
-
-      // Find the checkpoint at or before the requested rank.
-      final int index = (int) rank / fCheckpointInterval;
-
-      // Position the trace at the checkpoint
-      return seekCheckpoint(index);
-    }
-
-    /**
-     * Position the trace at the given checkpoint
-     * 
-     * @param index
-     *            the checkpoint index
-     * @return the corresponding context
-     */
-    private ITmfContext seekCheckpoint(int index) {
-        ITmfLocation<?> location;
-        synchronized (fTraceIndex) {
-            if (!fTraceIndex.isEmpty()) {
-                if (index >= fTraceIndex.size()) {
-                    index = fTraceIndex.size() - 1;
-                }
-                location = fTraceIndex.elementAt(index).getLocation();
-            } else {
-                location = null;
-            }
-        }
-        final ITmfContext context = fTrace.seekLocation(location);
-        context.setRank(index * fCheckpointInterval);
-        return context;
-    }
-
-}
index f5f254677f5a4e7208a86e07425b658df212444b..8088ec2adc342bd9bf5ed9d2ffdc33289d6f60e4 100644 (file)
@@ -23,8 +23,8 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 import org.eclipse.linuxtools.tmf.ui.tests.uml2sd.trace.TmfUml2SDTestTrace;
@@ -85,6 +85,7 @@ public class Uml2SDTestFacility {
 
             fParser = new TmfUml2SDTestTrace();
             fTrace = setupTrace(fParser);
+            fParser.setTrace(fTrace);
 
             IViewPart view;
             try {
@@ -275,7 +276,11 @@ public class Uml2SDTestFacility {
      */
     @SuppressWarnings({ "rawtypes", "unchecked" })
     public void selectExperiment(final boolean wait) {
+        fParser = new TmfUml2SDTestTrace();
         fTrace = setupTrace(fParser);
+        fParser.setTrace(fTrace);
+
+//        fTrace = setupTrace(fParser);
 
         final ITmfTrace traces[] = new ITmfTrace[1];
         traces[0] = fTrace;
index d836824af2488d0760eae269d27c4298d7ef9636..bdac6e010a57302ec47c39d8f6051baf6efe441b 100644 (file)
@@ -20,23 +20,36 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
 
 public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
     
+    ITmfTrace<TmfEvent> fEventStream;
+
+    public TmfUml2SDTestTrace() {
+    }
+
+    public TmfUml2SDTestTrace(ITmfTrace<TmfEvent> eventStream) {
+        fEventStream = eventStream;
+    }
+
+    public void setTrace(ITmfTrace<TmfEvent> eventStream) {
+        fEventStream = eventStream;
+    }
+
     @Override
     @SuppressWarnings({ "unchecked", "nls" })    
-    public TmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, ITmfContext context) throws IOException {
-        if (! (eventStream instanceof TmfTraceStub)) {
+    public TmfEvent parseEvent(ITmfContext context) {
+        if (! (fEventStream instanceof TmfTraceStub)) {
             return null;
         }
 
         // Highly inefficient...
-        RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream();
+        RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
 
 //        String name = eventStream.getName();
 //        name = name.substring(name.lastIndexOf('/') + 1);
@@ -44,9 +57,10 @@ public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
         long location = 0;
         if (context != null)
             location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
-        stream.seek(location);
 
         try {
+            stream.seek(location);
+
             long ts        = stream.readLong();
             String source  = stream.readUTF();
             String type    = stream.readUTF();
@@ -72,10 +86,11 @@ public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
             fields[2] = new TmfEventField("signal", signal);
             
             ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields);
-            TmfEvent tmfEvent = new TmfEvent(eventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference);
+            TmfEvent tmfEvent = new TmfEvent(fEventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference);
 
             return tmfEvent;
-        } catch (EOFException e) {
+        } catch (final EOFException e) {
+        } catch (final IOException e) {
         }
         return null;
     }
index 11d435a96b97f015806b9bc26cbd0340d76ea34e..f1a2cc53570c58a29c5f85903aa7d80fd39d5224 100644 (file)
@@ -27,12 +27,13 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
 \r
-public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {\r
+public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEventParser<CustomTxtEvent> {\r
 \r
     private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
     private static final int DEFAULT_CACHE_SIZE = 100;\r
@@ -57,7 +58,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     }\r
 \r
     @Override\r
-    public TmfContext seekLocation(final ITmfLocation<?> location) {\r
+    public TmfContext seekEvent(final ITmfLocation<?> location) {\r
         final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK);\r
         if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile())\r
             return context;\r
@@ -103,7 +104,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     }\r
 \r
     @Override\r
-    public TmfContext seekLocation(final double ratio) {\r
+    public TmfContext seekEvent(final double ratio) {\r
         BufferedRandomAccessFile raFile = null;\r
         try {\r
             raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
@@ -116,7 +117,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
                 pos--;\r
             }\r
             final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
-            final TmfContext context = seekLocation(location);\r
+            final TmfContext context = seekEvent(location);\r
             context.setRank(ITmfContext.UNKNOWN_RANK);\r
             return context;\r
         } catch (final FileNotFoundException e) {\r
@@ -165,7 +166,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     }\r
 \r
     @Override\r
-    public synchronized TmfEvent getNextEvent(final ITmfContext context) {\r
+    public synchronized TmfEvent readEvent(final ITmfContext context) {\r
         final ITmfContext savedContext = context.clone();\r
         final TmfEvent event = parseEvent(context);\r
         if (event != null) {\r
index 707fddc7c43a88f1d050515133211f485a09a551..bc36be6d80cb11e0c85e7b306f1414f65724c07a 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
 import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
 import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
@@ -43,7 +44,7 @@ import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;\r
 import org.xml.sax.SAXParseException;\r
 \r
-public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {\r
+public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> implements ITmfEventParser<CustomXmlEvent> {\r
 \r
     private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
     private static final int DEFAULT_CACHE_SIZE = 100;\r
@@ -71,7 +72,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
     }\r
 \r
     @Override\r
-    public TmfContext seekLocation(final ITmfLocation<?> location) {\r
+    public TmfContext seekEvent(final ITmfLocation<?> location) {\r
         final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK);\r
         if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile())\r
             return context;\r
@@ -105,7 +106,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
     }\r
 \r
     @Override\r
-    public TmfContext seekLocation(final double ratio) {\r
+    public TmfContext seekEvent(final double ratio) {\r
         BufferedRandomAccessFile raFile = null;\r
         try {\r
             raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
@@ -118,7 +119,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
                 pos--;\r
             }\r
             final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
-            final TmfContext context = seekLocation(location);\r
+            final TmfContext context = seekEvent(location);\r
             context.setRank(ITmfContext.UNKNOWN_RANK);\r
             return context;\r
         } catch (final FileNotFoundException e) {\r
@@ -167,7 +168,7 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
     }\r
 \r
     @Override\r
-    public synchronized TmfEvent getNextEvent(final ITmfContext context) {\r
+    public synchronized TmfEvent readEvent(final ITmfContext context) {\r
         final ITmfContext savedContext = context.clone();\r
         final TmfEvent event = parseEvent(context);\r
         if (event != null) {\r
index e105915b0f14307cabc265888b95d53c3aa4471c..46f0b6797c868d8416ad37dfda1bd790b19ac2f4 100644 (file)
@@ -179,7 +179,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
                 }\r
                 while (true) {\r
                     long rank = context.getRank();\r
-                    ITmfEvent event = trace.getNextEvent(context);\r
+                    ITmfEvent event = trace.readEvent(context);\r
                     if (event == null) {\r
                         done = true;\r
                         break;\r
@@ -447,7 +447,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
                         if (interrupted)\r
                             return;\r
                         long rank = fContext.getRank();\r
-                        ITmfEvent event = trace.getNextEvent(fContext);\r
+                        ITmfEvent event = trace.readEvent(fContext);\r
                         if (event == null) {\r
                             break;\r
                         }\r
index 1b81dd210ee9e97a7d198dc45ab1ae0c3e127bd8..dc762813ea4d9f0fc09672c843cb7e92ff7e1b0a 100644 (file)
@@ -334,7 +334,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
     }\r
     \r
     private void setTopPosition(double ratio) {\r
-        fBottomContext = fTrace.seekLocation(ratio);\r
+        fBottomContext = fTrace.seekEvent(ratio);\r
         if (fBottomContext == null) {\r
             return;\r
         }\r
@@ -382,13 +382,13 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                 while (fTopLineIndex < 0) {\r
                     ITmfLocation<?> endLocation = fLines.get(0).location;\r
                     firstRatio = Math.max(0, firstRatio - delta);\r
-                    ITmfContext context = fTrace.seekLocation(firstRatio);\r
+                    ITmfContext context = fTrace.seekEvent(firstRatio);\r
                     ITmfLocation<?> location;\r
                     int index = 0;\r
                     long rank = 0;\r
                     while (!context.getLocation().equals(endLocation)) {\r
                         location = context.getLocation().clone();\r
-                        ITmfEvent event = fTrace.getNextEvent(context);\r
+                        ITmfEvent event = fTrace.readEvent(context);\r
                         if (event == null) {\r
                                break;\r
                         }\r
@@ -427,8 +427,8 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                        fBottomContext = fTrace.seekEvent(0);\r
                    } else {\r
                     //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1);\r
-                       fBottomContext = fTrace.seekLocation(fLines.get(fLines.size() - 1).location);\r
-                       fTrace.getNextEvent(fBottomContext);\r
+                       fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location);\r
+                       fTrace.readEvent(fBottomContext);\r
                    }\r
                    if (fBottomContext == null) {\r
                        break;\r
@@ -436,7 +436,7 @@ public class TmfRawEventViewer extends Composite implements ControlListener, Sel
                }\r
             long rank = fBottomContext.getRank();\r
             ITmfLocation<?> location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;\r
-            ITmfEvent event = fTrace.getNextEvent(fBottomContext);\r
+            ITmfEvent event = fTrace.readEvent(fBottomContext);\r
             if (event == null) {\r
                 break;\r
             }\r
This page took 0.101514 seconds and 5 git commands to generate.