zeroshade commented on code in PR #1352:
URL: https://github.com/apache/arrow-go/pull/1352#discussion_r4257846018


##########
arrow/compute/dictionary_filter_bench_test.go:
##########
@@ -0,0 +1,149 @@
+// 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.
+
+//go:build go1.24
+
+package compute_test
+
+import (
+       "context"
+       "fmt"
+       "testing"
+
+       "github.com/apache/arrow-go/v18/arrow"
+       "github.com/apache/arrow-go/v18/arrow/array"
+       "github.com/apache/arrow-go/v18/arrow/compute"
+       "github.com/apache/arrow-go/v18/arrow/memory"
+)
+
+var dictionaryFilterBenchmarkOutputLength int
+
+func BenchmarkFilterDictionaryIndices(b *testing.B) {
+       patterns := []struct {
+               name       string
+               selected   func(int) bool
+               indexNull  func(int) bool
+               filterNull func(int) bool
+               nullSelect compute.NullSelectionBehavior
+       }{
+               {name: "random10", selected: func(i int) bool { return 
dictionaryFilterSelect(i, 10) }},
+               {name: "random50", selected: func(i int) bool { return 
dictionaryFilterSelect(i, 50) }},
+               {name: "random90", selected: func(i int) bool { return 
dictionaryFilterSelect(i, 90) }},
+               {name: "alternating", selected: func(i int) bool { return i%2 
== 0 }},
+               {name: "clustered50", selected: func(i int) bool { return 
(i/4096)%2 == 0 }},
+               {
+                       name:       "nullable-indices-random50",

Review Comment:
   The nullable-index and nullable-filter benchmark cases are now present, but 
the PR description still has no before/after results requested in the two 
previous reviews. Please include comparable measurements for nullable indices, 
nullable `DropNulls`, and `EmitNulls`, with the base/head revisions and 
environment.



##########
arrow/compute/selection.go:
##########
@@ -540,32 +539,33 @@ func structFilter(ctx *exec.KernelCtx, batch 
*exec.ExecSpan, out *exec.ExecResul
 // The shared dictionary is reused as-is and never compacted, so the result 
may retain values
 // that are no longer referenced by any index.
 func dictionaryFilter(ctx *exec.KernelCtx, batch *exec.ExecSpan, out 
*exec.ExecResult) error {
-       // convert the filter (boolean array) to indices to take from the 
dictionary array.
-       indices, err := kernels.GetTakeIndices(exec.GetAllocator(ctx.Ctx),
-               &batch.Values[1].Array, 
ctx.State.(kernels.FilterState).NullSelection)
-       if err != nil {
-               return err
+       filterState := ctx.State.(kernels.FilterState)
+       if batch.Values[0].Array.UpdateNullCount() > 0 ||

Review Comment:
   Blocking: `UpdateNullCount()` changes the executor-reused span, and 
`SetSlice` preserves a cached `Nulls == 0` when advancing to a later slice. 
With `ChunkSize=1`, dictionary indices `[0, null, 1]` and mask `[true, true, 
true]` produce `[0, 0, 1]` under both null-selection modes; the filter-side 
call likewise makes `DropNulls` retain a null mask entry when its underlying 
value bit is set. Checked-allocator repros fail with the default and `noasm` 
builds, but pass when this kernel uses the original take-only path. Please 
avoid persisting slice-local null counts in the reused spans and add 
null-free-then-nullable execution-slice coverage.



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