mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
use translateIndexKeys instead of translateIndexKeySet in ImportValue()
This commit is contained in:
parent
efffa39c2c
commit
f001ad199f
1 changed files with 6 additions and 11 deletions
17
api.go
17
api.go
|
|
@ -1100,22 +1100,17 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest, opts .
|
|||
// Translate values when the field uses keys (for example, when
|
||||
// the field has a ForeignIndex with keys).
|
||||
if useKeys {
|
||||
keySet := make(map[string]struct{})
|
||||
for i := range req.StringValues {
|
||||
keySet[req.StringValues[i]] = struct{}{}
|
||||
}
|
||||
|
||||
// Perform a separate batch translation for each separate index used.
|
||||
keyMap := make(map[string]uint64)
|
||||
if keyMap, err = api.cluster.translateIndexKeySet(ctx, foreignIndexName, keySet); err != nil {
|
||||
// Perform translation.
|
||||
uints, err := api.cluster.translateIndexKeys(ctx, foreignIndexName, req.StringValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Because the BSI field supports negative values, we have to
|
||||
// convert the uint64 keys to a slice of int64.
|
||||
ints := make([]int64, len(req.StringValues))
|
||||
for i := range req.StringValues {
|
||||
ints[i] = int64(keyMap[req.StringValues[i]])
|
||||
ints := make([]int64, len(uints))
|
||||
for i := range uints {
|
||||
ints[i] = int64(uints[i])
|
||||
}
|
||||
req.Values = ints
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue