mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
properly thread the ctx through so we can pass Auth around
This commit is contained in:
parent
e530193e80
commit
bff9128c9b
3 changed files with 14 additions and 14 deletions
4
api.go
4
api.go
|
|
@ -2332,7 +2332,7 @@ func (api *API) TranslateIDs(ctx context.Context, r io.Reader) (_ []byte, err er
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if keys, err = api.cluster.translateFieldListIDs(field, req.IDs); err != nil {
|
||||
} else if keys, err = api.cluster.translateFieldListIDs(ctx, field, req.IDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
@ -2883,7 +2883,7 @@ func (api *API) MutexCheck(ctx context.Context, qcx *Qcx, indexName string, fiel
|
|||
return nil, err
|
||||
}
|
||||
if useFieldKeys {
|
||||
fieldKeyList, err := api.cluster.translateFieldListIDs(field, fieldIDs)
|
||||
fieldKeyList, err := api.cluster.translateFieldListIDs(ctx, field, fieldIDs)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "translating index keys")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1480,7 +1480,7 @@ func (c *cluster) matchField(ctx context.Context, field *Field, like string) ([]
|
|||
return c.InternalClient.MatchFieldKeysNode(ctx, &primary.URI, field.Index(), field.Name(), like)
|
||||
}
|
||||
|
||||
func (c *cluster) translateFieldIDs(field *Field, ids map[uint64]struct{}) (map[uint64]string, error) {
|
||||
func (c *cluster) translateFieldIDs(ctx context.Context, field *Field, ids map[uint64]struct{}) (map[uint64]string, error) {
|
||||
idList := make([]uint64, len(ids))
|
||||
{
|
||||
i := 0
|
||||
|
|
@ -1490,7 +1490,7 @@ func (c *cluster) translateFieldIDs(field *Field, ids map[uint64]struct{}) (map[
|
|||
}
|
||||
}
|
||||
|
||||
keyList, err := c.translateFieldListIDs(field, idList)
|
||||
keyList, err := c.translateFieldListIDs(ctx, field, idList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -1502,7 +1502,7 @@ func (c *cluster) translateFieldIDs(field *Field, ids map[uint64]struct{}) (map[
|
|||
return mapped, nil
|
||||
}
|
||||
|
||||
func (c *cluster) translateFieldListIDs(field *Field, ids []uint64) (keys []string, err error) {
|
||||
func (c *cluster) translateFieldListIDs(ctx context.Context, field *Field, ids []uint64) (keys []string, err error) {
|
||||
// Create a snapshot of the cluster to use for node/partition calculations.
|
||||
snap := topology.NewClusterSnapshot(c.noder, c.Hasher, c.ReplicaN)
|
||||
|
||||
|
|
@ -1518,7 +1518,7 @@ func (c *cluster) translateFieldListIDs(field *Field, ids []uint64) (keys []stri
|
|||
}
|
||||
keys, err = field.TranslateStore().TranslateIDs(ids)
|
||||
} else {
|
||||
keys, err = c.InternalClient.TranslateIDsNode(context.Background(), &primary.URI, field.Index(), field.Name(), ids)
|
||||
keys, err = c.InternalClient.TranslateIDsNode(ctx, &primary.URI, field.Index(), field.Name(), ids)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "translating field(%s/%s) ids(%v)", field.Index(), field.Name(), ids)
|
||||
|
|
|
|||
16
executor.go
16
executor.go
|
|
@ -6896,7 +6896,7 @@ func (e *executor) collectResultIDs(index string, idx *Index, call *pql.Call, re
|
|||
}
|
||||
|
||||
// preTranslateMatrixSet translates the IDs of a set field in an extracted matrix.
|
||||
func (e *executor) preTranslateMatrixSet(mat ExtractedIDMatrix, fieldIdx uint, field *Field) (map[uint64]string, error) {
|
||||
func (e *executor) preTranslateMatrixSet(ctx context.Context, mat ExtractedIDMatrix, fieldIdx uint, field *Field) (map[uint64]string, error) {
|
||||
ids := make(map[uint64]struct{}, len(mat.Columns))
|
||||
for _, col := range mat.Columns {
|
||||
for _, v := range col.Rows[fieldIdx] {
|
||||
|
|
@ -6904,7 +6904,7 @@ func (e *executor) preTranslateMatrixSet(mat ExtractedIDMatrix, fieldIdx uint, f
|
|||
}
|
||||
}
|
||||
|
||||
return e.Cluster.translateFieldIDs(field, ids)
|
||||
return e.Cluster.translateFieldIDs(ctx, field, ids)
|
||||
}
|
||||
|
||||
func (e *executor) translateResult(ctx context.Context, index string, idx *Index, call *pql.Call, result interface{}, idSet map[uint64]string, memoryAvailable *int64) (_ interface{}, err error) {
|
||||
|
|
@ -6924,7 +6924,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
}
|
||||
return other, nil
|
||||
case byRowField:
|
||||
keys, err := e.Cluster.translateFieldListIDs(rowField, result.Columns())
|
||||
keys, err := e.Cluster.translateFieldListIDs(ctx, rowField, result.Columns())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "translating Row to field keys")
|
||||
}
|
||||
|
|
@ -7026,7 +7026,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
for i := range result.Pairs {
|
||||
ids[i] = result.Pairs[i].ID
|
||||
}
|
||||
keys, err := e.Cluster.translateFieldListIDs(field, ids)
|
||||
keys, err := e.Cluster.translateFieldListIDs(ctx, field, ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -7078,7 +7078,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
|
||||
fieldTranslations := make(map[string]map[uint64]string)
|
||||
for field, ids := range fieldIDs {
|
||||
trans, err := e.Cluster.translateFieldIDs(field, ids)
|
||||
trans, err := e.Cluster.translateFieldIDs(ctx, field, ids)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "translating IDs in field %q", field.Name())
|
||||
}
|
||||
|
|
@ -7133,7 +7133,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
if field := idx.Field(fieldName); field == nil {
|
||||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
} else if field.Keys() {
|
||||
keys, err := e.Cluster.translateFieldListIDs(field, result)
|
||||
keys, err := e.Cluster.translateFieldListIDs(ctx, field, result)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "translating row IDs")
|
||||
}
|
||||
|
|
@ -7180,7 +7180,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
case FieldTypeSet, FieldTypeTime:
|
||||
if field.Keys() {
|
||||
datatype = "[]string"
|
||||
translations, err := e.preTranslateMatrixSet(result, uint(i), field)
|
||||
translations, err := e.preTranslateMatrixSet(ctx, result, uint(i), field)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "translating IDs of field %q", v)
|
||||
}
|
||||
|
|
@ -7203,7 +7203,7 @@ func (e *executor) translateResult(ctx context.Context, index string, idx *Index
|
|||
case FieldTypeMutex:
|
||||
if field.Keys() {
|
||||
datatype = "string"
|
||||
translations, err := e.preTranslateMatrixSet(result, uint(i), field)
|
||||
translations, err := e.preTranslateMatrixSet(ctx, result, uint(i), field)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "translating IDs of field %q", v)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue