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

Implement DataAPI #92

Merged
merged 1 commit into from
Jul 23, 2019
Merged

Implement DataAPI #92

merged 1 commit into from
Jul 23, 2019

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented May 8, 2019

No description provided.

"""
Tables.allocatecolumn(::Type{T}, len) => returns a column type (usually AbstractVector) w/ size to hold `len` elements

Custom column types can override with an appropriate "scalar" element type that should dispatch to their column allocator.
"""
allocatecolumn(T, len) = Vector{T}(undef, len)
allocatecolumn(T, len) = DataAPI.defaultarray(T, 1)(undef, len)
Copy link
Member

Choose a reason for hiding this comment

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

Should defaultarray replace allocatecolumn at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

they're slightly different; defaultarray just returns the array type for a given scalar type; allocatecolumn is for actually creating a column. We can probably just replace uses of allocatecolumn with defaultarray(T)(undef, len)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what I had in mind.


Base.@pure function nondatavaluetype(::Type{NT}) where {NT <: NamedTuple{names}} where {names}
TT = Tuple{Any[ nondatavaluetype(fieldtype(NT, i)) for i = 1:fieldcount(NT) ]...}
DataAPI.nondatavaluetype(::Type{T}) where {T} = T
Copy link
Member

Choose a reason for hiding this comment

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

I know that this function is documented to be owned by Tables.jl, but given how simple this fallback definition is, why not put it in DataAPI instead? That would be simpler for everybody.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fair.

@quinnj quinnj merged commit 9426eac into master Jul 23, 2019
@quinnj quinnj deleted the jq/dataapi branch July 23, 2019 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants