MCPcopy
hub / github.com/etcd-io/bbolt / pagePrintLeaf

Function pagePrintLeaf

cmd/bbolt/command/command_page.go:147–183  ·  view source on GitHub ↗

pagePrintLeaf prints the data for a leaf page.

(w io.Writer, buf []byte, formatValue string)

Source from the content-addressed store, hash-verified

145
146// pagePrintLeaf prints the data for a leaf page.
147func pagePrintLeaf(w io.Writer, buf []byte, formatValue string) error {
148 p := common.LoadPage(buf)
149
150 // print number of items.
151 fmt.Fprintf(w, "Item Count: %d\n", p.Count())
152 fmt.Fprintf(w, "\n")
153
154 // print each key/value.
155 for i := uint16(0); i < p.Count(); i++ {
156 e := p.LeafPageElement(i)
157
158 // format key as string.
159 var k string
160 if isPrintable(string(e.Key())) {
161 k = fmt.Sprintf("%q", string(e.Key()))
162 } else {
163 k = fmt.Sprintf("%x", string(e.Key()))
164 }
165
166 // format value as string.
167 var v string
168 var err error
169 if e.IsBucketEntry() {
170 b := e.Bucket()
171 v = b.String()
172 } else {
173 v, err = formatBytes(e.Value(), formatValue)
174 if err != nil {
175 return err
176 }
177 }
178
179 fmt.Fprintf(w, "%s: %s\n", k, v)
180 }
181 fmt.Fprintf(w, "\n")
182 return nil
183}
184
185// pagePrintBranch prints the data for a leaf page.
186func pagePrintBranch(w io.Writer, buf []byte) error {

Callers 1

printPageFunction · 0.85

Calls 10

LoadPageFunction · 0.92
isPrintableFunction · 0.85
LeafPageElementMethod · 0.80
IsBucketEntryMethod · 0.80
formatBytesFunction · 0.70
CountMethod · 0.65
KeyMethod · 0.45
BucketMethod · 0.45
StringMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected