MCPcopy
hub / github.com/dgraph-io/dgraph / KvWithMaxVersion

Function KvWithMaxVersion

x/x.go:1460–1470  ·  view source on GitHub ↗

KvWithMaxVersion returns a KV with the max version from the list of KVs.

(kvs *badgerpb.KVList, prefixes [][]byte)

Source from the content-addressed store, hash-verified

1458
1459// KvWithMaxVersion returns a KV with the max version from the list of KVs.
1460func KvWithMaxVersion(kvs *badgerpb.KVList, prefixes [][]byte) *badgerpb.KV {
1461 // Iterate over kvs to get the KV with the latest version. It is not necessary that the last
1462 // KV contain the latest value.
1463 var maxKv *badgerpb.KV
1464 for _, kv := range kvs.GetKv() {
1465 if maxKv.GetVersion() <= kv.GetVersion() {
1466 maxKv = kv
1467 }
1468 }
1469 return maxKv
1470}
1471
1472// PrefixesToMatches converts the prefixes for subscription to a list of match.
1473func PrefixesToMatches(prefixes [][]byte, ignore string) []*badgerpb.Match {

Callers 2

SubscribeForAclUpdatesFunction · 0.92
newAdminResolverFunction · 0.92

Calls 2

GetKvMethod · 0.80
GetVersionMethod · 0.65

Tested by

no test coverage detected