ctf: fix output writer segment intersection algorithm
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 31 Jul 2015 23:48:02 +0000 (19:48 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 16 Sep 2015 21:11:37 +0000 (17:11 -0400)
commit229d7d5a9788a168cf4ee60bd40e43121205a184
tree8e653256cf5207d20055e30db267597edc9adb59
parent90cefe9ffd51c476e75ba55bc6805830c68e5ff3
ctf: fix output writer segment intersection algorithm

Let's say you have two segments, A and B, they have the points
A0, A1, B0, B1. to see if there is intersection between the two
segments in one dimension, here are the exhaustive possibilities.

     A----A
B--B              1
   B--B           2
      B--B        3
         B--B     4
            B--B  5
  B----------B    6

we need to only reject 1 and 5

In 1, B0 && B1 < A0
In 5, B0 && B1 > A1

Now B0 < B1 so we can simplify to
B1 < A0 || B0 > A1
Applying demorgan we get
!(B1 >= A0 && B0 <= A1)
If B is the entry, B0 = entry.timestampStart() and B1 = entry.timestampEnd()

The intersection is the not(!) of the formula above.
entry.timestampEnd >= startTime && entry.timestampStart <= endTime

The patch changes the intersection algorith to that.

Change-Id: Ie3205a3c7da970daf94c0cb93cb336fe0851f039
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/53001
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceWriterTest.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamOutputWriter.java
This page took 0.027751 seconds and 5 git commands to generate.