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

Function updateMetaField

cmd/bbolt/command/command_surgery_meta.go:194–231  ·  view source on GitHub ↗
(m *common.Meta, fields map[string]uint64)

Source from the content-addressed store, hash-verified

192}
193
194func updateMetaField(m *common.Meta, fields map[string]uint64) bool {
195 changed := false
196 for key, val := range fields {
197 switch key {
198 case metaFieldPageSize:
199 m.SetPageSize(uint32(val))
200 case metaFieldRoot:
201 m.SetRootBucket(common.NewInBucket(common.Pgid(val), 0))
202 case metaFieldFreelist:
203 m.SetFreelist(common.Pgid(val))
204 case metaFieldPgid:
205 m.SetPgid(common.Pgid(val))
206 }
207
208 changed = true
209 }
210
211 if m.Magic() != common.Magic {
212 m.SetMagic(common.Magic)
213 changed = true
214 }
215 if m.Version() != common.Version {
216 m.SetVersion(common.Version)
217 changed = true
218 }
219 if m.Flags() != common.MetaPageFlag {
220 m.SetFlags(common.MetaPageFlag)
221 changed = true
222 }
223
224 newChecksum := m.Sum64()
225 if m.Checksum() != newChecksum {
226 m.SetChecksum(newChecksum)
227 changed = true
228 }
229
230 return changed
231}
232
233func ReadMetaPageAt(dbPath string, metaPageId uint32, pageSize uint32) (*common.Meta, []byte, error) {
234 if metaPageId > 1 {

Callers 1

surgeryMetaUpdateFuncFunction · 0.85

Calls 15

NewInBucketFunction · 0.92
PgidTypeAlias · 0.92
SetPageSizeMethod · 0.80
SetRootBucketMethod · 0.80
SetFreelistMethod · 0.80
MagicMethod · 0.80
SetMagicMethod · 0.80
VersionMethod · 0.80
SetVersionMethod · 0.80
Sum64Method · 0.80
ChecksumMethod · 0.80
SetChecksumMethod · 0.80

Tested by

no test coverage detected