voidstar69 commented on code in PR #41539:
URL: https://github.com/apache/arrow/pull/41539#discussion_r1597187017


##########
csharp/src/Apache.Arrow/Arrays/BinaryArray.cs:
##########
@@ -380,5 +380,40 @@ public ReadOnlySpan<byte> GetBytes(int index, out bool 
isNull)
         }
 
         IEnumerator IEnumerable.GetEnumerator() => 
((IEnumerable<byte[]>)this).GetEnumerator();
+
+        int ICollection<byte[]>.Count => Length;
+        bool ICollection<byte[]>.IsReadOnly => true;
+        void ICollection<byte[]>.Add(byte[]? item) => throw new 
NotSupportedException("Collection is read-only.");
+        bool ICollection<byte[]>.Remove(byte[]? item) => throw new 
NotSupportedException("Collection is read-only.");
+        void ICollection<byte[]>.Clear() => throw new 
NotSupportedException("Collection is read-only.");
+
+        bool ICollection<byte[]>.Contains(byte[] item)
+        {
+            for (int index = 0; index < Length; index++)
+            {
+                var foo = GetBytes(index);
+                if(IsSpanDataEqual(foo, item))
+                //if (foo == item)
+                    return true;
+            }
+
+            return false;
+        }
+
+        private static bool IsSpanDataEqual(ReadOnlySpan<byte> span1, 
ReadOnlySpan<byte> span2)
+        {
+            if (span1.Length != span2.Length)

Review Comment:
   Initially I started implementing a `for` loop in this method, then I 
realised that the `SequenceEqual` method would get the job done. The comparison 
above was to ensure that the `for` loop could run for the length of `span1` 
without checking/blowing up on accesses into `span2`.
   
   I will remove this extra comparison.



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