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

Function NewObject

runtime/vcache/object.go:28–44  ·  view source on GitHub ↗

NewObject creates a new in-memory Object corresponding to a CSUP object residing in storage. The CSUP header and metadata section are read and the metadata is deserialized so that vectors can be loaded into the cache on demand only as needed and retained in memory for future use.

(ctx context.Context, engine storage.Engine, uri *storage.URI)

Source from the content-addressed store, hash-verified

26// the metadata is deserialized so that vectors can be loaded into the cache
27// on demand only as needed and retained in memory for future use.
28func NewObject(ctx context.Context, engine storage.Engine, uri *storage.URI) (*Object, error) {
29 // XXX currently we open a storage.Reader for every object and never close it.
30 // We should either close after a timeout and reopen when needed or change the
31 // storage API to have a more reasonable semantics around the Put/Get not leaving
32 // a file descriptor open for every long Get. Perhaps there should be another
33 // method for intermittent random access.
34 // XXX maybe open the reader inside Fetch if needed?
35 reader, err := engine.Get(ctx, uri)
36 if err != nil {
37 return nil, err
38 }
39 object, err := csup.NewObject(reader)
40 if err != nil {
41 return nil, err
42 }
43 return NewObjectFromCSUP(object), nil
44}
45
46func NewObjectFromCSUP(object *csup.Object) *Object {
47 return &Object{object: object}

Callers 2

RunMethod · 0.92
FetchMethod · 0.70

Calls 3

NewObjectFunction · 0.92
NewObjectFromCSUPFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected