Skip to content

Commit 777eced

Browse files
[CI] Auto commit changes from spotless
1 parent 73b779d commit 777eced

File tree

6 files changed

+89
-79
lines changed

6 files changed

+89
-79
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/ChangePointOperator.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public class ChangePointOperator implements Operator {
3838

3939
public static final int INPUT_VALUE_COUNT_LIMIT = 1000;
4040

41-
public record Factory(int metricChannel, List<Integer> partitionChannel, String sourceText, int sourceLine, int sourceColumn) implements OperatorFactory {
41+
public record Factory(int metricChannel, List<Integer> partitionChannel, String sourceText, int sourceLine, int sourceColumn)
42+
implements
43+
OperatorFactory {
4244
@Override
4345
public Operator get(DriverContext driverContext) {
4446
return new ChangePointOperator(driverContext, metricChannel, partitionChannel, sourceText, sourceLine, sourceColumn);
@@ -64,7 +66,14 @@ public String describe() {
6466

6567
// TODO: make org.elasticsearch.xpack.esql.core.tree.Source available here
6668
// (by modularizing esql-core) and use that instead of the individual fields.
67-
public ChangePointOperator(DriverContext driverContext, int metricChannel, List<Integer> partitionChannel, String sourceText, int sourceLine, int sourceColumn) {
69+
public ChangePointOperator(
70+
DriverContext driverContext,
71+
int metricChannel,
72+
List<Integer> partitionChannel,
73+
String sourceText,
74+
int sourceLine,
75+
int sourceColumn
76+
) {
6877
this.driverContext = driverContext;
6978
this.metricChannel = metricChannel;
7079
this.partitionChannel = partitionChannel;
@@ -128,7 +137,6 @@ private void createOutputPages() {
128137
}
129138
boolean tooManyValues = maxValuesCount > INPUT_VALUE_COUNT_LIMIT;
130139

131-
132140
List<MlAggsHelper.DoubleBucketValues> bucketValuesPerPartition = new ArrayList<>();
133141
boolean hasNulls = false;
134142
boolean hasMultivalued = false;
@@ -168,14 +176,14 @@ private void createOutputPages() {
168176
}
169177
}
170178
// Handle last partition separately
171-
// if (lastPartitionFieldValue != null) {
179+
// if (lastPartitionFieldValue != null) {
172180
MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues(
173181
null,
174182
values.stream().mapToDouble(Double::doubleValue).toArray(),
175183
bucketIndexes.stream().mapToInt(Integer::intValue).toArray()
176184
);
177185
bucketValuesPerPartition.add(bucketValues);
178-
// }
186+
// }
179187
}
180188

181189
List<ChangeType> changeTypes = new ArrayList<>();
@@ -237,7 +245,9 @@ private void insertChangePoints(Iterable<ChangeType> changeTypes) {
237245

238246
try {
239247
// TODO: How to handle case when there are no change points
240-
if (changeType != null && pageStartIndex <= changeType.changePoint() && changeType.changePoint() < pageStartIndex + inputPage.getPositionCount()) {
248+
if (changeType != null
249+
&& pageStartIndex <= changeType.changePoint()
250+
&& changeType.changePoint() < pageStartIndex + inputPage.getPositionCount()) {
241251
try (
242252
BytesRefBlock.Builder changeTypeBlockBuilder = blockFactory.newBytesRefBlockBuilder(inputPage.getPositionCount());
243253
DoubleBlock.Builder pvalueBlockBuilder = blockFactory.newDoubleBlockBuilder(inputPage.getPositionCount())
@@ -258,7 +268,7 @@ private void insertChangePoints(Iterable<ChangeType> changeTypes) {
258268
changeTypeBlock = blockFactory.newConstantNullBlock(inputPage.getPositionCount());
259269
changePvalueBlock = blockFactory.newConstantNullBlock(inputPage.getPositionCount());
260270
}
261-
outputPage = inputPage.appendBlocks(new Block[]{changeTypeBlock, changePvalueBlock});
271+
outputPage = inputPage.appendBlocks(new Block[] { changeTypeBlock, changePvalueBlock });
262272
if (pageStartIndex + inputPage.getPositionCount() > INPUT_VALUE_COUNT_LIMIT) {
263273
outputPage = outputPage.subPage(0, INPUT_VALUE_COUNT_LIMIT - pageStartIndex);
264274
}
@@ -310,7 +320,7 @@ private static String describe(int metricChannel, List<Integer> partitionChannel
310320
+ metricChannel
311321
+ ", partitionChannels="
312322
+ partitionChannel.stream().map(c -> c.toString()).collect(Collectors.joining(",", "[", "]"))
313-
+ "]";
323+
+ "]";
314324
}
315325

316326
private Warnings warnings(boolean onlyWarnings) {

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/topn/TopNOperator.java

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -451,78 +451,78 @@ private Iterator<Page> toPages() {
451451
// TODO: optimize case where all the queues are empty
452452
try {
453453
for (var entry : inputQueues.entrySet()) {
454-
Queue inputQueue = entry.getValue();
454+
Queue inputQueue = entry.getValue();
455455

456-
list = new ArrayList<>(inputQueue.size());
457-
builders = null;
458-
while (inputQueue.size() > 0) {
459-
list.add(inputQueue.pop());
460-
}
461-
Collections.reverse(list);
462-
463-
int p = 0;
464-
int size = 0;
465-
for (int i = 0; i < list.size(); i++) {
466-
if (builders == null) {
467-
size = Math.min(maxPageSize, list.size() - i);
468-
builders = new ResultBuilder[elementTypes.size()];
469-
for (int b = 0; b < builders.length; b++) {
470-
builders[b] = ResultBuilder.resultBuilderFor(
471-
blockFactory,
472-
elementTypes.get(b),
473-
encoders.get(b).toUnsortable(),
474-
channelInKey(sortOrders, b),
475-
size
476-
);
477-
}
478-
p = 0;
456+
list = new ArrayList<>(inputQueue.size());
457+
builders = null;
458+
while (inputQueue.size() > 0) {
459+
list.add(inputQueue.pop());
479460
}
461+
Collections.reverse(list);
462+
463+
int p = 0;
464+
int size = 0;
465+
for (int i = 0; i < list.size(); i++) {
466+
if (builders == null) {
467+
size = Math.min(maxPageSize, list.size() - i);
468+
builders = new ResultBuilder[elementTypes.size()];
469+
for (int b = 0; b < builders.length; b++) {
470+
builders[b] = ResultBuilder.resultBuilderFor(
471+
blockFactory,
472+
elementTypes.get(b),
473+
encoders.get(b).toUnsortable(),
474+
channelInKey(sortOrders, b),
475+
size
476+
);
477+
}
478+
p = 0;
479+
}
480480

481-
Row row = list.get(i);
482-
BytesRef keys = row.keys.bytesRefView();
483-
for (SortOrder so : sortOrders) {
484-
if (keys.bytes[keys.offset] == so.nul()) {
481+
Row row = list.get(i);
482+
BytesRef keys = row.keys.bytesRefView();
483+
for (SortOrder so : sortOrders) {
484+
if (keys.bytes[keys.offset] == so.nul()) {
485+
keys.offset++;
486+
keys.length--;
487+
continue;
488+
}
485489
keys.offset++;
486490
keys.length--;
487-
continue;
491+
builders[so.channel].decodeKey(keys);
492+
}
493+
if (keys.length != 0) {
494+
throw new IllegalArgumentException("didn't read all keys");
488495
}
489-
keys.offset++;
490-
keys.length--;
491-
builders[so.channel].decodeKey(keys);
492-
}
493-
if (keys.length != 0) {
494-
throw new IllegalArgumentException("didn't read all keys");
495-
}
496-
497-
BytesRef values = row.values.bytesRefView();
498-
for (ResultBuilder builder : builders) {
499-
builder.decodeValue(values);
500-
}
501-
if (values.length != 0) {
502-
throw new IllegalArgumentException("didn't read all values");
503-
}
504496

505-
list.set(i, null);
506-
row.close();
497+
BytesRef values = row.values.bytesRefView();
498+
for (ResultBuilder builder : builders) {
499+
builder.decodeValue(values);
500+
}
501+
if (values.length != 0) {
502+
throw new IllegalArgumentException("didn't read all values");
503+
}
507504

508-
p++;
509-
if (p == size) {
510-
Block[] blocks = new Block[builders.length];
511-
try {
512-
for (int b = 0; b < blocks.length; b++) {
513-
blocks[b] = builders[b].build();
514-
}
515-
} finally {
516-
if (blocks[blocks.length - 1] == null) {
517-
Releasables.closeExpectNoException(blocks);
505+
list.set(i, null);
506+
row.close();
507+
508+
p++;
509+
if (p == size) {
510+
Block[] blocks = new Block[builders.length];
511+
try {
512+
for (int b = 0; b < blocks.length; b++) {
513+
blocks[b] = builders[b].build();
514+
}
515+
} finally {
516+
if (blocks[blocks.length - 1] == null) {
517+
Releasables.closeExpectNoException(blocks);
518+
}
518519
}
520+
result.add(new Page(blocks));
521+
Releasables.closeExpectNoException(builders);
522+
builders = null;
519523
}
520-
result.add(new Page(blocks));
521-
Releasables.closeExpectNoException(builders);
522-
builders = null;
523524
}
524-
}
525-
assert builders == null;
525+
assert builders == null;
526526
}
527527
success = true;
528528
return result.iterator();
@@ -605,7 +605,9 @@ public Status status() {
605605
public String toString() {
606606
int queueSizeSum = inputQueues.values().stream().mapToInt(Queue::size).sum();
607607
return "TopNOperator[count="
608-
+ queueSizeSum + "/" + topCount
608+
+ queueSizeSum
609+
+ "/"
610+
+ topCount
609611
+ ", elementTypes="
610612
+ elementTypes
611613
+ ", encoders="

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ChangePointByOperatorTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.util.ArrayList;
2121
import java.util.List;
22-
import java.util.Optional;
2322

2423
import static org.hamcrest.Matchers.equalTo;
2524
import static org.hamcrest.Matchers.hasSize;
@@ -74,17 +73,19 @@ protected void assertSimpleOutput(List<Page> input, List<Page> output) {
7473
}
7574
assertThat(
7675
actualChangePoints,
77-
equalTo(List.of(
78-
Tuple.tuple(rowCount / 6, "step_change"),
79-
Tuple.tuple(rowCount / 2, "step_change"),
80-
Tuple.tuple(8 * rowCount / 9, "spike"))
76+
equalTo(
77+
List.of(
78+
Tuple.tuple(rowCount / 6, "step_change"),
79+
Tuple.tuple(rowCount / 2, "step_change"),
80+
Tuple.tuple(8 * rowCount / 9, "spike")
81+
)
8182
)
8283
);
8384
}
8485

8586
@Override
8687
protected Operator.OperatorFactory simple() {
87-
return new ChangePointOperator.Factory(0, List.of(1), null,0, 0);
88+
return new ChangePointOperator.Factory(0, List.of(1), null, 0, 0);
8889
}
8990

9091
@Override

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ChangePointOperatorTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.util.ArrayList;
2121
import java.util.List;
22-
import java.util.Optional;
2322

2423
import static org.hamcrest.Matchers.equalTo;
2524
import static org.hamcrest.Matchers.hasSize;

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/topn/TopNOperatorTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import java.util.LinkedHashSet;
5353
import java.util.List;
5454
import java.util.Map;
55-
import java.util.Optional;
5655
import java.util.Set;
5756
import java.util.function.Function;
5857
import java.util.stream.Collectors;

x-pack/plugin/esql/compute/test/src/main/java/org/elasticsearch/compute/test/AbstractBlockSourceOperator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.elasticsearch.compute.data.BlockFactory;
1111
import org.elasticsearch.compute.data.Page;
1212
import org.elasticsearch.compute.operator.SourceOperator;
13-
import org.elasticsearch.test.ESTestCase;
1413

1514
/**
1615
* An abstract source operator. Implementations of this operator produce pages with a random

0 commit comments

Comments
 (0)