niketh closed pull request #6000: Fix versioned interval timeline to add same 
version data
URL: https://github.com/apache/incubator-druid/pull/6000
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java 
b/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java
index 4bbafe7884b..85db1b22d7a 100644
--- a/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java
+++ b/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java
@@ -57,6 +57,12 @@ public PartitionHolder(PartitionHolder partitionHolder)
 
   public void add(PartitionChunk<T> chunk)
   {
+    // Treeset will ignore add if it already contains the chunk.
+    // Removing and readding will ensure that it adds the latest chunk
+    if (holderSet.contains(chunk)) {
+      holderSet.remove(chunk);
+    }
+
     holderSet.add(chunk);
   }
 
diff --git 
a/common/src/test/java/io/druid/timeline/VersionedIntervalTimelineTest.java 
b/common/src/test/java/io/druid/timeline/VersionedIntervalTimelineTest.java
index 0c5003242fc..bbdc6d435a4 100644
--- a/common/src/test/java/io/druid/timeline/VersionedIntervalTimelineTest.java
+++ b/common/src/test/java/io/druid/timeline/VersionedIntervalTimelineTest.java
@@ -63,6 +63,7 @@ public void setUp()
     add("2011-04-01/2011-04-09", "2", 1);
     add("2011-04-06/2011-04-09", "3", 4);
     add("2011-04-01/2011-04-02", "3", 5);
+    add("2011-04-06/2011-04-09", "3", 100);
 
     add("2011-05-01/2011-05-02", "1", 6);
     add("2011-05-01/2011-05-05", "2", 7);
@@ -84,7 +85,7 @@ public void testApril()
         Arrays.asList(
             createExpected("2011-04-01/2011-04-02", "3", 5),
             createExpected("2011-04-02/2011-04-06", "2", 1),
-            createExpected("2011-04-06/2011-04-09", "3", 4)
+            createExpected("2011-04-06/2011-04-09", "3", 100)
         ),
         timeline.lookup(Intervals.of("2011-04-01/2011-04-09"))
     );
@@ -102,7 +103,7 @@ public void testApril2()
             createExpected("2011-04-01/2011-04-02", "3", 5),
             createExpected("2011-04-02/2011-04-03", "1", 2),
             createExpected("2011-04-03/2011-04-06", "1", 3),
-            createExpected("2011-04-06/2011-04-09", "3", 4)
+            createExpected("2011-04-06/2011-04-09", "3", 100)
         ),
         timeline.lookup(Intervals.of("2011-04-01/2011-04-09"))
     );
@@ -123,7 +124,7 @@ public void testApril3()
         Arrays.asList(
             createExpected("2011-04-01/2011-04-02", "3", 5),
             createExpected("2011-04-03/2011-04-06", "1", 3),
-            createExpected("2011-04-06/2011-04-09", "3", 4)
+            createExpected("2011-04-06/2011-04-09", "3", 100)
         ),
         timeline.lookup(Intervals.of("2011-04-01/2011-04-09"))
     );
@@ -443,7 +444,7 @@ public void testOverlapSameVersionIsOkay()
 
     assertValues(
         Collections.singletonList(
-            createExpected("2011-01-01/2011-01-10", "2", 2)
+            createExpected("2011-01-01/2011-01-10", "2", 3)
         ),
         timeline.lookup(Intervals.of("2011-01-01/2011-01-10"))
     );
@@ -560,8 +561,8 @@ public void testOverlapSecondAfter()
 
     assertValues(
         Arrays.asList(
-            createExpected("2011-01-01/2011-01-10", "2", 1),
-            createExpected("2011-01-10/2011-01-15", "1", 3)
+            createExpected("2011-01-01/2011-01-10", "2", 3),
+            createExpected("2011-01-10/2011-01-15", "1", 1)
         ),
         timeline.lookup(Intervals.of("2011-01-01/2011-01-15"))
     );
@@ -930,7 +931,7 @@ public void testOverlapV1Large()
             createExpected("2011-01-01/2011-01-03", "1", 1),
             createExpected("2011-01-03/2011-01-05", "2", 2),
             createExpected("2011-01-05/2011-01-13", "1", 1),
-            createExpected("2011-01-13/2011-01-20", "2", 2)
+            createExpected("2011-01-13/2011-01-20", "2", 3)
         ),
         timeline.lookup(Intervals.of("2011-01-01/2011-01-20"))
     );
@@ -949,8 +950,8 @@ public void testOverlapV2Large()
 
     assertValues(
         Arrays.asList(
-            createExpected("2011-01-01/2011-01-15", "2", 2),
-            createExpected("2011-01-15/2011-01-20", "1", 1)
+            createExpected("2011-01-01/2011-01-15", "2", 1),
+            createExpected("2011-01-15/2011-01-20", "1", 3)
         ),
         timeline.lookup(Intervals.of("2011-01-01/2011-01-20"))
     );
@@ -1775,7 +1776,7 @@ private void assertValues(
 
       Assert.assertEquals(pair.lhs, holder.getInterval());
       Assert.assertEquals(pair.rhs.lhs, holder.getVersion());
-      Assert.assertEquals(pair.rhs.rhs, holder.getObject());
+      Assert.assertEquals(pair.rhs.rhs.toString(), 
holder.getObject().toString());
     }
   }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to