Skip to content

Commit 05b411d

Browse files
committed
More review fixes
1 parent a088431 commit 05b411d

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

x-pack/plugin/mapper-exponential-histogram/src/main/java/org/elasticsearch/xpack/exponentialhistogram/ExponentialHistogramFieldMapper.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,14 @@ private Double validateOrEstimateSum(
443443
IndexWithCount.asBuckets(scale, negativeBuckets).iterator(),
444444
IndexWithCount.asBuckets(scale, positiveBuckets).iterator()
445445
);
446-
} else {
447-
if (totalValueCount == 0 && sum != 0.0) {
448-
throw new DocumentParsingException(
449-
subParser.getTokenLocation(),
450-
"error parsing field [" + fullPath() + "], sum field must be zero if the histogram is empty, but got " + sum
451-
);
452-
}
453-
return sum;
454446
}
447+
if (totalValueCount == 0 && sum != 0.0) {
448+
throw new DocumentParsingException(
449+
subParser.getTokenLocation(),
450+
"error parsing field [" + fullPath() + "], sum field must be zero if the histogram is empty, but got " + sum
451+
);
452+
}
453+
return sum;
455454
}
456455

457456
private Double validateOrEstimateMin(
@@ -470,15 +469,14 @@ private Double validateOrEstimateMin(
470469
IndexWithCount.asBuckets(scale, positiveBuckets)
471470
);
472471
return estimatedMin.isPresent() ? estimatedMin.getAsDouble() : null;
473-
} else {
474-
if (totalValueCount == 0) {
475-
throw new DocumentParsingException(
476-
subParser.getTokenLocation(),
477-
"error parsing field [" + fullPath() + "], min field must be null if the histogram is empty, but got " + parsedMin
478-
);
479-
}
480-
return parsedMin;
481472
}
473+
if (totalValueCount == 0) {
474+
throw new DocumentParsingException(
475+
subParser.getTokenLocation(),
476+
"error parsing field [" + fullPath() + "], min field must be null if the histogram is empty, but got " + parsedMin
477+
);
478+
}
479+
return parsedMin;
482480
}
483481

484482
private Double validateOrEstimateMax(
@@ -497,15 +495,14 @@ private Double validateOrEstimateMax(
497495
IndexWithCount.asBuckets(scale, positiveBuckets)
498496
);
499497
return estimatedMax.isPresent() ? estimatedMax.getAsDouble() : null;
500-
} else {
501-
if (totalValueCount == 0) {
502-
throw new DocumentParsingException(
503-
subParser.getTokenLocation(),
504-
"error parsing field [" + fullPath() + "], max field must be null if the histogram is empty, but got " + parsedMax
505-
);
506-
}
507-
return parsedMax;
508498
}
499+
if (totalValueCount == 0) {
500+
throw new DocumentParsingException(
501+
subParser.getTokenLocation(),
502+
"error parsing field [" + fullPath() + "], max field must be null if the histogram is empty, but got " + parsedMax
503+
);
504+
}
505+
return parsedMax;
509506
}
510507

511508
private double parseDoubleAllowingInfinity(XContentParser parser) throws IOException {

0 commit comments

Comments
 (0)