akshayrai commented on a change in pull request #4894: [TE] Prefetch based on
data granularity in dimension exploration jobs
URL: https://github.com/apache/incubator-pinot/pull/4894#discussion_r355281094
##########
File path:
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/algorithm/DimensionWrapper.java
##########
@@ -249,8 +256,22 @@ public DetectionPipelineResult run() throws Exception {
// don't use in-memory cache for dimension exploration, it will cause
thrashing
// we add a "duplicate" condition so that tests can run. will fix tests
later on
if (CacheConfig.getInstance().useCentralizedCache() &&
!CacheConfig.getInstance().useInMemoryCache()) {
- if (this.cachingPeriodLookback >= 0) {
- this.provider.fetchTimeseries(nestedMetrics.stream()
+ Map<Long, MetricConfigDTO> metricConfigs =
+
this.provider.fetchMetrics(nestedMetrics.stream().map(MetricEntity::getId).collect(Collectors.toSet()));
+ Map<String, DatasetConfigDTO> datasets = this.provider.fetchDatasets(
+
metricConfigs.values().stream().map(MetricConfigBean::getDataset).collect(Collectors.toSet()));
+ // group the metric entities by dataset
+ Map<DatasetConfigDTO, List<MetricEntity>> nestedMetricsByDataset =
nestedMetrics.stream()
+ .collect(Collectors.groupingBy(metric ->
datasets.get(metricConfigs.get(metric.getId()).getDataset()),
+ Collectors.toList()));
+
+ // prefetch each
+ for (Map.Entry<DatasetConfigDTO, List<MetricEntity>> entry :
nestedMetricsByDataset.entrySet()) {
+ long cachingPeriodLookback =
config.getProperties().containsKey(PROP_CACHE_PERIOD_LOOKBACK) ?
MapUtils.getLong(config.getProperties(),
Review comment:
Rather than checking for the key in the properties over and over again, why
not fetch it once and then just check if cachingPeriodLookback is set or not.
something like,
```
long cachingPeriodLookback =
config.getProperties().containsKey(PROP_CACHE_PERIOD_LOOKBACK) ?
MapUtils.getLong(config.getProperties(), PROP_CACHE_PERIOD_LOOKBACK) :
DEFAULT_CACHING_PERIOD_LOOKBACK;
for (...) {
long metricCacheLookback = cachingPeriodLookback;
if (metricCacheLookback < 0) {
metricCacheLookback =
getCachingPeriodLookback(entry.getKey().bucketTimeGranularity());
}
...
}
```
----------------------------------------------------------------
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]