akshayrai commented on a change in pull request #4900: [TE][detection] 
Implement anomalies cache to speed up detection
URL: https://github.com/apache/incubator-pinot/pull/4900#discussion_r359171746
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/algorithm/DimensionWrapper.java
 ##########
 @@ -308,6 +314,33 @@ public DetectionPipelineResult run() throws Exception {
         predictionResults, 
calculateEvaluationMetrics(predictionResults)).setDiagnostics(diagnostics);
   }
 
+  private DatasetConfigDTO retrieveDatasetConfig(List<MetricEntity> 
nestedMetrics) {
+    // All nested metrics after dimension explore belong to the same dataset
+    long metricId = nestedMetrics.get(0).getId();
+    MetricConfigDTO metricConfigDTO = 
this.provider.fetchMetrics(Collections.singletonList(metricId)).get(metricId);
+
+    return 
this.provider.fetchDatasets(Collections.singletonList(metricConfigDTO.getDataset()))
+        .get(metricConfigDTO.getDataset());
+  }
+
+  private void warmUpAnomaliesCache(List<MetricEntity> nestedMetrics) {
+    DatasetConfigDTO dataset = retrieveDatasetConfig(nestedMetrics);
+    long cachingPeriodLookback = 
config.getProperties().containsKey(PROP_CACHE_PERIOD_LOOKBACK) ?
+        MapUtils.getLong(config.getProperties(), PROP_CACHE_PERIOD_LOOKBACK) : 
ThirdEyeUtils
+        .getCachingPeriodLookback(dataset.bucketTimeGranularity());
+
+    long paddingBuffer = TimeUnit.DAYS.toMillis(1); // 100000
+    AnomalySlice anomalySlice = new AnomalySlice()
+        .withDetectionId(this.config.getId())
+        .withStart(startTime - cachingPeriodLookback - paddingBuffer)
+        .withEnd(endTime + paddingBuffer);
+    //.withFilters(this.metricEntity.getFilters())
+    //.withDetectionCompNames(Collections.singletonList(this.detectorName));
 
 Review comment:
   The idea is that running a specific detection will require all its past 
anomalies irrespective of filters or detection component names. So we fetch it 
once and cache it. The dimension exploration, for example, will then filter the 
relevant anomalies from this cache.

----------------------------------------------------------------
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