MCPcopy Create free account
hub / github.com/brimdata/super / readMagic

Method readMagic

db/root.go:153–183  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

151}
152
153func (r *Root) readMagic(ctx context.Context) error {
154 path := r.path.JoinPath(MagicFile)
155 reader, err := r.engine.Get(ctx, path)
156 if err != nil {
157 return err
158 }
159 zr := bsupio.NewReader(super.NewContext(), reader)
160 defer zr.Close()
161 val, err := zr.Read()
162 if err != nil {
163 return err
164 }
165 last, err := zr.Read()
166 if err != nil {
167 return err
168 }
169 if last != nil {
170 return fmt.Errorf("corrupt database version file: more than one value at %s", sup.String(last))
171 }
172 var magic Magic
173 if err := sup.UnmarshalBSUP(*val, &magic); err != nil {
174 return fmt.Errorf("corrupt database version file: %w", err)
175 }
176 if magic.Magic != MagicString {
177 return fmt.Errorf("corrupt database version file: magic %q should be %q", magic.Magic, MagicString)
178 }
179 if magic.Version != Version {
180 return fmt.Errorf("unsupported database version: found version %d while expecting %d", magic.Version, Version)
181 }
182 return nil
183}
184
185func (r *Root) BatchifyPools(ctx context.Context, sctx *super.Context, f expr.Evaluator) ([]super.Value, error) {
186 m := sup.NewBSUPMarshalerWithContext(sctx)

Callers 2

loadConfigMethod · 0.95
writeMagicMethod · 0.95

Calls 8

CloseMethod · 0.95
ReadMethod · 0.95
NewReaderFunction · 0.92
NewContextFunction · 0.92
StringFunction · 0.92
UnmarshalBSUPFunction · 0.92
JoinPathMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected