Skip to content

New C++ API#8741

Merged
myrrc merged 6 commits into
developfrom
myrrc/cxx2-code
Jul 14, 2026
Merged

New C++ API#8741
myrrc merged 6 commits into
developfrom
myrrc/cxx2-code

Conversation

@myrrc

@myrrc myrrc commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Add new C++ API code.
Tests and examples will be added in the next PR

@myrrc
myrrc requested a review from 0ax1 July 13, 2026 16:12
@myrrc
myrrc force-pushed the myrrc/cxx2-code branch from 96bfeae to 9773d83 Compare July 13, 2026 16:14
@myrrc myrrc added changelog/feature A new feature lang/cpp Relates to the Vortex C++ API labels Jul 13, 2026
@myrrc
myrrc enabled auto-merge (squash) July 13, 2026 16:16
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@myrrc
myrrc force-pushed the myrrc/cxx2-code branch from 9773d83 to afbbb04 Compare July 13, 2026 16:17
@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1698 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing myrrc/cxx2-code (b4aec09) with develop (5abaf98)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@joseph-isaacs

Copy link
Copy Markdown
Contributor

Please can we add the tests along side the code.

Comment thread lang/cpp/src/f16.cpp
Comment thread lang/cpp/include/vortex/common.hpp
@myrrc
myrrc requested a review from 0ax1 July 14, 2026 10:28
Comment thread lang/cpp/include/vortex/array.hpp Outdated
Comment thread lang/cpp/include/vortex/array.hpp
Comment thread lang/cpp/include/vortex/array.hpp
Comment thread lang/cpp/include/vortex/common.hpp
Comment thread lang/cpp/include/vortex/data_source.hpp
Comment thread lang/cpp/include/vortex/data_source.hpp
Comment thread lang/cpp/include/vortex/estimate.hpp
Comment thread lang/cpp/include/vortex/expression.hpp
Comment thread lang/cpp/include/vortex/dtype.hpp
Comment thread lang/cpp/src/array.cpp Outdated
@myrrc myrrc mentioned this pull request Jul 14, 2026
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@vortex-data vortex-data deleted a comment from 0ax1 Jul 14, 2026
@myrrc
myrrc requested a review from 0ax1 July 14, 2026 12:37
Comment thread lang/cpp/include/vortex/array.hpp Outdated
Comment thread lang/cpp/include/vortex/array.hpp Outdated
Comment thread lang/cpp/include/vortex/array.hpp
@0ax1

0ax1 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

noexcept audit

Given that this was already inconsistent I'd still vote for fully dropping noexcept.

Scope and criterion

This audit covers the new lang/cpp API.

noexcept is a public contract: adding it turns a propagated exception into
std::terminate. A Rust panic crossing an extern "C-unwind" function is not
a safe basis for marking a C++ function non-throwing.

There are a few clear omissions, but most apparent accessor candidates should
remain unannotated until the FFI guarantees no panic or unwind.

Clear noexcept additions

These do not allocate, do not use an FFI error path, and do not depend on an
unwinding FFI call.

Location Candidate
lang/cpp/include/vortex/common.hpp:18 / src/f16.cpp:12 float16_t::operator float() const noexcept
lang/cpp/include/vortex/common.hpp:50 detail::to_ptype<T>() noexcept
lang/cpp/include/vortex/estimate.hpp:21 explicit Estimate(vx_estimate raw) noexcept
lang/cpp/include/vortex/array.hpp:144 / src/array.cpp:191 Array::nullable() const noexcept
lang/cpp/include/vortex/scan.hpp:36 PullRange::iterator::operator*() const noexcept
lang/cpp/include/vortex/scan.hpp:46 PullRange::iterator::operator==(std::default_sentinel_t) const noexcept
lang/cpp/include/vortex/scan.hpp:55 PullRange(Source&) noexcept
lang/cpp/include/vortex/scan.hpp:60 PullRange::end() noexcept
lang/cpp/include/vortex/scan.hpp:112 Partition::batches() & noexcept
lang/cpp/include/vortex/scan.hpp:223 Scan::partitions() & noexcept

For PullRange's default iterator constructor, noexcept is also appropriate.
Its constructor taking std::optional<Item> can be conditional:

