Skip to content

Commit fc5c773

Browse files
author
elasticsearchmachine
committed
[CI] Auto commit changes from spotless
1 parent b24fec8 commit fc5c773

File tree

10 files changed

+114
-79
lines changed

10 files changed

+114
-79
lines changed

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

Lines changed: 20 additions & 7 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, Optional<Integer> partitionChannel, String sourceText, int sourceLine, int sourceColumn) implements OperatorFactory {
41+
public record Factory(int metricChannel, Optional<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, Optional<Integer> partitionChannel, String sourceText, int sourceLine, int sourceColumn) {
69+
public ChangePointOperator(
70+
DriverContext driverContext,
71+
int metricChannel,
72+
Optional<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())
@@ -298,7 +308,10 @@ public String toString() {
298308
}
299309

300310
private static String describe(int metricChannel, Optional<Integer> partitionChannel) {
301-
return "ChangePointOperator[metricChannel=" + metricChannel + (partitionChannel.isPresent() ? ", partitionChannel=" + partitionChannel.get() : "") + "]";
311+
return "ChangePointOperator[metricChannel="
312+
+ metricChannel
313+
+ (partitionChannel.isPresent() ? ", partitionChannel=" + partitionChannel.get() : "")
314+
+ "]";
302315
}
303316

304317
private Warnings warnings(boolean onlyWarnings) {

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

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -441,78 +441,78 @@ private Iterator<Page> toPages() {
441441
// TODO: optimize case where all the queues are empty
442442
try {
443443
for (var entry : inputQueues.entrySet()) {
444-
Queue inputQueue = entry.getValue();
444+
Queue inputQueue = entry.getValue();
445445

446-
list = new ArrayList<>(inputQueue.size());
447-
builders = null;
448-
while (inputQueue.size() > 0) {
449-
list.add(inputQueue.pop());
450-
}
451-
Collections.reverse(list);
452-
453-
int p = 0;
454-
int size = 0;
455-
for (int i = 0; i < list.size(); i++) {
456-
if (builders == null) {
457-
size = Math.min(maxPageSize, list.size() - i);
458-
builders = new ResultBuilder[elementTypes.size()];
459-
for (int b = 0; b < builders.length; b++) {
460-
builders[b] = ResultBuilder.resultBuilderFor(
461-
blockFactory,
462-
elementTypes.get(b),
463-
encoders.get(b).toUnsortable(),
464-
channelInKey(sortOrders, b),
465-
size
466-
);
467-
}
468-
p = 0;
446+
list = new ArrayList<>(inputQueue.size());
447+
builders = null;
448+
while (inputQueue.size() > 0) {
449+
list.add(inputQueue.pop());
469450
}
451+
Collections.reverse(list);
452+
453+
int p = 0;
454+
int size = 0;
455+
for (int i = 0; i < list.size(); i++) {
456+
if (builders == null) {
457+
size = Math.min(maxPageSize, list.size() - i);
458+
builders = new ResultBuilder[elementTypes.size()];
459+
for (int b = 0; b < builders.length; b++) {
460+
builders[b] = ResultBuilder.resultBuilderFor(
461+
blockFactory,
462+
elementTypes.get(b),
463+
encoders.get(b).toUnsortable(),
464+
channelInKey(sortOrders, b),
465+
size
466+
);
467+
}
468+
p = 0;
469+
}
470470

471-
Row row = list.get(i);
472-
BytesRef keys = row.keys.bytesRefView();
473-
for (SortOrder so : sortOrders) {
474-
if (keys.bytes[keys.offset] == so.nul()) {
471+
Row row = list.get(i);
472+
BytesRef keys = row.keys.bytesRefView();
473+
for (SortOrder so : sortOrders) {
474+
if (keys.bytes[keys.offset] == so.nul()) {
475+
keys.offset++;
476+
keys.length--;
477+
continue;
478+
}
475479
keys.offset++;
476480
keys.length--;
477-
continue;
481+
builders[so.channel].decodeKey(keys);
482+
}
483+
if (keys.length != 0) {
484+
throw new IllegalArgumentException("didn't read all keys");
478485
}
479-
keys.offset++;
480-
keys.length--;
481-
builders[so.channel].decodeKey(keys);
482-
}
483-
if (keys.length != 0) {
484-
throw new IllegalArgumentException("didn't read all keys");
485-
}
486-
487-
BytesRef values = row.values.bytesRefView();
488-
for (ResultBuilder builder : builders) {
489-
builder.decodeValue(values);
490-
}
491-
if (values.length != 0) {
492-
throw new IllegalArgumentException("didn't read all values");
493-
}
494486

495-
list.set(i, null);
496-
row.close();
487+
BytesRef values = row.values.bytesRefView();
488+
for (ResultBuilder builder : builders) {
489+
builder.decodeValue(values);
490+
}
491+
if (values.length != 0) {
492+
throw new IllegalArgumentException("didn't read all values");
493+
}
497494

498-
p++;
499-
if (p == size) {
500-
Block[] blocks = new Block[builders.length];
501-
try {
502-
for (int b = 0; b < blocks.length; b++) {
503-
blocks[b] = builders[b].build();
504-
}
505-
} finally {
506-
if (blocks[blocks.length - 1] == null) {
507-
Releasables.closeExpectNoException(blocks);
495+
list.set(i, null);
496+
row.close();
497+
498+
p++;
499+
if (p == size) {
500+
Block[] blocks = new Block[builders.length];
501+
try {
502+
for (int b = 0; b < blocks.length; b++) {
503+
blocks[b] = builders[b].build();
504+
}
505+
} finally {
506+
if (blocks[blocks.length - 1] == null) {
507+
Releasables.closeExpectNoException(blocks);
508+
}
508509
}
510+
result.add(new Page(blocks));
511+
Releasables.closeExpectNoException(builders);
512+
builders = null;
509513
}
510-
result.add(new Page(blocks));
511-
Releasables.closeExpectNoException(builders);
512-
builders = null;
513514
}
514-
}
515-
assert builders == null;
515+
assert builders == null;
516516
}
517517
success = true;
518518
return result.iterator();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ChangePointByOperatorTests extends OperatorTestCase {
3030
@Override
3131
protected SourceOperator simpleInput(BlockFactory blockFactory, int size) {
3232
// size must be in [25, 1000] for ChangePoint to function correctly and detect the step change.
33-
size = 25;//Math.clamp(size, 25, 1000);
33+
size = 25;// Math.clamp(size, 25, 1000);
3434
List<Tuple<Long, BytesRef>> data = new ArrayList<>(size);
3535
for (int i = 0; i < size; i++) { // step change 0 -> 100
3636
data.add(Tuple.tuple(i < size / 2 ? randomLongBetween(0, 3) : randomLongBetween(100, 103), new BytesRef("prod")));
@@ -81,7 +81,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> output) {
8181

8282
@Override
8383
protected Operator.OperatorFactory simple() {
84-
return new ChangePointOperator.Factory(0, Optional.of(1), null,0, 0);
84+
return new ChangePointOperator.Factory(0, Optional.of(1), null, 0, 0);
8585
}
8686

8787
@Override

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

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/ChangePoint.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ public class ChangePoint extends UnaryPlan implements SurrogateLogicalPlan, Post
5151

5252
private List<Attribute> output;
5353

54-
public ChangePoint(Source source, LogicalPlan child, Attribute value, Attribute key, Attribute partitionField, Attribute targetType, Attribute targetPvalue) {
54+
public ChangePoint(
55+
Source source,
56+
LogicalPlan child,
57+
Attribute value,
58+
Attribute key,
59+
Attribute partitionField,
60+
Attribute targetType,
61+
Attribute targetPvalue
62+
) {
5563
super(source, child);
5664
this.value = value;
5765
this.key = key;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/TopN.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.common.io.stream.StreamInput;
1212
import org.elasticsearch.common.io.stream.StreamOutput;
1313
import org.elasticsearch.xpack.esql.core.capabilities.Resolvables;
14-
import org.elasticsearch.xpack.esql.core.expression.Attribute;
1514
import org.elasticsearch.xpack.esql.core.expression.Expression;
1615
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
1716
import org.elasticsearch.xpack.esql.core.tree.Source;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/TopNExec.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ public class TopNExec extends UnaryExec implements EstimatesRowSize {
3939
*/
4040
private final Integer estimatedRowSize;
4141

42-
public TopNExec(Source source, PhysicalPlan child, Expression partitionField, List<Order> order, Expression limit, Integer estimatedRowSize) {
42+
public TopNExec(
43+
Source source,
44+
PhysicalPlan child,
45+
Expression partitionField,
46+
List<Order> order,
47+
Expression limit,
48+
Integer estimatedRowSize
49+
) {
4350
super(source, child);
4451
this.partitionField = partitionField;
4552
this.order = order;
@@ -106,7 +113,8 @@ public Integer estimatedRowSize() {
106113
@Override
107114
public PhysicalPlan estimateRowSize(State state) {
108115
final List<Attribute> output = output();
109-
final boolean needsSortedDocIds = output.stream().anyMatch(a -> a.typeResolved().resolved() && a.dataType() == DataType.DOC_DATA_TYPE);
116+
final boolean needsSortedDocIds = output.stream()
117+
.anyMatch(a -> a.typeResolved().resolved() && a.dataType() == DataType.DOC_DATA_TYPE);
110118
state.add(needsSortedDocIds, output);
111119
int size = state.consumeAllFields(true);
112120
size = Math.max(size, 1);

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ private PhysicalOperation planProject(ProjectExec project, LocalExecutionPlanner
762762
Layout.ChannelAndType input = source.layout.get(inputId);
763763
if (input == null) {
764764
continue;
765-
// throw new IllegalStateException("can't find input for [" + ne + "]"); // TODO: uncomment?
765+
// throw new IllegalStateException("can't find input for [" + ne + "]"); // TODO: uncomment?
766766
}
767767
layout.append(ne);
768768
projectionList.add(input.channel());
@@ -821,7 +821,9 @@ private PhysicalOperation planChangePoint(ChangePointExec changePoint, LocalExec
821821
return source.with(
822822
new ChangePointOperator.Factory(
823823
layout.get(changePoint.value().id()).channel(),
824-
changePoint.partitionField() != null ? Optional.of(layout.get(changePoint.partitionField().id()).channel()) : Optional.empty(),
824+
changePoint.partitionField() != null
825+
? Optional.of(layout.get(changePoint.partitionField().id()).channel())
826+
: Optional.empty(),
825827
changePoint.sourceText(),
826828
changePoint.sourceLocation().getLineNumber(),
827829
changePoint.sourceLocation().getColumnNumber()

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/logical/TopNSerializationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ protected TopN mutateInstance(TopN instance) throws IOException {
4646
Expression limit = instance.limit();
4747
switch (between(0, 3)) {
4848
case 0 -> child = randomValueOtherThan(child, () -> randomChild(0));
49-
case 1 -> partitionField = randomValueOtherThan(partitionField, () -> new Literal(randomSource(), randomAlphaOfLengthBetween(1, 10), DataType.KEYWORD));
49+
case 1 -> partitionField = randomValueOtherThan(
50+
partitionField,
51+
() -> new Literal(randomSource(), randomAlphaOfLengthBetween(1, 10), DataType.KEYWORD)
52+
);
5053
case 2 -> order = randomValueOtherThan(order, TopNSerializationTests::randomOrders);
5154
case 3 -> limit = randomValueOtherThan(limit, AbstractExpressionSerializationTests::randomChild);
5255
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/TopNExecSerializationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ protected TopNExec mutateInstance(TopNExec instance) throws IOException {
4848
estimatedRowSize,
4949
AbstractPhysicalPlanSerializationTests::randomEstimatedRowSize
5050
);
51-
case 4 -> partitionField = randomValueOtherThan(partitionField, () -> new Literal(randomSource(), randomAlphaOfLengthBetween(1, 10), DataType.KEYWORD));
51+
case 4 -> partitionField = randomValueOtherThan(
52+
partitionField,
53+
() -> new Literal(randomSource(), randomAlphaOfLengthBetween(1, 10), DataType.KEYWORD)
54+
);
5255
default -> throw new UnsupportedOperationException();
5356
}
5457
return new TopNExec(instance.source(), child, partitionField, order, limit, estimatedRowSize);

0 commit comments

Comments
 (0)