Repository navigation
Conversation
LanceArrowBatchScan switches a Lance BatchScanExec to lance-spark's Arrow batch reads (LanceScan.withArrowBatches, lance-spark#908) when Velox imports every column type of them, and VeloxLanceComponent declares those batches as ArrowJavaBatchType, so Gluten offloads them with its Arrow transitions. The vanilla BatchScanExec stays in the plan and keeps lance-spark's runtime filters, output partitioning and metrics. LanceScanTransformer and OffloadLanceScan are removed. OffloadArrowDataExec now closes the batches that ColumnarBatches.offload builds from Spark ArrowColumnVectors, which nothing closed before. Generated-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Velox imports both, and Gluten runs TIMESTAMP_NTZ natively by default. ArrowColumnVectors.adopt and copy now handle a NullVector, whose getAllocator() throws. Generated-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lance-spark allocated the Arrow batches of a Lance scan under Spark's root allocator, so OffloadArrowDataExec copied every batch into Gluten's task allocator: Arrow moves buffers only within a root, and a move into Gluten's allocator would leave its listener unbalanced (Arrow charges a transfer without calling the target's AllocationListener, then calls onRelease on the last owner's listener). VeloxLanceComponent now supplies the task's Arrow allocator to lance-spark (LanceRuntime.setArrowBatchAllocatorProvider) when the executor starts. A Lance reader builds its batches in it, so the offload adopts their vectors in place, and their memory is charged to the task once through Spark's memory manager. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
sezruby
force-pushed
the
feat/lance-arrow-batches
branch
from
November 26, 2026 16:33
3118c49 to
084ac16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
lance-spark allocates the Arrow batches of a Lance scan under Spark's root allocator, so
OffloadArrowDataExeccopies every batch into Gluten's task allocator (ArrowColumnVectors.adopt). Arrow moves buffers only within one root. A move into Gluten's allocator would also unbalance its listener: Arrow charges a transfer without calling the target'sAllocationListener, then callsonReleaseon the listener of whichever allocator owns the memory last (details in apache#12958, issuecomment-6904672648).VeloxLanceComponentnow supplies the task's Arrow allocator to lance-spark when the executor starts:onExecutorStartsetsLanceRuntime.setArrowBatchAllocatorProvidertoArrowBufferAllocators.contextInstance()(null outside a Spark task);onExecutorShutdownclears it.OffloadArrowDataExecoffloads with, soadopttransfers within one allocator. There's no copy and no move between allocators, and the memory is charged to the task once.TaskResourcesregisters its completion listener at task start, beforeDataSourceRDDregisters the reader's close, so the reader closes before the allocator is released.VeloxLance.mddrops the copy from the limitations.Before enabling: memory refused during the import
Gluten's task allocator throws when Spark has no memory left to grant (
ManagedAllocationListenerover athrowOnOomtarget). With this change, lance-spark imports each batch's Arrow C stream into that allocator, so a refusal can happen inside Arrow Java's C Data import.Gluten's Arrow Java has both leaks. That covers the 15.0.0 source build (
dev/build-arrow.shwithmodify_arrow.patch) and the Maven 18.x / 19.0 artifacts used for Spark 4.x. So this change should wait for an Arrow Java release with both fixes. Alternatively, the source build could carry the two small patches.ColumnarBatches.load) already have the same exposure.How was this patch tested?
All runs are on amd64 Linux against a local build of lance-format/lance-spark#966:
VeloxLanceSuitepasses 13/13, including a new test: every vector of a Lance task's Arrow batches lives in the task's Arrow allocator. A row-based query still feeds Velox throughOffloadArrowDataExec.ArrowColumnVectorTest(7),ColumnarBatchTest(8) andVeloxTransitionSuite(24) pass.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5