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

Method NewReader

db/data/reader.go:22–47  ·  view source on GitHub ↗

NewReader returns a Reader for this data object. If the object has a seek index and if the provided span skips part of the object, the seek index will be used to limit the reading window of the returned reader.

(ctx context.Context, engine storage.Engine, path *storage.URI, ranges []seekindex.Range)

Source from the content-addressed store, hash-verified

20// and if the provided span skips part of the object, the seek index will be used to
21// limit the reading window of the returned reader.
22func (o *Object) NewReader(ctx context.Context, engine storage.Engine, path *storage.URI, ranges []seekindex.Range) (*Reader, error) {
23 objectPath := o.SequenceURI(path)
24 reader, err := engine.Get(ctx, objectPath)
25 if err != nil {
26 return nil, fmt.Errorf("%s: %w", objectPath, err)
27 }
28 var r io.Reader
29 var readBytes int64
30 if len(ranges) == 0 {
31 r = reader
32 readBytes = o.Size
33 } else {
34 readers := make([]io.Reader, 0, len(ranges))
35 for _, rg := range ranges {
36 readers = append(readers, io.NewSectionReader(reader, rg.Offset, rg.Length))
37 readBytes += rg.Length
38 }
39 r = io.MultiReader(readers...)
40 }
41 return &Reader{
42 Reader: r,
43 Closer: reader,
44 TotalBytes: o.Size,
45 ReadBytes: readBytes,
46 }, nil
47}

Callers 15

isValidFunction · 0.45
runOneBoomerangFunction · 0.45
TestNonRecordDerefFunction · 0.45
runFunction · 0.45
FuzzQueryFunction · 0.45
BenchmarkReadCSUPFunction · 0.45
compileLeafMethod · 0.45
TestQueryFunction · 0.45
TestPoolStatsFunction · 0.45
TestEventsHandlerFunction · 0.45
NewCoreFunction · 0.45

Calls 2

SequenceURIMethod · 0.95
GetMethod · 0.65

Tested by 15

isValidFunction · 0.36
runOneBoomerangFunction · 0.36
TestNonRecordDerefFunction · 0.36
FuzzQueryFunction · 0.36
BenchmarkReadCSUPFunction · 0.36
TestQueryFunction · 0.36
TestPoolStatsFunction · 0.36
TestEventsHandlerFunction · 0.36
TestEOFOnEmptyFillFunction · 0.36
TestHost_AddFromReaderFunction · 0.36