quinnj commented on code in PR #493:
URL: https://github.com/apache/arrow-julia/pull/493#discussion_r1428703277
##########
src/ArrowTypes/src/ArrowTypes.jl:
##########
@@ -170,11 +170,15 @@ overload is necessary.
A few `ArrowKind`s have/allow slightly more custom overloads for their
`fromarrow` methods:
* `ListKind{true}`: for `String` types, they may overload
`fromarrow(::Type{T}, ptr::Ptr{UInt8}, len::Int) = ...` to avoid
materializing a `String`
- * `StructKind`: must overload `fromarrow(::Type{T}, x...)` where individual
fields are passed as separate
+ * `StructKind`:
+ * May overload `fromarrow(::Type{T}, x...)` where individual fields are
passed as separate
positional arguments; so if my custom type `Interval` has two fields
`first` and `last`, then I'd overload like
`ArrowTypes.fromarrow(::Type{Interval}, first, last) = ...`. Note the
default implementation is
`ArrowTypes.fromarrow(::Type{T}, x...) = T(x...)`, so if your type
already accepts all arguments in a constructor
no additional `fromarrow` method should be necessary (default struct
constructors have this behavior).
+ * Alternatively, may overload `fromarrowstruct(::Type{T}, ::Val{fnames},
x...)`, where `fnames` is a tuple of the
Review Comment:
Sorry to be so slow in the review here; it might be worth adding another
example the docs here like we have above, something like:
```
So taking the example from before, if my arrow data happens to have the
`first` and `last` fields for my `Interval` type reversed, I could implement
`fromarrowstruct(::Type{Interval}, ::Val{(last, first}), last, first) =
Interval(first, last)`
```
I find concrete examples usually help drive home the core point of a new
feature.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]