recompute shards for cross-index queries

When computing results on another index, recompute list of
shards for that index.
This commit is contained in:
Seebs 2019-11-20 16:10:51 -06:00
parent 6ad39a376e
commit 26326ac74c

View file

@ -427,7 +427,7 @@ func (e *executor) execute(ctx context.Context, index string, q *pql.Query, shar
// already precomputed by handlePreCallChildren, though,
// we don't need this logic in executeCall.
if newIndex := call.CallIndex(); newIndex != "" {
v, err = e.executeCall(ctx, newIndex, call, shards, opt)
v, err = e.executeCall(ctx, newIndex, call, nil, opt)
} else {
v, err = e.executeCall(ctx, index, call, shards, opt)
}
@ -458,6 +458,20 @@ func (e *executor) executeCall(ctx context.Context, index string, c *pql.Call, s
e.Holder.Logger.Printf("DEPRECATED: Range() is deprecated, please use Row() instead.")
}
// If shards are specified, then use that value for shards. If shards aren't
// specified, then include all of them.
if shards == nil && needsShards([]*pql.Call{c}) {
// Round up the number of shards.
idx := e.Holder.Index(index)
if idx == nil {
return nil, ErrIndexNotFound
}
shards = idx.AvailableShards().Slice()
if len(shards) == 0 {
shards = []uint64{0}
}
}
// Special handling for mutation and top-n calls.
if op, ok := e.additionalCountOps[c.Name]; ok {
e.Holder.Stats.CountWithCustomTags(c.Name, 1, 1.0, []string{indexTag})