Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37562: [Ruby] Add support for table.each_raw_record.to_a #37600

Merged
merged 7 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ruby/red-arrow/ext/arrow/raw-records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ namespace red_arrow {
}

VALUE
record_batch_each_raw_record(VALUE rb_record_batch){
record_batch_each_raw_record(VALUE rb_record_batch) {
auto garrow_record_batch = GARROW_RECORD_BATCH(RVAL2GOBJ(rb_record_batch));
auto record_batch = garrow_record_batch_get_raw(garrow_record_batch).get();
RETURN_SIZED_ENUMERATOR(rb_record_batch, 0, 0, record_batch->num_rows());
Copy link
Member

Choose a reason for hiding this comment

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

We should use nullptr for a null pointer in C++:

Suggested change
RETURN_SIZED_ENUMERATOR(rb_record_batch, 0, 0, record_batch->num_rows());
RETURN_SIZED_ENUMERATOR(rb_record_batch, 0, nullptr, record_batch->num_rows());

Copy link
Contributor Author

@otegami otegami Sep 11, 2023

Choose a reason for hiding this comment

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

Thank you so much!
fix: 3563046

 * @param[in]  argc     Number of objects of `argv`.
 * @param[in]  argv     Arguments passed to the current method.

We can pass the 0 to argc because it is literally the number of objects of argv.
On the other hand, we cannot pass the 0. to argv because we want to say there is no passed method pointer.
https://github.com/ruby/ruby/blob/05aaff2191cbe777d1efb915ab9652eeaa1c16b8/include/ruby/internal/intern/enumerator.h#L201C4-L202


try {
RawRecordsProducer producer;
Expand All @@ -323,6 +324,7 @@ namespace red_arrow {
table_each_raw_record(VALUE rb_table) {
auto garrow_table = GARROW_TABLE(RVAL2GOBJ(rb_table));
auto table = garrow_table_get_raw(garrow_table).get();
RETURN_SIZED_ENUMERATOR(rb_table, 0, 0, table->num_rows());

try {
RawRecordsProducer producer;
Expand Down
Loading