adamreeve commented on code in PR #257:
URL: https://github.com/apache/arrow-dotnet/pull/257#discussion_r2838948945


##########
src/Apache.Arrow.Operations/Select.cs:
##########
@@ -0,0 +1,703 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System.Numerics;
+
+using Apache.Arrow;
+using Apache.Arrow.Memory;
+using Apache.Arrow.Types;
+
+namespace Apache.Arrow.Operations;
+
+public static class Select
+{
+    /// <summary>
+    /// Returns a copy of the positions in the array where the mask is true. 
All other values in the array will be
+    /// excluded.
+    ///
+    /// This internally reduces to building a true-value run index map and 
calling `Take`
+    /// </summary>
+    /// <param name="array">The array to select from</param>
+    /// <param name="mask">The mask defining which values to keep or 
exclude</param>
+    /// <param name="allocator">The memory allocator to build the new array 
from</param>
+    /// <returns></returns>
+    /// <exception cref="InvalidOperationException">If the mask and the array 
are not of equal size</exception>
+    public static Array Filter(Array array, BooleanArray mask, 
MemoryAllocator? allocator = null)

Review Comment:
   I haven't had a close look at this PR, but just wanted to mention that I've 
implemented the same operation at 
https://github.com/G-Research/ParquetSharp.Dataset/blob/main/ParquetSharp.Dataset/Filter/ArrayMaskApplier.cs.
   
   It's implemented as an `IArrowArrayVisitor` with specialized implementations 
for different array types. It might be worth benchmarking the two approaches? 
Your approach has the advantage of working for any array type that 
`ArrowArrayConcatenator` supports, but I suspect there might be a lot of 
overhead with that when you have a large number of spans.



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