You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xh...@apache.org on 2019/06/26 20:51:53 UTC
[incubator-pinot] branch master updated: [TE] set detection window
based on detection granularity (#4352)
This is an automated email from the ASF dual-hosted git repository.
xhsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 49902ae [TE] set detection window based on detection granularity (#4352)
49902ae is described below
commit 49902ae309a7deb79aa788b6f0c6a532975cbea5
Author: Xiaohui Sun <xh...@linkedin.com>
AuthorDate: Wed Jun 26 13:51:48 2019 -0700
[TE] set detection window based on detection granularity (#4352)
---
.../yaml/translator/DetectionConfigTranslator.java | 64 +++++++++++++---------
1 file changed, 38 insertions(+), 26 deletions(-)
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
index ab29b4a..142cc7f 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
@@ -21,6 +21,7 @@ package org.apache.pinot.thirdeye.detection.yaml.translator;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
+import java.time.Period;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -375,31 +376,18 @@ public class DetectionConfigTranslator extends ConfigTranslator<DetectionConfigD
// fill in window size and unit if detector requires this
private void fillInDetectorWrapperProperties(Map<String, Object> properties, Map<String, Object> yamlConfig, String detectorType, TimeGranularity datasetTimegranularity) {
- if (MOVING_WINDOW_DETECTOR_TYPES.contains(detectorType)) {
- properties.put(PROP_MOVING_WINDOW_DETECTION, true);
- switch (datasetTimegranularity.getUnit()) {
- case MINUTES:
- properties.put(PROP_WINDOW_SIZE, 6);
- properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
- properties.put(PROP_FREQUENCY, new TimeGranularity(15, TimeUnit.MINUTES));
- break;
- case HOURS:
- properties.put(PROP_WINDOW_SIZE, 24);
- properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
- break;
- case DAYS:
- properties.put(PROP_WINDOW_SIZE, 1);
- properties.put(PROP_WINDOW_UNIT, TimeUnit.DAYS);
- // TODO completeness checker true
- break;
- default:
- properties.put(PROP_WINDOW_SIZE, 6);
- properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
- }
- }
// set default bucketPeriod
properties.put(PROP_BUCKET_PERIOD, datasetTimegranularity.toPeriod().toString());
- // override from yaml
+
+ // override bucketPeriod now since it is needed by detection window
+ if (yamlConfig.containsKey(PROP_BUCKET_PERIOD)){
+ properties.put(PROP_BUCKET_PERIOD, MapUtils.getString(yamlConfig, PROP_BUCKET_PERIOD));
+ }
+
+ // set default detection window
+ setDefaultDetectionWindow(properties, detectorType);
+
+ // override other properties from yaml
if (yamlConfig.containsKey(PROP_WINDOW_SIZE)) {
properties.put(PROP_MOVING_WINDOW_DETECTION, true);
properties.put(PROP_WINDOW_SIZE, MapUtils.getString(yamlConfig, PROP_WINDOW_SIZE));
@@ -417,14 +405,38 @@ public class DetectionConfigTranslator extends ConfigTranslator<DetectionConfigD
if (yamlConfig.containsKey(PROP_TIMEZONE)){
properties.put(PROP_TIMEZONE, MapUtils.getString(yamlConfig, PROP_TIMEZONE));
}
- if (yamlConfig.containsKey(PROP_BUCKET_PERIOD)){
- properties.put(PROP_BUCKET_PERIOD, MapUtils.getString(yamlConfig, PROP_BUCKET_PERIOD));
- }
if (yamlConfig.containsKey(PROP_CACHE_PERIOD_LOOKBACK)) {
properties.put(PROP_CACHE_PERIOD_LOOKBACK, MapUtils.getString(yamlConfig, PROP_CACHE_PERIOD_LOOKBACK));
}
}
+ // Set the default detection window if it is not specified.
+ // Here instead of using data granularity we use the detection period to set the default window size.
+ private void setDefaultDetectionWindow(Map<String, Object> properties, String detectorType) {
+ if (MOVING_WINDOW_DETECTOR_TYPES.contains(detectorType)) {
+ properties.put(PROP_MOVING_WINDOW_DETECTION, true);
+ org.joda.time.Period detectionPeriod =
+ org.joda.time.Period.parse(MapUtils.getString(properties, PROP_BUCKET_PERIOD));
+ int days = detectionPeriod.toStandardDays().getDays();
+ int hours = detectionPeriod.toStandardHours().getHours();
+ int minutes = detectionPeriod.toStandardMinutes().getMinutes();
+ if (days >= 1) {
+ properties.put(PROP_WINDOW_SIZE, 1);
+ properties.put(PROP_WINDOW_UNIT, TimeUnit.DAYS);
+ } else if (hours >= 1) {
+ properties.put(PROP_WINDOW_SIZE, 24);
+ properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
+ } else if (minutes >= 1) {
+ properties.put(PROP_WINDOW_SIZE, 6);
+ properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
+ properties.put(PROP_FREQUENCY, new TimeGranularity(15, TimeUnit.MINUTES));
+ } else {
+ properties.put(PROP_WINDOW_SIZE, 6);
+ properties.put(PROP_WINDOW_UNIT, TimeUnit.HOURS);
+ }
+ }
+ }
+
private List<Map<String, Object>> buildFilterWrapperProperties(String wrapperClassName,
Map<String, Object> yamlConfig, List<Map<String, Object>> nestedProperties) {
if (yamlConfig == null || yamlConfig.isEmpty()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org