pitrou commented on a change in pull request #11127:
URL: https://github.com/apache/arrow/pull/11127#discussion_r707552193



##########
File path: cpp/src/arrow/compute/kernels/vector_nested_test.cc
##########
@@ -51,6 +54,33 @@ TEST(TestVectorNested, ListFlattenChunkedArray) {
   }
 }
 
+TEST(TestVectorNested, ListFlattenFixedSizeList) {
+  for (auto ty : {fixed_size_list(int16(), 2), fixed_size_list(uint32(), 2)}) {
+    const auto& out_ty = checked_cast<const 
FixedSizeListType&>(*ty).value_type();
+    {
+      auto input = ArrayFromJSON(ty, "[[0, null], null, [2, 3], [0, 42]]");
+      auto expected = ArrayFromJSON(out_ty, "[0, null, 2, 3, 0, 42]");
+      CheckVectorUnary("list_flatten", input, expected);
+
+      // Construct a list with a non-empty null slot

Review comment:
       For a fixed size list, this doesn't test anything special ;-)

##########
File path: cpp/src/arrow/compute/kernels/vector_nested_test.cc
##########
@@ -82,5 +112,31 @@ TEST(TestVectorNested, ListParentIndicesChunkedArray) {
   }
 }
 
+TEST(TestVectorNested, ListParentIndicesFixedSizeList) {
+  for (auto ty : {fixed_size_list(int16(), 2), fixed_size_list(uint32(), 2)}) {
+    {
+      auto input = ArrayFromJSON(ty, "[[0, null], null, [1, 2], [3, 4], [null, 
5]]");
+      auto expected = ArrayFromJSON(int32(), "[0, 0, 2, 2, 3, 3, 4, 4]");
+      CheckVectorUnary("list_parent_indices", input, expected);
+
+      // Construct a list with a non-empty null slot

Review comment:
       Same here.

##########
File path: cpp/src/arrow/array/array_nested.h
##########
@@ -292,6 +292,13 @@ class ARROW_EXPORT FixedSizeListArray : public Array {
     return values_->Slice(value_offset(i), value_length(i));
   }
 
+  /// \brief Return an Array that is a concatenation of the lists in this 
array.
+  ///
+  /// Note that it's different from `values()` in that it takes into
+  /// consideration null elements (they are skipped, thus copying may be 
needed).
+  Result<std::shared_ptr<Array>> Flatten(
+      MemoryPool* memory_pool = default_memory_pool()) const;

Review comment:
       Can you add a test for this method?

##########
File path: cpp/src/arrow/compute/kernels/vector_nested.cc
##########
@@ -76,6 +76,24 @@ struct ListParentIndicesArray {
 
   Status Visit(const LargeListType& type) { return VisitList(type); }
 
+  Status Visit(const FixedSizeListType& type) {
+    const int32_t slot_length = type.list_size();
+    const int64_t values_length = slot_length * (input->length - 
input->GetNullCount());
+    ARROW_ASSIGN_OR_RAISE(auto indices, ctx->Allocate(values_length * 
sizeof(int32_t)));
+    int32_t* out_indices = reinterpret_cast<int32_t*>(indices->mutable_data());
+    const uint8_t* bitmap = input->GetValues<uint8_t>(0, 0);
+    for (int32_t i = 0; i < input->length; i++) {
+      if (!bitmap || BitUtil::GetBit(bitmap, input->offset + i)) {
+        std::fill(out_indices, out_indices + slot_length,

Review comment:
       Also, if you wanted to do that, it would be much better to call 
`VisitSetBitRuns`...




-- 
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]


Reply via email to