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

Function seekTotal

dgraph/cmd/debug/run.go:174–206  ·  view source on GitHub ↗
(db *badger.DB, readTs uint64)

Source from the content-addressed store, hash-verified

172}
173
174func seekTotal(db *badger.DB, readTs uint64) int {
175 txn := db.NewTransactionAt(readTs, false)
176 defer txn.Discard()
177
178 iopt := badger.DefaultIteratorOptions
179 iopt.AllVersions = true
180 iopt.PrefetchValues = false
181 itr := txn.NewIterator(iopt)
182 defer itr.Close()
183
184 keys := uidToVal(itr, "key_")
185 fmt.Printf("Got keys: %+v\n", keys)
186 vals := uidToVal(itr, "amount_")
187 var total int
188 for _, val := range vals {
189 total += val
190 }
191 fmt.Printf("Got vals: %+v. Total: %d\n", vals, total)
192 if opt.noKeys {
193 // Ignore the key_ predicate. Only consider the amount_ predicate. Useful when tablets are
194 // being moved around.
195 keys = vals
196 }
197
198 total = 0
199 for uid, key := range keys {
200 a := vals[uid]
201 fmt.Printf("uid: %-5d %x key: %d amount: %d\n", uid, uid, key, a)
202 total += a
203 }
204 fmt.Printf("Total @ %d = %d\n", readTs, total)
205 return total
206}
207
208func findFirstValidTxn(db *badger.DB) uint64 {
209 readTs := opt.readTs

Callers 4

findFirstValidTxnFunction · 0.85
findFirstInvalidTxnFunction · 0.85
jepsenFunction · 0.85
runFunction · 0.85

Calls 3

uidToValFunction · 0.85
NewIteratorMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected