| 373 | } |
| 374 | |
| 375 | func (this *KVTask) TestInspect(t *testing.T) { |
| 376 | var db = this.itemsTable.DB() |
| 377 | it, err := db.Store().RawDB().NewIter(&pebble.IterOptions{ |
| 378 | LowerBound: []byte(db.Namespace()), |
| 379 | UpperBound: append([]byte(db.Namespace()), 0xFF), |
| 380 | }) |
| 381 | if err != nil { |
| 382 | t.Fatal(err) |
| 383 | } |
| 384 | defer func() { |
| 385 | _ = it.Close() |
| 386 | }() |
| 387 | |
| 388 | for it.First(); it.Valid(); it.Next() { |
| 389 | valueBytes, valueErr := it.ValueAndErr() |
| 390 | if valueErr != nil { |
| 391 | t.Fatal(valueErr) |
| 392 | } |
| 393 | var key = string(it.Key()[len(db.Namespace())-1:]) |
| 394 | t.Log(key, "=>", string(valueBytes)) |
| 395 | if strings.HasPrefix(key, "$values$K$") { |
| 396 | _, _, _, value, hash, _ := DecodeValueKey(key[len("$values$K$"):]) |
| 397 | t.Log(" |", hash, "=>", value) |
| 398 | } else if strings.HasPrefix(key, "$sumValues$K$") { |
| 399 | count, sum := DecodeSumValue(valueBytes) |
| 400 | t.Log(" |", count, sum) |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | func (this *KVTask) Truncate() error { |
| 406 | var db = this.itemsTable.DB() |