Skip to content

Commit 2c6a6f1

Browse files
author
Peter Alfonsi
committed
switch block order
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
1 parent da54be2 commit 2c6a6f1

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

server/src/main/java/org/opensearch/search/aggregations/metrics/TDigestState.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,19 @@ public static TDigestState read(StreamInput in) throws IOException {
9090
if (in.getVersion().before(Version.V_3_4_0)) {
9191
// In older versions TDigestState was based on AVLTreeDigest. Load centroids into this class, then add it to MergingDigest.
9292
double compression = in.readDouble();
93-
AVLTreeDigest treeDigest = new AVLTreeDigest(compression);
93+
9494
int n = in.readVInt();
95-
if (n > 0) {
96-
for (int i = 0; i < n; i++) {
97-
treeDigest.add(in.readDouble(), in.readVInt());
98-
}
99-
TDigestState state = new TDigestState(compression);
100-
state.add(List.of(treeDigest));
101-
return state;
95+
if (n <= 0) {
96+
return new TDigestState(compression);
10297
}
103-
return new TDigestState(compression);
98+
AVLTreeDigest treeDigest = new AVLTreeDigest(compression);
99+
for (int i = 0; i < n; i++) {
100+
treeDigest.add(in.readDouble(), in.readVInt());
101+
}
102+
TDigestState state = new TDigestState(compression);
103+
state.add(List.of(treeDigest));
104+
return state;
105+
104106
} else {
105107
// For MergingDigest, adding the original centroids in ascending order to a new, empty MergingDigest isn't guaranteed
106108
// to produce a MergingDigest whose centroids are exactly equal to the originals.

0 commit comments

Comments
 (0)