Skip to content

Commit 9709a15

Browse files
authored
Document requirements for the refpool return value (#24)
Without supporting `keys` and related functions, `refpool` is useless. In practice, experience from DataFrames and Arrow shows that the object should be iterable (otherwise one would need to collect it to a vector before passing it to many functions) and support `eltype`. Also document that equality refers to `isequal` and that the object is supposed to be of the same type as the original, which was previously implied by "is the appropriate *original* value" without being explicit.
1 parent 2007174 commit 9709a15

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/DataAPI.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ refvalue(A::AbstractArray, x) = x
5252
5353
Whenever available, return an indexable object `pool` such that, given the *original* array `A` and
5454
a "ref value" `x` taken from `refarray(A)`, `pool[x]` is the appropriate *original* value. Return
55-
`nothing` if such object is not available. If `refpool(A)` is not `nothing`, then
56-
`refpool(A)[refarray(A)[I...]]` must be equal to `A[I...]`.
55+
`nothing` if such object is not available.
5756
5857
By default, `refpool(A)` returns `nothing`.
5958
59+
If `refpool(A)` is not `nothing`, then `refpool(A)[refarray(A)[I...]]`
60+
must be equal to (according to `isequal`) and of the same type as `A[I...]`,
61+
and the object returned by `refpool(A)` must implement the iteration and
62+
indexing interfaces as well as the `length`, `eachindex`, `keys`, `values`, `pairs`,
63+
`firstindex`, `lastindex`, and `eltype` functions
64+
in accordance with the `AbstractArray` interface.
65+
6066
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
6167
default definition.
6268
"""

0 commit comments

Comments
 (0)