Skip to content

Commit ca4a159

Browse files
authored
[9.0] Rename driver description (elastic#123863)
1 parent 273b244 commit ca4a159

File tree

42 files changed

+333
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+333
-374
lines changed

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

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ public class Driver implements Releasable, Describable {
5353
private final String sessionId;
5454

5555
/**
56-
* Description of the task this driver is running. This description should be
57-
* short and meaningful as a grouping identifier. We use the phase of the
58-
* query right now: "data", "node_reduce", "final".
56+
* Description of the driver. This description should be short and meaningful as a grouping identifier.
57+
* We use the phase of the query right now: "data", "node_reduce", "final".
5958
*/
60-
private final String taskDescription;
59+
private final String shortDescription;
6160

6261
/**
6362
* The wall clock time when this driver was created in milliseconds since epoch.
@@ -103,10 +102,8 @@ public class Driver implements Releasable, Describable {
103102
/**
104103
* Creates a new driver with a chain of operators.
105104
* @param sessionId session Id
106-
* @param taskDescription Description of the task this driver is running. This
107-
* description should be short and meaningful as a grouping
108-
* identifier. We use the phase of the query right now:
109-
* "data", "node_reduce", "final".
105+
* @param shortDescription Description of the driver. This description should be short and meaningful as a grouping identifier.
106+
* We use the phase of the query right now: "data", "node_reduce", "final".
110107
* @param driverContext the driver context
111108
* @param source source operator
112109
* @param intermediateOperators the chain of operators to execute
@@ -116,7 +113,7 @@ public class Driver implements Releasable, Describable {
116113
*/
117114
public Driver(
118115
String sessionId,
119-
String taskDescription,
116+
String shortDescription,
120117
long startTime,
121118
long startNanos,
122119
DriverContext driverContext,
@@ -128,7 +125,7 @@ public Driver(
128125
Releasable releasable
129126
) {
130127
this.sessionId = sessionId;
131-
this.taskDescription = taskDescription;
128+
this.shortDescription = shortDescription;
132129
this.startTime = startTime;
133130
this.startNanos = startNanos;
134131
this.driverContext = driverContext;
@@ -142,7 +139,7 @@ public Driver(
142139
this.status = new AtomicReference<>(
143140
new DriverStatus(
144141
sessionId,
145-
taskDescription,
142+
shortDescription,
146143
startTime,
147144
System.currentTimeMillis(),
148145
0,
@@ -155,37 +152,6 @@ public Driver(
155152
);
156153
}
157154

158-
/**
159-
* Creates a new driver with a chain of operators.
160-
* @param driverContext the driver context
161-
* @param source source operator
162-
* @param intermediateOperators the chain of operators to execute
163-
* @param sink sink operator
164-
* @param releasable a {@link Releasable} to invoked once the chain of operators has run to completion
165-
*/
166-
public Driver(
167-
String taskDescription,
168-
DriverContext driverContext,
169-
SourceOperator source,
170-
List<Operator> intermediateOperators,
171-
SinkOperator sink,
172-
Releasable releasable
173-
) {
174-
this(
175-
"unset",
176-
taskDescription,
177-
System.currentTimeMillis(),
178-
System.nanoTime(),
179-
driverContext,
180-
() -> null,
181-
source,
182-
intermediateOperators,
183-
sink,
184-
DEFAULT_STATUS_INTERVAL,
185-
releasable
186-
);
187-
}
188-
189155
public DriverContext driverContext() {
190156
return driverContext;
191157
}
@@ -512,7 +478,7 @@ public DriverProfile profile() {
512478
throw new IllegalStateException("can only get profile from finished driver");
513479
}
514480
return new DriverProfile(
515-
status.taskDescription(),
481+
status.description(),
516482
status.started(),
517483
status.lastUpdated(),
518484
finishNanos - startNanos,
@@ -559,7 +525,7 @@ private void updateStatus(long extraCpuNanos, int extraIterations, DriverStatus.
559525

560526
return new DriverStatus(
561527
sessionId,
562-
taskDescription,
528+
shortDescription,
563529
startTime,
564530
now,
565531
prev.cpuNanos() + extraCpuNanos,

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DriverProfile implements Writeable, ChunkedToXContentObject {
3232
* short and meaningful as a grouping identifier. We use the phase of the
3333
* query right now: "data", "node_reduce", "final".
3434
*/
35-
private final String taskDescription;
35+
private final String description;
3636

3737
/**
3838
* Millis since epoch when the driver started.
@@ -69,7 +69,7 @@ public class DriverProfile implements Writeable, ChunkedToXContentObject {
6969
private final DriverSleeps sleeps;
7070

7171
public DriverProfile(
72-
String taskDescription,
72+
String description,
7373
long startMillis,
7474
long stopMillis,
7575
long tookNanos,
@@ -78,7 +78,7 @@ public DriverProfile(
7878
List<DriverStatus.OperatorStatus> operators,
7979
DriverSleeps sleeps
8080
) {
81-
this.taskDescription = taskDescription;
81+
this.description = description;
8282
this.startMillis = startMillis;
8383
this.stopMillis = stopMillis;
8484
this.tookNanos = tookNanos;
@@ -89,7 +89,7 @@ public DriverProfile(
8989
}
9090

9191
public DriverProfile(StreamInput in) throws IOException {
92-
this.taskDescription = in.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90) ? in.readString() : "";
92+
this.description = in.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90) ? in.readString() : "";
9393
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
9494
this.startMillis = in.readVLong();
9595
this.stopMillis = in.readVLong();
@@ -113,7 +113,7 @@ public DriverProfile(StreamInput in) throws IOException {
113113
@Override
114114
public void writeTo(StreamOutput out) throws IOException {
115115
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90)) {
116-
out.writeString(taskDescription);
116+
out.writeString(description);
117117
}
118118
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_16_0)) {
119119
out.writeVLong(startMillis);
@@ -131,8 +131,8 @@ public void writeTo(StreamOutput out) throws IOException {
131131
/**
132132
* Description of the task this driver is running.
133133
*/
134-
public String taskDescription() {
135-
return taskDescription;
134+
public String description() {
135+
return description;
136136
}
137137

138138
/**
@@ -189,7 +189,7 @@ public DriverSleeps sleeps() {
189189
@Override
190190
public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params) {
191191
return Iterators.concat(ChunkedToXContentHelper.startObject(), Iterators.single((b, p) -> {
192-
b.field("task_description", taskDescription);
192+
b.field("description", description);
193193
b.timestampFieldsFromUnixEpochMillis("start_millis", "start", startMillis);
194194
b.timestampFieldsFromUnixEpochMillis("stop_millis", "stop", stopMillis);
195195
b.field("took_nanos", tookNanos);
@@ -218,7 +218,7 @@ public boolean equals(Object o) {
218218
return false;
219219
}
220220
DriverProfile that = (DriverProfile) o;
221-
return taskDescription.equals(that.taskDescription)
221+
return description.equals(that.description)
222222
&& startMillis == that.startMillis
223223
&& stopMillis == that.stopMillis
224224
&& tookNanos == that.tookNanos
@@ -230,7 +230,7 @@ public boolean equals(Object o) {
230230

231231
@Override
232232
public int hashCode() {
233-
return Objects.hash(taskDescription, startMillis, stopMillis, tookNanos, cpuNanos, iterations, operators, sleeps);
233+
return Objects.hash(description, startMillis, stopMillis, tookNanos, cpuNanos, iterations, operators, sleeps);
234234
}
235235

236236
@Override

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class DriverStatus implements Task.Status {
4545
/**
4646
* Description of the task this driver is running.
4747
*/
48-
private final String taskDescription;
48+
private final String description;
4949

5050
/**
5151
* Milliseconds since epoch when this driver started.
@@ -88,7 +88,7 @@ public class DriverStatus implements Task.Status {
8888

8989
DriverStatus(
9090
String sessionId,
91-
String taskDescription,
91+
String description,
9292
long started,
9393
long lastUpdated,
9494
long cpuTime,
@@ -99,7 +99,7 @@ public class DriverStatus implements Task.Status {
9999
DriverSleeps sleeps
100100
) {
101101
this.sessionId = sessionId;
102-
this.taskDescription = taskDescription;
102+
this.description = description;
103103
this.started = started;
104104
this.lastUpdated = lastUpdated;
105105
this.cpuNanos = cpuTime;
@@ -112,7 +112,7 @@ public class DriverStatus implements Task.Status {
112112

113113
public DriverStatus(StreamInput in) throws IOException {
114114
this.sessionId = in.readString();
115-
this.taskDescription = in.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90) ? in.readString() : "";
115+
this.description = in.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90) ? in.readString() : "";
116116
this.started = in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0) ? in.readLong() : 0;
117117
this.lastUpdated = in.readLong();
118118
this.cpuNanos = in.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0) ? in.readVLong() : 0;
@@ -131,7 +131,7 @@ public DriverStatus(StreamInput in) throws IOException {
131131
public void writeTo(StreamOutput out) throws IOException {
132132
out.writeString(sessionId);
133133
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_DRIVER_TASK_DESCRIPTION_90)) {
134-
out.writeString(taskDescription);
134+
out.writeString(description);
135135
}
136136
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_14_0)) {
137137
out.writeLong(started);
@@ -166,8 +166,8 @@ public String sessionId() {
166166
* short and meaningful as a grouping identifier. We use the phase of the
167167
* query right now: "data", "node_reduce", "final".
168168
*/
169-
public String taskDescription() {
170-
return taskDescription;
169+
public String description() {
170+
return description;
171171
}
172172

173173
/**
@@ -232,7 +232,7 @@ public List<OperatorStatus> activeOperators() {
232232
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
233233
builder.startObject();
234234
builder.field("session_id", sessionId);
235-
builder.field("task_description", taskDescription);
235+
builder.field("description", description);
236236
builder.field("started", DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.formatMillis(started));
237237
builder.field("last_updated", DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.formatMillis(lastUpdated));
238238
builder.field("cpu_nanos", cpuNanos);
@@ -261,7 +261,7 @@ public boolean equals(Object o) {
261261
if (o == null || getClass() != o.getClass()) return false;
262262
DriverStatus that = (DriverStatus) o;
263263
return sessionId.equals(that.sessionId)
264-
&& taskDescription.equals(that.taskDescription)
264+
&& description.equals(that.description)
265265
&& started == that.started
266266
&& lastUpdated == that.lastUpdated
267267
&& cpuNanos == that.cpuNanos
@@ -276,7 +276,7 @@ public boolean equals(Object o) {
276276
public int hashCode() {
277277
return Objects.hash(
278278
sessionId,
279-
taskDescription,
279+
description,
280280
started,
281281
lastUpdated,
282282
cpuNanos,

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.elasticsearch.compute.test.BlockTestUtils;
6464
import org.elasticsearch.compute.test.OperatorTestCase;
6565
import org.elasticsearch.compute.test.SequenceLongBlockSourceOperator;
66+
import org.elasticsearch.compute.test.TestDriverFactory;
6667
import org.elasticsearch.core.CheckedConsumer;
6768
import org.elasticsearch.core.Releasables;
6869
import org.elasticsearch.index.mapper.KeywordFieldMapper;
@@ -123,7 +124,7 @@ public void testQueryOperator() throws IOException {
123124
}
124125
});
125126
DriverContext driverContext = driverContext();
126-
drivers.add(new Driver("test", driverContext, factory.get(driverContext), List.of(), docCollector, () -> {}));
127+
drivers.add(TestDriverFactory.create(driverContext, factory.get(driverContext), List.of(), docCollector));
127128
}
128129
OperatorTestCase.runDriver(drivers);
129130
Set<Integer> expectedDocIds = searchForDocIds(reader, query);
@@ -214,8 +215,7 @@ public String toString() {
214215
driverContext
215216
)
216217
);
217-
Driver driver = new Driver(
218-
"test",
218+
Driver driver = TestDriverFactory.create(
219219
driverContext,
220220
luceneOperatorFactory(reader, new MatchAllDocsQuery(), LuceneOperator.NO_LIMIT).get(driverContext),
221221
operators,
@@ -228,8 +228,7 @@ public String toString() {
228228
actualCounts.put(BytesRef.deepCopyOf(spare), counts.getLong(i));
229229
}
230230
page.releaseBlocks();
231-
}),
232-
() -> {}
231+
})
233232
);
234233
OperatorTestCase.runDriver(driver);
235234
assertThat(actualCounts, equalTo(expectedCounts));
@@ -248,8 +247,7 @@ public void testLimitOperator() {
248247
var results = new ArrayList<Long>();
249248
DriverContext driverContext = driverContext();
250249
try (
251-
var driver = new Driver(
252-
"test",
250+
var driver = TestDriverFactory.create(
253251
driverContext,
254252
new SequenceLongBlockSourceOperator(driverContext.blockFactory(), values, 100),
255253
List.of((new LimitOperator.Factory(limit)).get(driverContext)),
@@ -258,8 +256,7 @@ public void testLimitOperator() {
258256
for (int i = 0; i < page.getPositionCount(); i++) {
259257
results.add(block.getLong(i));
260258
}
261-
}),
262-
() -> {}
259+
})
263260
)
264261
) {
265262
OperatorTestCase.runDriver(driver);
@@ -336,8 +333,7 @@ public void testHashLookup() {
336333
var actualValues = new ArrayList<>();
337334
var actualPrimeOrds = new ArrayList<>();
338335
try (
339-
var driver = new Driver(
340-
"test",
336+
var driver = TestDriverFactory.create(
341337
driverContext,
342338
new SequenceLongBlockSourceOperator(driverContext.blockFactory(), values, 100),
343339
List.of(
@@ -354,8 +350,7 @@ public void testHashLookup() {
354350
} finally {
355351
page.releaseBlocks();
356352
}
357-
}),
358-
() -> {}
353+
})
359354
)
360355
) {
361356
OperatorTestCase.runDriver(driver);

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.compute.test.BlockTestUtils;
3232
import org.elasticsearch.compute.test.CannedSourceOperator;
3333
import org.elasticsearch.compute.test.TestBlockFactory;
34+
import org.elasticsearch.compute.test.TestDriverFactory;
3435
import org.elasticsearch.compute.test.TestResultPageSinkOperator;
3536
import org.hamcrest.Matcher;
3637

@@ -110,13 +111,11 @@ public final void testIgnoresNulls() {
110111
List<Page> origInput = BlockTestUtils.deepCopyOf(input, TestBlockFactory.getNonBreakingInstance());
111112

112113
try (
113-
Driver d = new Driver(
114-
"test",
114+
Driver d = TestDriverFactory.create(
115115
driverContext,
116116
new NullInsertingSourceOperator(new CannedSourceOperator(input.iterator()), blockFactory),
117117
List.of(simple().get(driverContext)),
118-
new TestResultPageSinkOperator(results::add),
119-
() -> {}
118+
new TestResultPageSinkOperator(results::add)
120119
)
121120
) {
122121
runDriver(d);

0 commit comments

Comments
 (0)