sunshone opened a new pull request, #13693: URL: https://github.com/apache/gluten/pull/13693
**What changes are proposed in this pull request?** Fixes [#<issue-id></issue>](<https://github.com/apache/gluten/issues/<issue-id>>) (companion velox PR [bigo-sg/velox#<NN></nn>](<https://github.com/bigo-sg/velox/pull/<NN>>), velox4j PR [bigo-sg/velox4j#<NN></nn>](<https://github.com/bigo-sg/velox4j/pull/<NN>>)): - `StreamExecRank` shadow translation: grouped/global TopN and Top1, the FirstN fast path (single proctime ASC key; routing mirrors the native firstN-before-top1 order), offset rank ranges with true rankStart/rankEnd pass-through, bare `ORDER BY ... LIMIT [OFFSET K]` through the StreamExecSortLimit subclass binding, DECIMAL/DATE sort keys, fail-loud guards for unsupported update strategies and non-constant rank ranges, and the `table.exec.rank.topn-cache-size` job-config read (default 10000) threaded into the velox RankNode plan. - `StreamExecExchange` keeps key-group routing unconditionally native: the native keyed backend derives key groups through the velox hash chain, so the edge partitioner must forward the native partition index — Flink's own key-group partitioner hashes keys a second time with a different chain and routes records away from their state owner at parallelism above 1. Max parallelism resolves job-configured-or-scheduler-default and is matched by the native state backend at runtime, so savepoint resume shards correctly at any parallelism. - Checkpoint persistence over the byte[] channel: `GlutenOneInputOperator` persists native operator checkpoint records as `byte[]` (write-back plus initializeState restore pass-through) and constructs real `KeyedStateBackendParameters` — the subtask's key-group range; `GlutenSourceFunction` and `GlutenStreamingFileWriterOperator` align to the same channel. Also fixes two pre-existing defects this work surfaced end to end: the PROCTIME materialization returned a TIMESTAMP instead of a BIGINT, and `GlutenSourceFunction` re-initialized its transient checkpoint-record array on fresh starts (ObjectInputStream runs no constructors — a non-restoring start handed null records to native state init). - `GlutenStatefulRecordSerializer` rides `BaseVector.serialize()` — presto frames over byte[], length-prefixed on the Flink wire — with v2 snapshot versioning and fail-loud compatibility resolution; deserialization goes through `baseVectorOps().deserializeOne`. - Build docs / CI: the velox4j pin follows the standard upstream file-based mechanism (`gluten-flink/velox4j-ref.txt`, read by both `.github/workflows/flink.yml` and `gluten-flink/docs/Flink.md`); during review it points at the velox4j PR branch tip and is refreshed together with its md5 on each rebase, reverting to the plain ref once that PR merges. **How was this patch tested?** - New `StreamExecRankTranslationTest` (planner UT through MiniCluster at parallelism 1, exact changelog assertions): FirstN routing and its three counter-examples (descending / multi-key / rowtime), SortLimit behavior pinning "N rows, not 1" and the offset truth, the offset window, DECIMAL+DATE with mixed sort directions, and the TIME rejection — 6/6 green. - `GlutenStatefulRecordSerializerTest` 5/5 (v2 wire round-trip, old-format fail-loud, version capture and compatibility resolution) and `GlutenStreamingFileWriterOperatorTest` 2/2 on the byte[][] channel with hostile bytes. - End-to-end dual-run vs native Flink 1.19.2 (fixed filesystem inputs + print sink, changelog folded back to final result sets, jobs must reach FINISHED): 22/22 exact match across the rank suite — the four shapes, FirstN variants, offset windows, bare LIMIT, DECIMAL/DATE keys, checkpoint-resume and P=4 savepoint-resume self-equivalence. - nexmark benchmark at parallelism 4: all four rank shapes (scan-only, firstN, Top1, TopN) run 2.7-6.0x faster than native Flink with identical results. -- 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]
