26
26
import io .trino .metadata .TableHandle ;
27
27
import io .trino .operator .WorkProcessor .ProcessState ;
28
28
import io .trino .operator .WorkProcessor .TransformationState ;
29
- import io .trino .operator .project .CursorProcessor ;
30
- import io .trino .operator .project .CursorProcessorOutput ;
31
29
import io .trino .operator .project .PageProcessor ;
32
30
import io .trino .operator .project .PageProcessorMetrics ;
33
31
import io .trino .spi .Page ;
34
- import io .trino .spi .PageBuilder ;
35
32
import io .trino .spi .connector .ColumnHandle ;
36
33
import io .trino .spi .connector .ConnectorPageSource ;
37
34
import io .trino .spi .connector .ConnectorSession ;
38
35
import io .trino .spi .connector .DynamicFilter ;
39
36
import io .trino .spi .connector .EmptyPageSource ;
40
- import io .trino .spi .connector .RecordCursor ;
41
- import io .trino .spi .connector .RecordPageSource ;
42
37
import io .trino .spi .connector .SourcePage ;
43
38
import io .trino .spi .metrics .Metrics ;
44
39
import io .trino .spi .type .Type ;
56
51
import java .util .function .Consumer ;
57
52
import java .util .function .Function ;
58
53
import java .util .function .LongConsumer ;
59
- import java .util .function .Supplier ;
60
54
61
55
import static com .google .common .base .Preconditions .checkState ;
62
56
import static com .google .common .util .concurrent .MoreExecutors .directExecutor ;
@@ -74,8 +68,6 @@ public class ScanFilterAndProjectOperator
74
68
private final WorkProcessor <Page > pages ;
75
69
private final PageProcessorMetrics pageProcessorMetrics = new PageProcessorMetrics ();
76
70
77
- @ Nullable
78
- private RecordCursor cursor ;
79
71
@ Nullable
80
72
private ConnectorPageSource pageSource ;
81
73
@@ -93,7 +85,6 @@ private ScanFilterAndProjectOperator(
93
85
DriverYieldSignal yieldSignal ,
94
86
WorkProcessor <Split > split ,
95
87
PageSourceProvider pageSourceProvider ,
96
- CursorProcessor cursorProcessor ,
97
88
PageProcessor pageProcessor ,
98
89
TableHandle table ,
99
90
Iterable <ColumnHandle > columns ,
@@ -107,7 +98,6 @@ private ScanFilterAndProjectOperator(
107
98
session ,
108
99
yieldSignal ,
109
100
pageSourceProvider ,
110
- cursorProcessor ,
111
101
pageProcessor ,
112
102
table ,
113
103
columns ,
@@ -163,9 +153,6 @@ public Metrics getConnectorMetrics()
163
153
@ Override
164
154
public Metrics getMetrics ()
165
155
{
166
- if (cursor != null ) {
167
- return Metrics .EMPTY ;
168
- }
169
156
return pageProcessorMetrics .getMetrics ();
170
157
}
171
158
@@ -187,9 +174,6 @@ public void close()
187
174
throw new UncheckedIOException (e );
188
175
}
189
176
}
190
- else if (cursor != null ) {
191
- cursor .close ();
192
- }
193
177
}
194
178
195
179
private class SplitToPages
@@ -198,7 +182,6 @@ private class SplitToPages
198
182
final Session session ;
199
183
final DriverYieldSignal yieldSignal ;
200
184
final PageSourceProvider pageSourceProvider ;
201
- final CursorProcessor cursorProcessor ;
202
185
final PageProcessor pageProcessor ;
203
186
final TableHandle table ;
204
187
final List <ColumnHandle > columns ;
@@ -215,7 +198,6 @@ private class SplitToPages
215
198
Session session ,
216
199
DriverYieldSignal yieldSignal ,
217
200
PageSourceProvider pageSourceProvider ,
218
- CursorProcessor cursorProcessor ,
219
201
PageProcessor pageProcessor ,
220
202
TableHandle table ,
221
203
Iterable <ColumnHandle > columns ,
@@ -228,7 +210,6 @@ private class SplitToPages
228
210
this .session = requireNonNull (session , "session is null" );
229
211
this .yieldSignal = requireNonNull (yieldSignal , "yieldSignal is null" );
230
212
this .pageSourceProvider = requireNonNull (pageSourceProvider , "pageSourceProvider is null" );
231
- this .cursorProcessor = requireNonNull (cursorProcessor , "cursorProcessor is null" );
232
213
this .pageProcessor = requireNonNull (pageProcessor , "pageProcessor is null" );
233
214
this .table = requireNonNull (table , "table is null" );
234
215
this .columns = ImmutableList .copyOf (requireNonNull (columns , "columns is null" ));
@@ -250,7 +231,7 @@ public TransformationState<WorkProcessor<Page>> process(Split split)
250
231
return finished ();
251
232
}
252
233
253
- checkState (cursor == null && pageSource == null , "Table scan split already set" );
234
+ checkState (pageSource == null , "Table scan split already set" );
254
235
255
236
if (!dynamicFilter .getCurrentPredicate ().isAll ()) {
256
237
dynamicFilterSplitsProcessed ++;
@@ -264,22 +245,10 @@ public TransformationState<WorkProcessor<Page>> process(Split split)
264
245
source = pageSourceProvider .createPageSource (session , split , table , columns , dynamicFilter );
265
246
}
266
247
267
- if (source instanceof RecordPageSource recordPageSource ) {
268
- cursor = recordPageSource .getCursor ();
269
- return ofResult (processColumnSource ());
270
- }
271
248
pageSource = source ;
272
249
return ofResult (processPageSource ());
273
250
}
274
251
275
- WorkProcessor <Page > processColumnSource ()
276
- {
277
- return WorkProcessor
278
- .create (new RecordCursorToPages (session , yieldSignal , cursorProcessor , types , pageSourceMemoryContext , outputMemoryContext ))
279
- .yielding (yieldSignal ::isSet )
280
- .blocking (() -> memoryContext .setBytes (localAggregatedMemoryContext .getBytes ()));
281
- }
282
-
283
252
WorkProcessor <Page > processPageSource ()
284
253
{
285
254
ConnectorSession connectorSession = session .toConnectorSession ();
@@ -301,68 +270,6 @@ WorkProcessor<Page> processPageSource()
301
270
}
302
271
}
303
272
304
- private class RecordCursorToPages
305
- implements WorkProcessor .Process <Page >
306
- {
307
- final ConnectorSession session ;
308
- final DriverYieldSignal yieldSignal ;
309
- final CursorProcessor cursorProcessor ;
310
- final PageBuilder pageBuilder ;
311
- final LocalMemoryContext pageSourceMemoryContext ;
312
- final LocalMemoryContext outputMemoryContext ;
313
-
314
- boolean finished ;
315
-
316
- RecordCursorToPages (
317
- Session session ,
318
- DriverYieldSignal yieldSignal ,
319
- CursorProcessor cursorProcessor ,
320
- List <Type > types ,
321
- LocalMemoryContext pageSourceMemoryContext ,
322
- LocalMemoryContext outputMemoryContext )
323
- {
324
- this .session = session .toConnectorSession ();
325
- this .yieldSignal = yieldSignal ;
326
- this .cursorProcessor = cursorProcessor ;
327
- this .pageBuilder = new PageBuilder (types );
328
- this .pageSourceMemoryContext = pageSourceMemoryContext ;
329
- this .outputMemoryContext = outputMemoryContext ;
330
- }
331
-
332
- @ Override
333
- public ProcessState <Page > process ()
334
- {
335
- if (!finished ) {
336
- CursorProcessorOutput output = cursorProcessor .process (session , yieldSignal , cursor , pageBuilder );
337
- pageSourceMemoryContext .setBytes (cursor .getMemoryUsage ());
338
-
339
- processedPositions += output .getProcessedRows ();
340
- // TODO: derive better values for cursors
341
- processedBytes = cursor .getCompletedBytes ();
342
- physicalBytes = cursor .getCompletedBytes ();
343
- physicalPositions = processedPositions ;
344
- readTimeNanos = cursor .getReadTimeNanos ();
345
- if (output .isNoMoreRows ()) {
346
- finished = true ;
347
- }
348
- }
349
-
350
- if (pageBuilder .isFull () || (finished && !pageBuilder .isEmpty ())) {
351
- // only return a page if buffer is full or cursor has finished
352
- Page page = pageBuilder .build ();
353
- pageBuilder .reset ();
354
- outputMemoryContext .setBytes (pageBuilder .getRetainedSizeInBytes ());
355
- return ProcessState .ofResult (page );
356
- }
357
- if (finished ) {
358
- checkState (pageBuilder .isEmpty ());
359
- return ProcessState .finished ();
360
- }
361
- outputMemoryContext .setBytes (pageBuilder .getRetainedSizeInBytes ());
362
- return ProcessState .yielded ();
363
- }
364
- }
365
-
366
273
static class ProcessedBytesMonitor
367
274
implements Consumer <ProcessState <Page >>
368
275
{
@@ -445,7 +352,6 @@ public static class ScanFilterAndProjectOperatorFactory
445
352
{
446
353
private final int operatorId ;
447
354
private final PlanNodeId planNodeId ;
448
- private final Supplier <CursorProcessor > cursorProcessor ;
449
355
private final Function <DynamicFilter , PageProcessor > pageProcessor ;
450
356
private final PlanNodeId sourceId ;
451
357
private final PageSourceProvider pageSourceProvider ;
@@ -462,7 +368,6 @@ public ScanFilterAndProjectOperatorFactory(
462
368
PlanNodeId planNodeId ,
463
369
PlanNodeId sourceId ,
464
370
PageSourceProviderFactory pageSourceProvider ,
465
- Supplier <CursorProcessor > cursorProcessor ,
466
371
Function <DynamicFilter , PageProcessor > pageProcessor ,
467
372
TableHandle table ,
468
373
Iterable <ColumnHandle > columns ,
@@ -473,7 +378,6 @@ public ScanFilterAndProjectOperatorFactory(
473
378
{
474
379
this .operatorId = operatorId ;
475
380
this .planNodeId = requireNonNull (planNodeId , "planNodeId is null" );
476
- this .cursorProcessor = requireNonNull (cursorProcessor , "cursorProcessor is null" );
477
381
this .pageProcessor = requireNonNull (pageProcessor , "pageProcessor is null" );
478
382
this .sourceId = requireNonNull (sourceId , "sourceId is null" );
479
383
this .table = requireNonNull (table , "table is null" );
@@ -530,7 +434,6 @@ public WorkProcessorSourceOperator create(
530
434
yieldSignal ,
531
435
split ,
532
436
pageSourceProvider ,
533
- cursorProcessor .get (),
534
437
pageProcessor .apply (dynamicFilter ),
535
438
table ,
536
439
columns ,
0 commit comments