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

Function ReadPageAndHWMSize

internal/guts_cli/guts_cli.go:93–113  ·  view source on GitHub ↗

ReadPageAndHWMSize reads Page size and HWM (id of the last+1 Page). This is not transactionally safe.

(path string)

Source from the content-addressed store, hash-verified

91// ReadPageAndHWMSize reads Page size and HWM (id of the last+1 Page).
92// This is not transactionally safe.
93func ReadPageAndHWMSize(path string) (uint64, common.Pgid, error) {
94 // Open database file.
95 f, err := os.Open(path)
96 if err != nil {
97 return 0, 0, err
98 }
99 defer f.Close()
100
101 // Read 4KB chunk.
102 buf := make([]byte, 4096)
103 if _, err := io.ReadFull(f, buf); err != nil {
104 return 0, 0, err
105 }
106
107 // Read Page size from metadata.
108 m := common.LoadPageMeta(buf)
109 if m.Magic() != common.Magic {
110 return 0, 0, fmt.Errorf("the Meta Page has wrong (unexpected) magic")
111 }
112 return uint64(m.PageSize()), common.Pgid(m.Pgid()), nil
113}
114
115// GetRootPage returns the root-page (according to the most recent transaction).
116func GetRootPage(path string) (root common.Pgid, activeMeta common.Pgid, err error) {

Callers 6

ClearPageElementsFunction · 0.92
printAllPagesFunction · 0.92
dumpFuncFunction · 0.92
readMetaPageFunction · 0.92
ReadPageFunction · 0.85
WritePageFunction · 0.85

Calls 7

LoadPageMetaFunction · 0.92
PgidTypeAlias · 0.92
MagicMethod · 0.80
PageSizeMethod · 0.80
ErrorfMethod · 0.65
CloseMethod · 0.45
PgidMethod · 0.45

Tested by

no test coverage detected