(m *common.Meta, fields map[string]uint64)
| 192 | } |
| 193 | |
| 194 | func 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 | |
| 233 | func ReadMetaPageAt(dbPath string, metaPageId uint32, pageSize uint32) (*common.Meta, []byte, error) { |
| 234 | if metaPageId > 1 { |
no test coverage detected