mbutrovich opened a new pull request, #4507:
URL: https://github.com/apache/datafusion-comet/pull/4507

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes #3925.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.
   -->
   
   When `CometShuffleExchangeExec` has a `CometNativeExec` child, the current 
implementation runs two `CometExecIterator` instances per partition: one for 
the upstream native subtree producing `ColumnarBatch` to JVM, and one for 
`Scan("ShuffleWriterInput") -> ShuffleWriter` consuming those batches back from 
JVM.
   
   The proto already supports the unsplit form: `Operator.children` is 
`repeated` and `ShuffleWriter` is an `op_struct`. This PR uses that form on the 
rich-child path. Each partition runs one `CometExecIterator` over 
`ShuffleWriter(child = childNativeOp)`. The per-batch Arrow C Stream Interface 
export+import between the two iterators is removed, along with one 
`createPlan`/`releasePlan` JNI pair and the per-batch `executePlan` JNI for the 
upstream iterator. The JVM-to-native batch boundary inside the stage no longer 
exists, so the schema reconciliation added in #4393 does not apply on this path.
   
   Wire-level behavior is unchanged for callers without a `CometNativeExec` 
subtree to inline (`CometSparkToColumnarExec` child, `CometCollectLimitExec`, 
`CometTakeOrderedAndProjectExec`). They get a synthesized 
`Scan("ShuffleWriterInput")` as `childNativeOp` and the same JVM-to-native 
batch flow as before.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Add `NativeExecContext` and `buildNativeContext()` / 
`executeColumnarWithContext(ctx)` on `CometNativeExec`. The shuffle path reuses 
the same per-partition input/context construction (broadcast alignment, 
plan-data, subqueries, encryption) as `doExecuteColumnar`.
   - Add `CometNativeShuffleInputRDD` (thin scheduling-anchor RDD) with 
`CometNativeShuffleInputPartition` and `CometNativeShuffleInputIterator`. 
`compute` resolves leaf partitions on the driver and returns an iterator 
carrying per-partition leaf iterators and shuffle-block iterators.
   - Add `NativeShuffleSpec` (child native op, child metric node, exec 
context). `CometShuffleDependency` carries an `Option[NativeShuffleSpec]`, 
populated only on native-shuffle deps.
   - `CometShuffleExchangeExec` dispatches on whether the child is a 
`CometNativeExec`. Rich-child path uses `prepareNativeShuffleDependency` and 
the thin RDD; otherwise the 5-arg `prepareShuffleDependency` synthesizes a 
`Scan` placeholder.
   - `CometNativeShuffleWriter` rewritten to one code path: always 
`ShuffleWriter(child = spec.childNativeOp)`, always reads inputs from 
`CometNativeShuffleInputIterator`. Subquery binding, plan-data injection, and 
metric-tree composition are unchanged.
   - Range-partitioning sampling on the rich-child path reuses the precomputed 
`NativeExecContext` instead of re-walking the SparkPlan tree (avoids a 
duplicate encryption broadcast).
   - `NativeExecContext` enforces the `perPartitionByKey` array-length 
invariant via `require()` so both the RDD and writer paths catch shape 
divergence at construction.
   - Update `docs/source/contributor-guide/native_shuffle.md` to reflect the 
new write path and class roles.
   
   ## How are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   Existing tests.


-- 
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]

Reply via email to