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

[C++] RecordBatchReader should support STL-like iteration #29300

Closed
asfimport opened this issue Aug 18, 2021 · 12 comments
Closed

[C++] RecordBatchReader should support STL-like iteration #29300

asfimport opened this issue Aug 18, 2021 · 12 comments

Comments

@asfimport
Copy link

Our custom Iterator<T> has support for STL-like iteration (allowing natural for loops), but RecordBatchReader doesn't. Adding STL-like iteration would be a significant quality of life improvement for developers

Reporter: Antoine Pitrou / @pitrou
Assignee: Dhruv Vats / @dhruv9vats

PRs and other links:

Note: This issue was originally created as ARROW-13663. Please see the migration documentation for further details.

@asfimport
Copy link
Author

Dhruv Vats / @dhruv9vats:
May I give this is a shot?

@asfimport
Copy link
Author

Neal Richardson / @nealrichardson:
Go for it! If no one has assigned themselves to the issue, it's generally fair game. I've assigned it to you now.

@asfimport
Copy link
Author

Dhruv Vats / @dhruv9vats:
From what I understand, to support STL-like iteration, the following operators will have to be overloaded:

++ (increment) (also decrement?)

* (dereference)

!= (inequality)

== (equality)

right?

 

Also, I'm trying to find my way through the code; in this context, could some basic guidelines be provided? Like how should this functionality be implemented? Whether to use a nested class like in the case of {}Iterator<T>{}, or some other way?

 

Sorry if I'm overlooking something obvious.

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
Yes, a nested class sounds fine. You can just try to reuse what was done for Iterator<T>.

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
@dhruv9vats If you face any problem trying to implement this, please don't hesitate to mention!

@asfimport
Copy link
Author

Dhruv Vats / @dhruv9vats:
Hey @pitrou,

Extremely sorry for the delay. Was caught up in unavoidable school work but am now actively working on this and will keep you posted. 

Apologies again.

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
It's fine, I just wanted to make sure you're still interested :-)

@asfimport
Copy link
Author

Dhruv Vats / @dhruv9vats:
Because the RecordBatchReader is an abstract class, is there a straightforward way to define STL like iterators for it?

I tried using {}shared_ptr as given in Iterator<T>{}, but can't use them as the class is abstract. Does something like shared_from_this() have to be used? @pitrou  

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
Given the typical usage of STL iterators (i.e. mostly local and synchronous), I think the iterator can simply be non-owning, so you only need a raw pointer to the {}RecordBatchReader{}.  @bkietz  What do you think?

@asfimport
Copy link
Author

Dhruv Vats / @dhruv9vats:
Sorry for all the delay. Written theory exams should not exist anymore.

Does the basic structure in the PR look correct? 

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
Yes, the basic structure looks ok. You'll probably need to add some tests before I review it.

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
Issue resolved by pull request 11946
#11946

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant