Ruoyingw commented on a change in pull request #5869:
URL: https://github.com/apache/incubator-pinot/pull/5869#discussion_r471787378



##########
File path: 
thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/anomaly/views/TestCondensedAnomalyTimelinesView.java
##########
@@ -73,35 +74,46 @@ public void testFromJsonString() throws Exception{
     }
   }
 
+  /** Compression Test case 1: anomaly view could satisfy requirement after 
rounding up the decimals.*/
+  @Test
+  public void testCompressWithRoundUp() throws Exception {
+    int testNum = 500;
+    CondensedAnomalyTimelinesView condensedView = 
CondensedAnomalyTimelinesView.fromAnomalyTimelinesView(getTestData(testNum));
+    Assert.assertTrue(condensedView.toJsonString().length() > 
CondensedAnomalyTimelinesView.DEFAULT_MAX_LENGTH);
+    CondensedAnomalyTimelinesView compressedView = condensedView.compress();
+    Assert.assertTrue(compressedView.toJsonString().length() < 
CondensedAnomalyTimelinesView.DEFAULT_MAX_LENGTH);
+    Assert.assertEquals(testNum, compressedView.timeStamps.size());
+  }
+
+  /** Compression Test case 2:  The anomaly view is still too large after 
rounding up, and needed to be further compressed */
   @Test
   public void testCompress() throws Exception {
-    int testNum = 1500;
+    int testNum = 600;
     long minBucketMillis = 
CondensedAnomalyTimelinesView.DEFAULT_MIN_BUCKET_UNIT;
     CondensedAnomalyTimelinesView condensedView = 
CondensedAnomalyTimelinesView.fromAnomalyTimelinesView(getTestData(testNum));
     Assert.assertTrue(condensedView.toJsonString().length() > 
CondensedAnomalyTimelinesView.DEFAULT_MAX_LENGTH);
-
     CondensedAnomalyTimelinesView compressedView = condensedView.compress();
     Assert.assertTrue(compressedView.toJsonString().length() < 
CondensedAnomalyTimelinesView.DEFAULT_MAX_LENGTH);
-    Assert.assertEquals(compressedView.bucketMillis.longValue(), 240l);
+    Assert.assertEquals(300, compressedView.timeStamps.size());
+    Assert.assertEquals(compressedView.bucketMillis.longValue(), 10);
     DateTime date = new DateTime(2018, 1, 1, 0, 0, 0);
     for (int i = 0; i < compressedView.getTimeStamps().size(); i++) {
       Assert.assertEquals(compressedView.getTimeStamps().get(i).longValue(),
           (date.getMillis() - condensedView.timestampOffset)/minBucketMillis);
-      Assert.assertEquals(compressedView.getCurrentValues().get(i), i * 4 + 
1.5, 0.000001);
-      Assert.assertEquals(compressedView.getBaselineValues().get(i), i * 4 + 
1.6, 0.000001);
-      date = date.plusHours(4);
+      Assert.assertEquals(compressedView.getCurrentValues().get(i), i * 2 + 
0.5, 0.000001);
+      Assert.assertEquals(compressedView.getBaselineValues().get(i), i * 2 + 
0.833, 0.000001);

Review comment:
       right I should do that. 




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to