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

Access SampleInfo from async reader interface #298

Open
samcarey opened this issue Oct 2, 2023 · 1 comment
Open

Access SampleInfo from async reader interface #298

samcarey opened this issue Oct 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@samcarey
Copy link

samcarey commented Oct 2, 2023

Using the async interface, as in the examples:

let mut datareader_stream = reader.async_sample_stream();

This stream produces samples with no metadata (SampleInfo) using the take_bare method internally instead of take.
Is there a way to access the SampleInfo using the async interface, or do I need to resort to synchronously calling take on the reader directly?

Is there a reason that the async interface currently strips the metadata? Performance I'm guessing?
It seems like a more versatile interface would expose the metadata and let the user choose to ignore it.
Or perhaps two interfaces could exist, one that provides metadata and one that doesn't?

@jhelovuo
Copy link
Owner

jhelovuo commented Oct 7, 2023

This stream produces samples with no metadata (SampleInfo) using the take_bare method internally instead of take.
Is there a way to access the SampleInfo using the async interface, or do I need to resort to synchronously calling take on the reader directly?

No. You need to use the synchronous API.

Is there a reason that the async interface currently strips the metadata? Performance I'm guessing?

Performance and lazy development. You are the first one to come up with a use case of async + metadata.

Our main use case is ROS 2, and that does not use the metadata at all.

Performancewise, a full DataReader (as opposed to SimpleDataReader) needs to maintain a DataSampleCache to generate the various metadata items, and that requires some memory + CPU, even if no-one ever uses the metadata.

It seems like a more versatile interface would expose the metadata and let the user choose to ignore it.
Or perhaps two interfaces could exist, one that provides metadata and one that doesn't?

The correct solution here would be to provide an alternative interface. If you want to try to implement that, then that should be reasonably straightforward. I would start from making a copy of the current async machinery for the DataReader and just replacing its SimpleDataReader with a full version, and using .take() instead of .take_bare() and seeing how far that would get me. Please make a PR if you choose to try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants