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

Function newStatsCommand

cmd/bbolt/command/command_stats.go:13–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func newStatsCommand() *cobra.Command {
14 statsCmd := &cobra.Command{
15 Use: "stats <bbolt-file>",
16 Short: "print stats of bbolt database",
17 Long: strings.TrimLeft(`
18usage: bolt stats PATH
19
20Stats performs an extensive search of the database to track every page
21reference. It starts at the current meta page and recursively iterates
22through every accessible bucket.
23
24The following errors can be reported:
25
26 already freed
27 The page is referenced more than once in the freelist.
28
29 unreachable unfreed
30 The page is not referenced by a bucket or in the freelist.
31
32 reachable freed
33 The page is referenced by a bucket but is also in the freelist.
34
35 out of bounds
36 A page is referenced that is above the high water mark.
37
38 multiple references
39 A page is referenced by more than one other page.
40
41 invalid type
42 The page type is not "meta", "leaf", "branch", or "freelist".
43
44No errors should occur in your database. However, if for some reason you
45experience corruption, please submit a ticket to the etcd-io/bbolt project page:
46
47 https://github.com/etcd-io/bbolt/issues
48`, "\n"),
49 Args: cobra.RangeArgs(1, 2),
50 RunE: func(cmd *cobra.Command, args []string) error {
51 prefix := ""
52 if len(args) > 1 {
53 prefix = args[1]
54 }
55
56 return statsFunc(cmd, args[0], prefix)
57 },
58 }
59
60 return statsCmd
61}
62
63func statsFunc(cmd *cobra.Command, dbPath string, prefix string) error {
64 if _, err := checkSourceDBPath(dbPath); err != nil {

Callers 1

NewRootCommandFunction · 0.85

Calls 1

statsFuncFunction · 0.85

Tested by

no test coverage detected