CurtHagenlocher commented on code in PR #41144:
URL: https://github.com/apache/arrow/pull/41144#discussion_r1561019969


##########
csharp/src/Apache.Arrow/Arrays/ArrayData.cs:
##########
@@ -125,5 +155,69 @@ public ArrayData Clone(MemoryAllocator allocator = default)
                 Children?.Select(b => b.Clone(allocator))?.ToArray(),
                 Dictionary?.Clone(allocator));
         }
+
+        private int ComputeNullCount()
+        {
+            if (DataType.TypeId == ArrowTypeId.Union)
+            {
+                return ((UnionType)DataType).Mode switch
+                {
+                    UnionMode.Sparse => ComputeSparseUnionNullCount(),
+                    UnionMode.Dense => ComputeDenseUnionNullCount(),
+                    _ => throw new InvalidOperationException("unknown union 
mode in null count computation")
+                };
+            }
+
+            if (Buffers == null || Buffers.Length == 0 || Buffers[0].IsEmpty)
+            {
+                return 0;
+            }
+
+            // Note: Dictionary arrays may be logically null if there is a 
null in the dictionary values,
+            // but this isn't accounted for by the IArrowArray.IsNull 
implementation,
+            // so we maintain consistency with that behaviour here.
+
+            return Length - BitUtility.CountBits(Buffers[0].Span, Offset, 
Length);
+        }
+
+        private int ComputeSparseUnionNullCount()

Review Comment:
   Is it worth moving these as statics onto SparseUnionArray and 
DenseUnionArray respectively so that the type-specific logic remains in one 
place?



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