suneet-s commented on a change in pull request #9441: Improve 
OvershadowableManager performance
URL: https://github.com/apache/druid/pull/9441#discussion_r390011128
 
 

 ##########
 File path: 
core/src/test/java/org/apache/druid/timeline/partition/OvershadowableManagerTest.java
 ##########
 @@ -63,6 +64,57 @@ public void setup()
     expectedStandbyChunks = new ArrayList<>();
   }
 
+  @Test
+  public void testCopyVisible()
+  {
+    // chunks of partition id 0 and 1
+    manager.addChunk(newRootChunk());
+    manager.addChunk(newRootChunk());
+
+    // chunks to overshadow the partition id range [0, 2)
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+
+    // chunks of partition id 3 and 4
+    manager.addChunk(newRootChunk());
+    manager.addChunk(newRootChunk());
+
+    // standby chunk
+    manager.addChunk(newNonRootChunk(2, 4, 1, 3));
+
+    OvershadowableManager<OvershadowableInteger> copy = 
OvershadowableManager.copyVisible(manager);
+    Assert.assertTrue(copy.getOvershadowedChunks().isEmpty());
+    Assert.assertTrue(copy.getStandbyChunks().isEmpty());
+    Assert.assertEquals(
+        Lists.newArrayList(manager.visibleChunksIterator()),
+        Lists.newArrayList(copy.visibleChunksIterator())
+    );
+  }
+
+  @Test
+  public void testDeepCopy()
+  {
+    // chunks of partition id 0 and 1
+    manager.addChunk(newRootChunk());
+    manager.addChunk(newRootChunk());
+
+    // chunks to overshadow the partition id range [0, 2)
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+    manager.addChunk(newNonRootChunk(0, 2, 1, 3));
+
+    // chunks of partition id 3 and 4
+    manager.addChunk(newRootChunk());
+    manager.addChunk(newRootChunk());
+
+    // standby chunk
+    manager.addChunk(newNonRootChunk(2, 4, 1, 3));
+
+    OvershadowableManager<OvershadowableInteger> copy = 
OvershadowableManager.deepCopy(manager);
+    Assert.assertEquals(manager, copy);
+  }
+
 
 Review comment:
   Thanks for the tests! One last ask, since this depends on equals to be 
implemented correctly, I think we need another test for equals
   
   
   ```suggestion
   
     @Test
     public void testEqualAndHashCodeContract()
     {
       
EqualsVerifier.forClass(OvershadowableManager.class).usingGetClass().verify();
     }
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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