MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestInspect

Method TestInspect

internal/metrics/task_kv.go:375–403  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

373}
374
375func (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
405func (this *KVTask) Truncate() error {
406 var db = this.itemsTable.DB()

Callers 2

TestKVTask_CleanExpiredFunction · 0.45
TestKVTask_TestInspectFunction · 0.45

Calls 10

DecodeValueKeyFunction · 0.85
DecodeSumValueFunction · 0.85
DBMethod · 0.80
StoreMethod · 0.80
NextMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
KeyMethod · 0.65
RawDBMethod · 0.45
NamespaceMethod · 0.45

Tested by 2

TestKVTask_CleanExpiredFunction · 0.36
TestKVTask_TestInspectFunction · 0.36