| 531 | } |
| 532 | |
| 533 | func (c Client) ZINTER(sourceKeys []string, aggregation ZAggregation, weights map[string]float64) (membersWithScores map[string]float64, err error) { |
| 534 | membersWithScores, err = c.ZRANGEBYSCORE(sourceKeys[0], math.Inf(-1), math.Inf(+1), 0, 0) |
| 535 | if err != nil { |
| 536 | return |
| 537 | } |
| 538 | |
| 539 | for i := 1; i < len(sourceKeys); i++ { |
| 540 | sourceKey := sourceKeys[i] |
| 541 | currentSet, err := c.ZRANGEBYSCORE(sourceKey, math.Inf(-1), math.Inf(+1), 0, 0) |
| 542 | |
| 543 | if err != nil { |
| 544 | return membersWithScores, err |
| 545 | } |
| 546 | |
| 547 | for member, score := range membersWithScores { |
| 548 | if currentSetValue, ok := currentSet[member]; ok { |
| 549 | membersWithScores[member] = accumulators[aggregation](score, currentSetValue*zGetWeight(weights, sourceKey)) |
| 550 | } else { |
| 551 | delete(membersWithScores, member) |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | return |
| 557 | } |