Skip to content

Conversation

@XinyuZeng
Copy link
Contributor

@XinyuZeng XinyuZeng commented Aug 21, 2025

rationales described here: #4050 (comment) #4050 (comment)

@XinyuZeng XinyuZeng requested a review from 0ax1 August 21, 2025 08:52
@0ax1 0ax1 added the chore Release label indicating a trivial change label Aug 21, 2025
@codecov
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@0ax1 0ax1 mentioned this pull request Aug 21, 2025
Signed-off-by: Xinyu Zeng <xinyuzeng@tencent.com>
Comment on lines 24 to 29
ScanBuilder &&ScanBuilder::WithFilter(ExprType &&expr) && {
if constexpr (std::is_rvalue_reference_v<ExprType &&>) {
impl_->with_filter(std::forward<ExprType>(expr).IntoImpl());
} else {
impl_->with_filter_ref(std::forward<ExprType>(expr).Impl());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cxx does not support function overload (although I think technically it can do it), so we have to add separate ffi functions and do static dispatch here.

Copy link
Contributor

@0ax1 0ax1 Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the forwarding part is less important than the "reference collapsing" aspect such that the builder function can handle both rvalues and lvalues. Let's drop std::forward and a keep a single with_xyz not adding a ref version.

Just saw that you already added the ref versions. I think that looks good, even if a bit redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should drop std::forward and simply leave the overload variants for both rvalue and lvalue ref of Expr. I am working on that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are only two variants, and we still need specialization for both of them (to call the with_filter_ref ffi), then we do not need forward I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind taking a look at the modifications of my latest commit? I think it is cleaner

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are only two variants, and we still need specialization for both of them (to call the with_filter_ref ffi), then we do not need forward I think

Yes, this only works if the function we're forwarding to also supports r and l values. Thanks to C++ that's a silly amount of redudancy but this is fine for now. The most important part is that the API is hard to misuse now. We can iterate on making this more compact down the line.

Copy link
Contributor

@0ax1 0ax1 Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a second thought here also on whether C++23 might be ok to use so we could express this with reference collapsing and auto-deducing this in order to have a single func definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think C++ 20 may be ok but C++23 is too aggressive. As I know someone is still using C++17 (e.g., my current employer). Arrow-cpp recently had a vote to switch to 20 but it has not happened yet.

Signed-off-by: Xinyu Zeng <xinyuzeng@tencent.com>
Signed-off-by: Xinyu Zeng <xinyuzeng@tencent.com>
Copy link
Contributor

@0ax1 0ax1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @XinyuZeng

@0ax1 0ax1 merged commit fa89d6f into vortex-data:develop Aug 22, 2025
43 checks passed
@XinyuZeng XinyuZeng deleted the cxx_scanbuilder_fix branch August 22, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Release label indicating a trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants