mobiusklein commented on code in PR #257: URL: https://github.com/apache/arrow-dotnet/pull/257#discussion_r2920376732
########## 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: Yes, there would be. I had a hard time reading this implementation though, as it reaches into the internals of `ArrayData`, which don't think I have a good grasp of yet. I wrote the span slicing approach I did because it let me reliably delegate all that to the library. It's not obvious, either, from reading your visitor what types it _doesn't_ support? -- 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]
