-
Notifications
You must be signed in to change notification settings - Fork 9
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
Meta-programming tools and arrow types traits support. #49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A first pass.
include/sparrow/data_type.hpp
Outdated
, float32_t | ||
, float64_t | ||
, std::string | ||
//, std::vector<std::byte> // REVIEW should this be uint8_t? char? buffer<unit8_t>? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that we have used uint8_t
over std::byte
for the buffer.
Is uint8_t
use for interoperability with C, or are there other reason not to use std::byte
?
Also, if we use uint8_t
we must:
static_assert(CHAR_BIT == 8);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main "classic" issue is that because std::byte
has a strong type, not implicitly converted to other similar types, it's not automatically compatible with functions working with char
or char-like types, in particular when interfacing with C. Lots of explicit casts ensures. Not a big problem if you like correctness but it does obfuscate the code. It's the main criticism I'm aware of.
In this library, I'm not sure what would be best, but the C api kinds of forces us with at least some of the types?
Also, if we use uint8_t we must:
hmm actually shouldnt we always check that? I'll add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think, @JohanMabille?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C Api uses void*
for the buffers, so we'll have to cast anyway. I would actually be in favor of replacing the uint8_t
with byte
in the array_data buffers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I went with an alias byte_t
so that we can change that easilly, and added vector<byte_t>
and I suppose we'll see how it goes from here.
8343468
to
449f206
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks neat to me!
I have few comments and questions.
include/sparrow/data_type.hpp
Outdated
, float32_t | ||
, float64_t | ||
, std::string | ||
//, std::vector<std::byte> // REVIEW should this be uint8_t? char? buffer<unit8_t>? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think, @JohanMabille?
- added various metaprogramming basic algorithms and tools; - added concepts to check arrow-supported types; - added `arrow_traits` to extract information about arrow-supported types, including custom ones; - related tests. - added `float16_t` support, using copy-pasted dependency in C++20, standard library in C++23
Co-authored-by: Julien Jerphanion <[email protected]>
Co-authored-by: Julien Jerphanion <[email protected]>
Co-authored-by: Julien Jerphanion <[email protected]>
…valuate` is enough.
Co-authored-by: Julien Jerphanion <[email protected]> Co-authored-by: Alexis Placet <[email protected]>
b82e382
to
67b4769
Compare
LGTM except the minor comment I left. |
or | ||
requires(std::decay_t<P> predicate) | ||
{ | ||
{ predicate(std::type_identity_t<T>{}) } -> std::convertible_to<bool>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why we need to support both type_identity_t
and typelist
.Would the support of type_identity
be enough? It looks like predicates will be evaluated over types in a typelist via the evaluate
function, resulting in a pattern like (evaluate<T> OP ... OP init)
; therefore evaluate
could accept type_identity_t
only and that would simplify the code. But as always when I have this feeling, I probably missed something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why we need to support both type_identity_t and typelist.
I started with typelist
because that's what the algorithms in this PR work with as argument, to not deviate too far. The support for type_identity
you suggested simply allows for code taht dont depend on sparrow to still add new type-predicates as callable objects.
Would the support of type_identity be enough?
Both are fine to me, or do you see a cost I'm not seeing?
It looks like predicates will be evaluated over types in a typelist via the evaluate function, resulting in a pattern like (evaluate OP ... OP init); therefore evaluate could accept type_identity_t only and taht would simplify the code. But as always when I have this feeling, I probably issed something.
No you're right, both typelist and type_identity works here so I support both and other than the potential extension without being dependent on sparrow, it would indeed simplify some of the code.
Not sure what to do here. I have a slight preference toward supporting "anything that can act as a type wrapper" so that's why I switched to using the mpl::type_wrapper
concept instead of being too specific. The implementations of the algorithms could be rewritten with any type wrappers.
Choices. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are fine to me, or do you see a cost I'm not seeing?
Not really, it was really for simplifying the code. Also concepts with or clauses don't subsume, but I guess it's not really importnat here since we'll probably won'r refine the callable_type_predicate
concept.
I would say let's keep it as is for now, and use it. And we'll see later if we can really simplify it (if that's really worth it, and it it does not break any code using it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Minor suggestion which need not be adressed: we could reference the thread of discussions so that we can more easily refer to them in the future.
Fix #67
Fix #68
Part of the effort for #15
arrow_traits
to extract information about arrow-supported types, including custom ones;float16_t
support, using copy-pasted dependency in C++20, standard library in C++23