rohityadav1993 commented on PR #19120:
URL: https://github.com/apache/pinot/pull/19120#issuecomment-5200669708
Hi @gortiz, could you help with reviewing this 1st of the 3 PRs.
<details>
<summary> Here is flow chart of the new selection operator being added to
help with the review</summary>
```mermaid
flowchart TD
A["getNextBlock()"] --> B{"_exhausted?"}
B -- yes --> Z["return null"]
B -- no --> C{"_tailToSort?"}
C -- "no (no unsorted tail)" --> D["nextSortedRows()"]
C -- "yes (tail must be sorted per-run)" --> E["nextRun()"]
subgraph NSR["nextSortedRows() — pass-through mode"]
D --> D1{"remaining = numRowsToKeep - numRowsEmitted <= 0?"}
D1 -- yes --> D2["return null"]
D1 -- no --> D3["_projectOperator.nextBlock()"]
D3 --> D4{"block == null?"}
D4 -- yes --> D2
D4 -- no --> D5["build BlockValSets + RowBasedBlockValueFetcher\nfor
phase1 expressions"]
D5 --> D6["materializeRow() for first min(numDocs, remaining) rows"]
D6 --> D7["numRowsEmitted += rows.size()\nreturn rows"]
end
subgraph NR["nextRun() — buffer-and-sort-per-run mode"]
E --> E1{"remaining <= 0?"}
E1 -- yes --> E2["return null"]
E1 -- no --> E3{"_pendingRow == null?"}
E3 -- yes --> E4["_pendingRow = nextRow()"]
E4 --> E5{"still null?"}
E5 -- yes --> E2
E3 -- no --> E6
E5 -- no --> E6["clear _runHeap;\nseed with _pendingRow as
runFirstRow"]
E6 --> E7["loop: row = nextRow()"]
E7 --> E8{"primaryComparator(row, runFirstRow) == 0?"}
E8 -- yes --> E9["add row to _runHeap (bounded to numRowsToKeep)"]
E9 --> E7
E8 -- no --> E10["stash row as _pendingRow (next run's first
row)\nbreak loop"]
E10 --> E11["drainAscending(_runHeap)"]
E11 --> E12{"rows.size() > remaining?"}
E12 -- yes --> E13["truncate to first 'remaining' rows"]
E12 -- no --> E14["numRowsEmitted += rows.size()\nreturn rows"]
E13 --> E14
end
subgraph NEXTROW["nextRow() — forward scan cursor"]
F["nextRow()"] --> F1{"current block exhausted?"}
F1 -- yes --> F2{"_projectExhausted?"}
F2 -- yes --> F3["return null"]
F2 -- no --> F4["_projectOperator.nextBlock()"]
F4 --> F5{"block == null?"}
F5 -- yes --> F6["_projectExhausted = true\nreturn null"]
F5 -- no --> F7["rebuild fetcher/docIds/nullBitmaps\nfor new block;
reset _currentPos=0"]
F7 --> F1
F1 -- no --> F8["materializeRow() at _currentPos++\nreturn row"]
end
E4 -.calls.-> F
E7 -.calls.-> F
D7 --> G{"_twoPhase?"}
E14 --> G
G -- yes --> H["fetchNonOrderByColumns(rows)"]
G -- no --> I["_dataSchema already built\n(buildSinglePhaseDataSchema in
ctor)"]
subgraph PHASE2["fetchNonOrderByColumns() — two-phase second pass"]
H --> H1["collect docIds bitmap from rows"]
H1 --> H2["sort a docId-ordered view sharing same row instances"]
H2 --> H3["BitmapDocIdSetOperator.ascending(docIds)\n→
ProjectionOperator → TransformOperator"]
H3 --> H4["pull transformOperator blocks,\nfill non-order-by values
into rows in place"]
H4 --> H5{"_dataSchema == null?"}
H5 -- yes --> H6["buildTwoPhaseDataSchema()"]
H5 -- no --> H7["done"]
H6 --> H7
end
H7 --> J
I --> J["new SelectionResultsBlock(_dataSchema, rows, _comparator,
_queryContext)"]
J --> K["return block"]
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]