mobiusklein commented on code in PR #257: URL: https://github.com/apache/arrow-dotnet/pull/257#discussion_r2838908869
########## src/Apache.Arrow.Operations/Comparison.cs: ########## @@ -0,0 +1,390 @@ +// 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; +using System.Numerics; +using Apache.Arrow; +using Apache.Arrow.Memory; +using Apache.Arrow.Types; + +namespace Apache.Arrow.Operations; + +public static class Comparison +{ + /// <summary> + /// Negate a boolean array, flipping true to false, false to true. Nulls remain null + /// </summary> + /// <param name="mask"></param> + /// <param name="allocator"></param> + /// <returns></returns> + public static BooleanArray Invert(BooleanArray mask, MemoryAllocator? allocator = null) + { + var builder = new BooleanArray.Builder(); + builder.Reserve(mask.Length); + foreach (var val in mask) Review Comment: Thank you. There's a lot of possible optimizations, some of which are probably beyond the scope of this first writing. I'll look into the bit inversion methods, although I am not familiar enough with the consequences of using the SIMD types. > it can be copied as-is (we don't have a way to share buffers, unfortunately) @CurtHagenlocher could you please expand on what you mean by this? Is it that an array assumes it is the unique owner of its value and validity buffer and might mutate them directly? -- 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]
