enhance: [2.5] Avoid stringtoslicebytes copy for BatchPKExists (#40097)

Cherry-pick from master
pr: #40096 
Using unsafe.Slice to convert string to []byte by directly using
underlying data could avoid lots of copy and cpu time

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-02-21 21:41:21 +08:00 committed by GitHub
parent 0caad5fe37
commit 898606ae4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,7 @@ package storage
import (
"fmt"
"unsafe"
"github.com/cockroachdb/errors"
"github.com/samber/lo"
@ -119,7 +120,7 @@ func Locations(pk PrimaryKey, k uint, bfType bloomfilter.BFType) []uint64 {
return bloomfilter.Locations(buf, k, bfType)
case schemapb.DataType_VarChar:
varCharPk := pk.(*VarCharPrimaryKey)
return bloomfilter.Locations([]byte(varCharPk.Value), k, bfType)
return bloomfilter.Locations(unsafe.Slice(unsafe.StringData(varCharPk.Value), len(varCharPk.Value)), k, bfType)
default:
// TODO::
}