You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pinot.apache.org by GitBox <gi...@apache.org> on 2018/11/28 01:57:52 UTC

[GitHub] apucher closed pull request #3562: [TE] detection - copy nested property in wrapper

apucher closed pull request #3562: [TE] detection - copy nested property in wrapper
URL: https://github.com/apache/incubator-pinot/pull/3562
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionMigrationResource.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionMigrationResource.java
index c3d08d1ae4..3b15748f40 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionMigrationResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionMigrationResource.java
@@ -99,7 +99,7 @@ public String migrateToYaml(@QueryParam("id") long anomalyFunctionId) throws Exc
     yamlConfigs.put("metric", anomalyFunctionDTO.getMetric());
     yamlConfigs.put("dataset", anomalyFunctionDTO.getCollection());
     yamlConfigs.put("pipelineType", "Composite");
-    if (anomalyFunctionDTO.getExploreDimensions() != null) {
+    if (StringUtils.isNotBlank(anomalyFunctionDTO.getExploreDimensions())) {
       // dimension explore and data filter
       yamlConfigs.put("dimensionExploration",
           getDimensionExplorationParams(anomalyFunctionDTO));
@@ -180,7 +180,10 @@ public String migrateToYaml(@QueryParam("id") long anomalyFunctionId) throws Exc
     filterYamlParams.put("pattern", "up_or_down");
     filterYamlParams.put("sitewideMetricName", functionDTO.getGlobalMetric());
     filterYamlParams.put("sitewideCollection", functionDTO.getCollection());
-    filterYamlParams.put("filters", AnomalyDetectionInputContextBuilder.getFiltersForFunction(functionDTO.getGlobalMetricFilters()).asMap());
+    if (StringUtils.isNotBlank(functionDTO.getGlobalMetricFilters())) {
+      filterYamlParams.put("filters",
+          AnomalyDetectionInputContextBuilder.getFiltersForFunction(functionDTO.getGlobalMetricFilters()).asMap());
+    }
     return filterYamlParams;
   }
 
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/algorithm/MergeWrapper.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/algorithm/MergeWrapper.java
index 3f8b0de590..144bf5ff1a 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/algorithm/MergeWrapper.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/algorithm/MergeWrapper.java
@@ -80,7 +80,11 @@ public MergeWrapper(DataProvider provider, DetectionConfigDTO config, long start
     this.maxGap = MapUtils.getLongValue(config.getProperties(), "maxGap", 0);
     this.maxDuration = MapUtils.getLongValue(config.getProperties(), "maxDuration", Long.MAX_VALUE);
     this.slice = new AnomalySlice().withStart(startTime).withEnd(endTime);
-    this.nestedProperties = ConfigUtils.getList(config.getProperties().get(PROP_NESTED));
+    this.nestedProperties = new ArrayList<>();
+    List<Map<String, Object>> nested = ConfigUtils.getList(config.getProperties().get(PROP_NESTED));
+    for (Map<String, Object> properties : nested) {
+      this.nestedProperties.add(new HashMap<>(properties));
+    }
   }
 
   @Override
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/wrapper/AnomalyFilterWrapper.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/wrapper/AnomalyFilterWrapper.java
index dba5f8058b..429b537e48 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/wrapper/AnomalyFilterWrapper.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/wrapper/AnomalyFilterWrapper.java
@@ -28,6 +28,7 @@
 import com.linkedin.thirdeye.detection.spi.components.AnomalyFilter;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.collections.MapUtils;
@@ -46,8 +47,7 @@
   private final AnomalyFilter anomalyFilter;
   private String metricUrn;
 
-  public AnomalyFilterWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime)
-      throws Exception {
+  public AnomalyFilterWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
     super(provider, config, startTime, endTime);
     Map<String, Object> properties = config.getProperties();
     this.nestedProperties = ConfigUtils.getList(properties.get(PROP_NESTED));
@@ -72,13 +72,14 @@ public final DetectionPipelineResult run() throws Exception {
       DetectionConfigDTO nestedConfig = new DetectionConfigDTO();
 
       Preconditions.checkArgument(properties.containsKey(PROP_CLASS_NAME), "Nested missing " + PROP_CLASS_NAME);
+      HashMap<String, Object> nestedProp = new HashMap<>(properties);
+      if (this.metricUrn != null){
+        nestedProp.put(PROP_METRIC_URN, this.metricUrn);
+      }
       nestedConfig.setId(this.config.getId());
       nestedConfig.setName(this.config.getName());
-      nestedConfig.setProperties(properties);
+      nestedConfig.setProperties(nestedProp);
       nestedConfig.setComponents(this.config.getComponents());
-      if (this.metricUrn != null){
-        properties.put(PROP_METRIC_URN, this.metricUrn);
-      }
       DetectionPipeline pipeline = this.provider.loadPipeline(nestedConfig, this.startTime, this.endTime);
 
       DetectionPipelineResult intermediate = pipeline.run();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pinot.apache.org
For additional commands, e-mail: dev-help@pinot.apache.org