Repository navigation
Export to Arrow with the session of the execution context - #11304
connortsui20 wants to merge 1 commit into
Conversation
5953b96 to
647638a
Compare
647638a to
fcb03fb
Compare
Merging this PR will regress 1 benchmark1 warning
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
fcb03fb to
17d2e77
Compare
|
I think the main files to review are:
|
An Arrow export took an ArrowSession as its receiver and an ExecutionCtx that carries its own VortexSession. The top-level dispatch and the target checks used the receiver, while export plugins and the inference of nested fields used the session of the context. So `ArrowSession::default().execute_arrow(array, None, &mut other.create_execution_ctx())` compiled and mixed the plugins of two sessions in one export. Exports now go through the new `ExecuteArrowExt` extension trait on arrays (`execute_arrow` and `execute_arrow_with_options`), which reads the ArrowSession from the context and takes no other session. This replaces `ArrowSession::execute_arrow`, `ArrowSession::exporter`, `ArrowExporter`, and the deprecated `ArrowArrayExecutor` trait. ArrowSession has no public constructor or Default anymore, so every ArrowSession belongs to a VortexSession. A lazily created ArrowSession was a bare default with an empty extension dtype registry. It exported an extension type without a plugin under its Vortex ID, but imported the same field back as plain storage. Only `vortex_arrow::initialize` wired the registry, and it replaced any existing ArrowSession, which dropped plugins that other crates had registered earlier. `ArrowSessionExt::arrow` now builds the session from the dtype registry on first use through the new `SessionExt::get_or_insert_with`, so `vortex_arrow::initialize` is no longer needed and is removed. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
17d2e77 to
6c7f48f
Compare
| impl<S: SessionExt> ArrowSessionExt for S { | ||
| fn arrow(&self) -> SessionGuard<'_, ArrowSession> { | ||
| self.get::<ArrowSession>() | ||
| self.get_or_insert_with(|| ArrowSession::new(&self.dtypes())) |
There was a problem hiding this comment.
this is where the new session method is called
Summary
Fieldinstead of aDataType.Stacked on #11301.
An Arrow export could use two different
ArrowSessions at once, and the API made that easy to do by accident.ArrowSession::execute_arrowtook the session as its receiver and also anExecutionCtx, which carries its ownVortexSessionand so its ownArrowSession. The top-level dispatch and the target checks used the receiver, but plugins such asVectorandJsonexport their storage through the session of the ctx. SoArrowSession::default().execute_arrow(array, None, &mut session.create_execution_ctx())compiled, and which plugins ran depended on which part of the export was looking.A session that
arrow()created on first use also could not import what it exported. It was a bare default without the dtype registry, so it wrote an extension type without a plugin under its Vortex ID but read the same field back as plain storage. Onlyvortex_arrow::initializefixed that, and it replaced the existing session, so calling it aftervortex_uuid::initializesilently dropped the UUID plugins.Changes
Exports now go through
ExecuteArrowExton the array, which takes its session from the ctx, so there is no second session to pass. Keepingsession.arrow().execute_arrow(..)and using the session of the ctx inside was rejected, because the receiver would then be silently ignored. A runtime check that both are the same session was rejected too, because it only fails on the paths that tests happen to cover. The old methods are removed instead of deprecated, since a deprecated method that takes a session keeps the same trap open.arrow()now builds the session from the dtype registry on first use, through the newSessionExt::get_or_insert_with, so every session imports what it exports. That leaves nothing forinitializeto do, so it is removed instead of fixed.Note that
arrow()now also creates theDTypeSession, so.with::<DTypeSession>()after the firstarrow()call panics, as it already did afterinitialize. New tests cover a UUID session that imports by Vortex ID withoutinitialize, and a dtype that is registered after the firstarrow()call.API Changes
ArrowSession::execute_arrow,ArrowSession::exporter, andArrowExporterare removed. Useexecute_arroworexecute_arrow_with_optionsfromvortex_arrow::ExecuteArrowExton the array instead.ArrowArrayExecutoris removed.vortex_arrow::initializeis removed.ArrowSessionhas noDefaultor public constructor, so everyArrowSessioncomes from aVortexSession.vortex-sessiongainsSessionExt::get_or_insert_with.