MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / ZINTER

Method ZINTER

sorted_sets.go:533–557  ·  view source on GitHub ↗
(sourceKeys []string, aggregation ZAggregation, weights map[string]float64)

Source from the content-addressed store, hash-verified

531}
532
533func (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}

Callers 2

ZINTERSTOREMethod · 0.95
TestZAggregationsFunction · 0.80

Calls 2

ZRANGEBYSCOREMethod · 0.95
zGetWeightFunction · 0.85

Tested by 1

TestZAggregationsFunction · 0.64