MCPcopy Create free account
hub / github.com/apache/arrow / ListValueLength

Function ListValueLength

cpp/src/arrow/compute/kernels/scalar_nested.cc:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43template <typename Type, typename offset_type = typename Type::offset_type>
44Status ListValueLength(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
45 const ArraySpan& arr = batch[0].array;
46 ArraySpan* out_arr = out->array_span_mutable();
47 auto out_values = out_arr->GetValues<offset_type>(1);
48 if (is_list_view(*arr.type)) {
49 const auto* sizes = arr.GetValues<offset_type>(2);
50 if (arr.length > 0) {
51 memcpy(out_values, sizes, arr.length * sizeof(offset_type));
52 }
53 } else {
54 const offset_type* offsets = arr.GetValues<offset_type>(1);
55 // Offsets are always well-defined and monotonic, even for null values
56 for (int64_t i = 0; i < arr.length; ++i) {
57 *out_values++ = offsets[i + 1] - offsets[i];
58 }
59 }
60 return Status::OK();
61}
62
63Status FixedSizeListValueLength(KernelContext* ctx, const ExecSpan& batch,
64 ExecResult* out) {

Callers

nothing calls this directly

Calls 2

is_list_viewFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected