[
https://issues.apache.org/jira/browse/ARROW-15089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17476125#comment-17476125
]
David Li commented on ARROW-15089:
----------------------------------
* MapArray is of type MapType. Types are not values in our type system :)
MapType[K, V] is equivalent to List[Struct[key: K, value: V]]. Hence it looks
something like this: {{[[\{"key": "k", "value": 0}, \{"key": "foo", "value":
42}], [\{"key": "bar", "value": 32}]]}} for {{{}MapType[Utf8, Int64]{}}}.
* The parameters should be passed via an options class (e.g. see
StructFieldOptions) containing a Scalar:
[https://github.com/apache/arrow/blob/master/cpp/src/arrow/scalar.h]
* There's not really a difference, there's no uniform structure for kernels
other than ultimately a kernel is a function call with a specific signature.
Different kernels are implemented differently. CC [~edponce] who was
categorizing/trying to make consistent these things.
* They return a combined array, yes. This is due to the layout of ListArray
and StructArray. A ListArray doesn't have one child array per list, but rather
stores one child array and a list of offsets that mark the lists. A StructArray
stores one child array per struct field (i.e. it's columnar, not row-wise).
Iterating through the keys in that array would work, but you also need to keep
track of which list you are looking at, and decide what to do about duplicate
keys (since this will affect the return type).
> [C++] Add compute kernel to get MapArray value for given key
> ------------------------------------------------------------
>
> Key: ARROW-15089
> URL: https://issues.apache.org/jira/browse/ARROW-15089
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C++
> Affects Versions: 6.0.1
> Reporter: Will Jones
> Assignee: Dhruv Vats
> Priority: Major
> Labels: C++, Kernels, beginner, compute, good-second-issue,
> kernel
>
> Given a "map", an obvious operation is to get an item corresponding to a key.
> The idea here is to create a kernel that does this for each map in the array.
> IIRC MapArray isn't guaranteed to have unique keys. So one version would
> return an array of ItemType by returning the first of last item for a given
> key. Yet another version could return a ListType containing all matching
> items.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)