KvWithMaxVersion returns a KV with the max version from the list of KVs.
(kvs *badgerpb.KVList, prefixes [][]byte)
| 1458 | |
| 1459 | // KvWithMaxVersion returns a KV with the max version from the list of KVs. |
| 1460 | func 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. |
| 1473 | func PrefixesToMatches(prefixes [][]byte, ignore string) []*badgerpb.Match { |
no test coverage detected