Replace DebugString with Describe
This change makes tree description completely open to mechanical analysis and ensures consistency between description formats for each of the iterator types. Renamed StatsContainer.(Kind -> Type) for consistency.
This commit is contained in:
parent
b5f113203d
commit
62013d3dfc
22 changed files with 186 additions and 162 deletions
|
|
@ -17,7 +17,6 @@ package bolt
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/barakmich/glog"
|
||||
"github.com/boltdb/bolt"
|
||||
|
|
@ -179,9 +178,15 @@ func (it *AllIterator) Size() (int64, bool) {
|
|||
return it.qs.size, true
|
||||
}
|
||||
|
||||
func (it *AllIterator) DebugString(indent int) string {
|
||||
func (it *AllIterator) Describe() graph.Description {
|
||||
size, _ := it.Size()
|
||||
return fmt.Sprintf("%s(%s tags: %v bolt size:%d %s %p)", strings.Repeat(" ", indent), it.Type(), it.tags.Tags(), size, it.dir, it)
|
||||
return graph.Description{
|
||||
UID: it.UID(),
|
||||
Type: it.Type().String(),
|
||||
Tags: it.tags.Tags(),
|
||||
Size: size,
|
||||
Direction: it.dir,
|
||||
}
|
||||
}
|
||||
|
||||
func (it *AllIterator) Type() graph.Type { return graph.All }
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/barakmich/glog"
|
||||
"github.com/boltdb/bolt"
|
||||
|
|
@ -291,16 +290,15 @@ func (it *Iterator) Size() (int64, bool) {
|
|||
return it.size, true
|
||||
}
|
||||
|
||||
func (it *Iterator) DebugString(indent int) string {
|
||||
return fmt.Sprintf("%s(%s %d tags: %v dir: %s size:%d %s)",
|
||||
strings.Repeat(" ", indent),
|
||||
it.Type(),
|
||||
it.UID(),
|
||||
it.tags.Tags(),
|
||||
it.dir,
|
||||
it.size,
|
||||
it.qs.NameOf(&Token{it.bucket, it.checkID}),
|
||||
)
|
||||
func (it *Iterator) Describe() graph.Description {
|
||||
return graph.Description{
|
||||
UID: it.UID(),
|
||||
Name: it.qs.NameOf(&Token{it.bucket, it.checkID}),
|
||||
Type: it.Type().String(),
|
||||
Tags: it.tags.Tags(),
|
||||
Size: it.size,
|
||||
Direction: it.dir,
|
||||
}
|
||||
}
|
||||
|
||||
func (it *Iterator) Type() graph.Type { return boltType }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue