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

Function pagePrintBranch

cmd/bbolt/command/command_page.go:186–209  ·  view source on GitHub ↗

pagePrintBranch prints the data for a leaf page.

(w io.Writer, buf []byte)

Source from the content-addressed store, hash-verified

184
185// pagePrintBranch prints the data for a leaf page.
186func pagePrintBranch(w io.Writer, buf []byte) error {
187 p := common.LoadPage(buf)
188
189 // print number of items.
190 fmt.Fprintf(w, "Item Count: %d\n", p.Count())
191 fmt.Fprintf(w, "\n")
192
193 // print each key/value.
194 for i := uint16(0); i < p.Count(); i++ {
195 e := p.BranchPageElement(i)
196
197 // format key as string.
198 var k string
199 if isPrintable(string(e.Key())) {
200 k = fmt.Sprintf("%q", string(e.Key()))
201 } else {
202 k = fmt.Sprintf("%x", string(e.Key()))
203 }
204
205 fmt.Fprintf(w, "%s: <pgid=%d>\n", k, e.Pgid())
206 }
207 fmt.Fprintf(w, "\n")
208 return nil
209}
210
211// pagePrintFreelist prints the data for a freelist page.
212func pagePrintFreelist(w io.Writer, buf []byte) error {

Callers 1

printPageFunction · 0.85

Calls 6

LoadPageFunction · 0.92
isPrintableFunction · 0.85
BranchPageElementMethod · 0.80
CountMethod · 0.65
KeyMethod · 0.45
PgidMethod · 0.45

Tested by

no test coverage detected