John-W-Lewis opened a new pull request, #1149: URL: https://github.com/apache/arrow-java/pull/1149
## Summary Introduces `VectorOps`, a new utility class in `org.apache.arrow.vector.util` that provides three generic whole-vector operations: - **`shareCopy`** -- creates a new vector sharing the same underlying memory allocations via reference counting. Both source and result remain usable; memory is released only when all sharing vectors are closed. - **`transferCopy`** -- creates a new vector by transferring buffer ownership. The source is left empty and can be reused via `allocateNew()`. - **`deepCopy`** -- creates a fully independent clone with its own buffer allocations. These operations work generically across all vector types via `getFieldBuffers()`/`loadFieldBuffers()`, requiring no per-type implementation -- unlike `TransferPair`, which must be implemented by every vector type. `VectorOps` can replace `TransferPair` for whole-vector operations; `TransferPair` remains necessary for sub-range splitting/slicing (`splitAndTransfer`). This PR also uses `shareCopy` to fix the unsafe shared-reference bug in `VectorSchemaRoot.addVector()` and `removeVector()` (see #1142). The original implementation shared raw object references between source and result roots, meaning closing one would invalidate the other. The fix preserves the original intended semantics (both roots remain readable) while making it safe through proper reference counting. Closes #1142 ## Test plan - [x] `TestVectorOps`: 12 tests covering all three operations on IntVector, VarCharVector, VectorSchemaRoot, with/without explicit allocator, and source-closed-before-shared-copy semantics - [x] `TestVectorSchemaRoot`: Updated existing tests + 2 new ownership tests verifying that closing the source root after `addVector`/`removeVector` does not affect the result - [x] Spotless formatting passes - [x] All tests pass with JDK 21 Made with [Cursor](https://cursor.com) -- 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]
