Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix null pointer exception during preview #74

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
Expand Down Expand Up @@ -692,7 +691,6 @@ public List<ThresholdingResult> getPreviewResults(double[][] dataPoints) {
throw new IllegalArgumentException("Insufficient data for preview results. Minimum required: " + minPreviewSize);
}
// Train RCF models and collect non-zero scores
Random random = new Random();
int rcfNumFeatures = dataPoints[0].length;
RandomCutForest forest = RandomCutForest
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,20 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
XContentBuilder xContentBuilder = builder
.startObject()
.field(DETECTOR_ID_FIELD, detectorId)
.field(FEATURE_DATA_FIELD, featureData.toArray())
.field(DATA_START_TIME_FIELD, dataStartTime.toEpochMilli())
.field(DATA_END_TIME_FIELD, dataEndTime.toEpochMilli())
.field(EXECUTION_START_TIME_FIELD, executionStartTime.toEpochMilli())
.field(EXECUTION_END_TIME_FIELD, executionEndTime.toEpochMilli());
.field(DATA_END_TIME_FIELD, dataEndTime.toEpochMilli());
if (featureData != null) {
// can be null during preview
xContentBuilder.field(FEATURE_DATA_FIELD, featureData.toArray());
}
if (executionStartTime != null) {
// can be null during preview
xContentBuilder.field(EXECUTION_START_TIME_FIELD, executionStartTime.toEpochMilli());
}
if (executionEndTime != null) {
// can be null during preview
xContentBuilder.field(EXECUTION_END_TIME_FIELD, executionEndTime.toEpochMilli());
}
if (anomalyScore != null && !anomalyScore.isNaN()) {
xContentBuilder.field(ANOMALY_SCORE_FIELD, anomalyScore);
}
Expand Down