[TE] filter out anomalies in the future
Prevent detector generating anomalies in the future. Ensure the current value won't be NaN.
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.apache.pinot.thirdeye.anomaly.detection.DetectionJobSchedulerUtils;
import org.apache.pinot.thirdeye.common.time.TimeGranularity;
@@ -188,7 +189,9 @@ public class AnomalyDetectorWrapper extends DetectionPipeline {
anomaly.setDimensions(DetectionUtils.toFilterMap(this.metricEntity.getFilters()));
anomaly.getProperties().put(PROP_DETECTOR_COMPONENT_NAME, this.detectorName);
}
- return new DetectionPipelineResult(anomalies, this.getLastTimeStamp());
+ long lastTimeStamp = this.getLastTimeStamp();
+ return new DetectionPipelineResult(anomalies.stream().filter(anomaly -> anomaly.getEndTime() <= lastTimeStamp).collect(
+ Collectors.toList()), lastTimeStamp);
}
// guess-timate next time stamp
