check that translate store is not nil where it needs to be checked

This commit is contained in:
reesporte 2021-12-07 16:41:54 -06:00
parent fed20ffd3e
commit 47f78c88e0
2 changed files with 12 additions and 1 deletions

5
api.go
View file

@ -2343,7 +2343,10 @@ func (api *API) GetTranslateEntryReader(ctx context.Context, offsets TranslateOf
if field == nil {
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
}
store := field.TranslateStore()
if store == nil {
return nil, ErrTranslateStoreNotFound
}
r, err := field.TranslateStore().EntryReader(ctx, uint64(offset))
if err != nil {
return nil, errors.Wrap(err, "field translate reader")

View file

@ -1480,6 +1480,10 @@ func (c *cluster) matchField(ctx context.Context, field *Field, like string) ([]
if c.Node.ID == primary.ID {
// The local copy is the authoritative copy.
plan := planLike(like)
store := field.TranslateStore()
if store == nil {
return nil, ErrTranslateStoreNotFound
}
return field.TranslateStore().Match(func(key []byte) bool {
return matchLike(key, plan...)
})
@ -1521,6 +1525,10 @@ func (c *cluster) translateFieldListIDs(field *Field, ids []uint64) (keys []stri
}
if c.Node.ID == primary.ID {
store := field.TranslateStore()
if store == nil {
return nil, ErrTranslateStoreNotFound
}
keys, err = field.TranslateStore().TranslateIDs(ids)
} else {
keys, err = c.InternalClient.TranslateIDsNode(context.Background(), &primary.URI, field.Index(), field.Name(), ids)