amol- commented on code in PR #44447:
URL: https://github.com/apache/arrow/pull/44447#discussion_r1875841135


##########
cpp/src/arrow/array/util.cc:
##########
@@ -915,6 +917,71 @@ Result<std::shared_ptr<Array>> 
MakeEmptyArray(std::shared_ptr<DataType> type,
   return builder->Finish();
 }
 
+Result<std::shared_ptr<Array>> MakeMaskArray(const std::vector<int64_t>& 
indices,
+                                             int64_t length, MemoryPool* pool) 
{
+  ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBitmap(length, pool));
+  bit_util::SetBitsTo(buffer->mutable_data(), 0, length, false);
+  for (int64_t index : indices) {
+    if (index < 0 || index >= length) {
+      return Status::IndexError("Index out of bounds: ", index);
+    }
+    bit_util::SetBit(buffer->mutable_data(), index);
+  }
+  return std::make_shared<BooleanArray>(length, buffer);
+}
+
+template <typename IndexType>
+Result<std::shared_ptr<Array>> MakeMaskArrayImpl(
+    const std::shared_ptr<NumericArray<IndexType>>& indices, int64_t length,
+    MemoryPool* pool) {
+  ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBitmap(length, pool));
+  bit_util::SetBitsTo(buffer->mutable_data(), 0, length, false);
+  for (int64_t i = 0; i < indices->length(); ++i) {
+    int64_t index = indices->Value(i);

Review Comment:
   The outer MakeMaskArray function already prevents values from being null, 
that's why it's not done in the Impl again.



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