(db *badger.DB, readTs uint64)
| 172 | } |
| 173 | |
| 174 | func 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 | |
| 208 | func findFirstValidTxn(db *badger.DB) uint64 { |
| 209 | readTs := opt.readTs |
no test coverage detected