Make a safe cast

This commit is contained in:
Kuba Podgórski 2020-06-18 17:12:34 +02:00
parent bc9d13206f
commit ed86f6ea5d

View file

@ -3125,11 +3125,19 @@ func (e *executor) executeSetRow(ctx context.Context, indexName string, c *pql.C
// Merge returned results at coordinating node.
reduceFn := func(ctx context.Context, prev, v interface{}) interface{} {
val := v.(bool)
if prev == nil {
val, ok := v.(bool)
if !ok {
return errors.Errorf("executeSetRow.reduceFn: val is non-bool (%+v)", v)
}
if val {
return val
}
return val || prev.(bool)
pval, ok := prev.(bool)
if !ok {
return errors.Errorf("executeSetRow.reduceFn: prev is non-bool (%+v)", prev)
}
return pval
}
result, err := e.mapReduce(ctx, indexName, shards, c, opt, mapFn, reduceFn)