iterator(Source* src, std::optional<Item> first)
    noexcept(std::is_nothrow_move_constructible_v<std::optional<Item>>);

The private raw-handle adopting constructors are also safe to annotate, for
consistency:

  • Array(const vx_array*)
  • DataType(const vx_dtype*)
  • Expression(const vx_expression*)
  • Scalar(vx_scalar*)
  • Writer(vx_array_sink*)
  • DataSource(const vx_data_source*, Session)
  • Partition(vx_partition*, Session)
  • ArrowStream(Session, ArrowArrayStream)
  • all four view constructors

Scan(vx_scan*, Estimate, Session) is the exception: it uses
std::make_unique<std::mutex>(), so it can allocate and must remain potentially
throwing.

Candidates that need an FFI contract decision first

These are non-allocating in the current implementation, but call Rust functions
declared extern "C-unwind":

  • Array::is_primitive(PType) const
  • Scalar::is_null() const
  • Validity copy constructor and copy assignment

They could become noexcept only if the FFI contract explicitly guarantees that
valid wrapper inputs cannot panic or unwind. Otherwise, leave them
unannotated.

Things that look like accessors but should not be noexcept

Function Why
Array::size() vx_array_len dereferences through a panic-on-null FFI helper; a moved-from Array has a null handle.
Array::has_dtype() A valid internal Union or Variant dtype can panic while converting to the FFI dtype variant.
DataType::variant() Same Union/Variant conversion panic path.
DataType::nullable() Uses a panic-on-null FFI helper on a moved-from object.
DataSource::row_count() FFI dereferences a null handle and dispatches through a data-source trait.
DataType::primitive_type() Panics for non-primitive dtypes.
decimal_precision() / decimal_scale() Panic for non-decimal dtypes.
fixed_size_list_size() Panic for a non-fixed-size-list dtype.
PrimitiveView<bool>::value() Panics on an out-of-bounds index.
Array::dtype(), DataSource::dtype(), Scalar::dtype() Their FFI implementations allocate owning wrapper handles.
Copy constructors and assignments of owning wrapper types FFI cloning allocates wrapper storage and moved-from values can produce null-handle panic paths.
dtype::*, scalar::of, expression constructors/operators FFI allocation paths, and several have error or panic routes.
begin() / operator++() on PullRange They call next() / next_partition(), which can throw VortexException.

The destructors written without noexcept, such as ~Validity(),
~ValidityBits(), and ~ArrowStream(), are already implicitly
noexcept(true) in this design. Adding the spelling would be documentation
only.

Recommendation

Make the high-confidence annotations now, but first fix the FFI panic paths
before treating the remaining accessors as no-fail. In particular, moved-from
wrapper behavior needs an explicit policy: either guard null handles and
return or throw normally, or document every non-move operation as invalid after
move. The former gives a much better basis for adding noexcept to simple
predicates and accessors.

@myrrc

myrrc commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

+1, I've removed noexcept everywhere except move constructors and free functions.

Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@myrrc
myrrc requested a review from 0ax1 July 14, 2026 13:31
Comment thread lang/cpp/src/scalar.cpp Outdated
Comment thread lang/cpp/src/array.cpp Outdated
Comment thread vortex-ffi/src/array.rs
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@0ax1

0ax1 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Almost there! 🤝

@myrrc
myrrc disabled auto-merge July 14, 2026 13:58
@myrrc
myrrc requested a review from 0ax1 July 14, 2026 14:10
Comment thread lang/cpp/CMakeLists.txt
Comment thread lang/cpp/CMakeLists.txt
Comment thread lang/cpp/CMakeLists.txt
Comment thread lang/cpp/CMakeLists.txt
Comment thread lang/cpp/CMakeLists.txt
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
@myrrc
myrrc enabled auto-merge (squash) July 14, 2026 14:29
@myrrc
myrrc requested a review from 0ax1 July 14, 2026 14:52
@myrrc
myrrc merged commit 56dffcc into develop Jul 14, 2026
111 of 112 checks passed
@myrrc
myrrc deleted the myrrc/cxx2-code branch July 14, 2026 16:16
@myrrc myrrc mentioned this pull request Jul 15, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature lang/cpp Relates to the Vortex C++ API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants