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

Function printPage

cmd/bbolt/command/command_page.go:80–115  ·  view source on GitHub ↗

printPage prints given page to cmd.Stdout and returns error or number of interpreted pages.

(cmd *cobra.Command, path string, pageID uint64, formatValue string)

Source from the content-addressed store, hash-verified

78
79// printPage prints given page to cmd.Stdout and returns error or number of interpreted pages.
80func printPage(cmd *cobra.Command, path string, pageID uint64, formatValue string) (numPages uint32, reterr error) {
81 defer func() {
82 if err := recover(); err != nil {
83 reterr = fmt.Errorf("%s", err)
84 }
85 }()
86
87 // retrieve page info and page size.
88 p, buf, err := guts_cli.ReadPage(path, pageID)
89 if err != nil {
90 return 0, err
91 }
92
93 // print basic page info.
94 stdout := cmd.OutOrStdout()
95 fmt.Fprintf(stdout, "Page ID: %d\n", p.Id())
96 fmt.Fprintf(stdout, "Page Type: %s\n", p.Typ())
97 fmt.Fprintf(stdout, "Total Size: %d bytes\n", len(buf))
98 fmt.Fprintf(stdout, "Overflow pages: %d\n", p.Overflow())
99
100 // print type-specific data.
101 switch p.Typ() {
102 case "meta":
103 err = pagePrintMeta(stdout, buf)
104 case "leaf":
105 err = pagePrintLeaf(stdout, buf, formatValue)
106 case "branch":
107 err = pagePrintBranch(stdout, buf)
108 case "freelist":
109 err = pagePrintFreelist(stdout, buf)
110 }
111 if err != nil {
112 return 0, err
113 }
114 return p.Overflow(), nil
115}
116
117func printAllPages(cmd *cobra.Command, path string, formatValue string) {
118 _, hwm, err := guts_cli.ReadPageAndHWMSize(path)

Callers 2

printPagesFunction · 0.85
printAllPagesFunction · 0.85

Calls 9

ReadPageFunction · 0.92
pagePrintMetaFunction · 0.85
pagePrintLeafFunction · 0.85
pagePrintBranchFunction · 0.85
pagePrintFreelistFunction · 0.85
IdMethod · 0.80
TypMethod · 0.80
OverflowMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected