-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The commit adds the ability to use CSUP files in vector runtime. It also implements the NewConcurrentPuller protocol to enable parallel read of a CSUP file in vector runtime.
- Loading branch information
Showing
5 changed files
with
105 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package vngio | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"io" | ||
"sync/atomic" | ||
|
||
"github.com/brimdata/super" | ||
"github.com/brimdata/super/pkg/field" | ||
"github.com/brimdata/super/runtime/vcache" | ||
"github.com/brimdata/super/vector" | ||
"github.com/brimdata/super/vng" | ||
) | ||
|
||
type VectorReader struct { | ||
ctx context.Context | ||
zctx *super.Context | ||
|
||
objects []object | ||
Check failure on line 20 in zio/vngio/vectorreader.go GitHub Actions / output-check
Check failure on line 20 in zio/vngio/vectorreader.go GitHub Actions / test-windows
Check failure on line 20 in zio/vngio/vectorreader.go GitHub Actions / test-windows
Check failure on line 20 in zio/vngio/vectorreader.go GitHub Actions / test
|
||
nextObject *atomic.Int64 | ||
projection vcache.Path | ||
readerAt io.ReaderAt | ||
} | ||
|
||
func NewVectorReader(ctx context.Context, zctx *super.Context, r io.Reader, fields []field.Path) (*VectorReader, error) { | ||
ra, ok := r.(io.ReaderAt) | ||
if !ok { | ||
return nil, errors.New("Super Columnar requires a seekable input") | ||
} | ||
objects, err := readObjects(ra) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &VectorReader{ | ||
ctx: ctx, | ||
zctx: zctx, | ||
objects: objects, | ||
nextObject: &atomic.Int64{}, | ||
projection: vcache.NewProjection(fields), | ||
readerAt: ra, | ||
}, nil | ||
} | ||
|
||
func (v *VectorReader) NewConcurrentPuller() vector.Puller { | ||
return &VectorReader{ | ||
ctx: v.ctx, | ||
zctx: v.zctx, | ||
objects: v.objects, | ||
nextObject: v.nextObject, | ||
projection: v.projection, | ||
readerAt: v.readerAt, | ||
} | ||
} | ||
|
||
func (v *VectorReader) Pull(done bool) (vector.Any, error) { | ||
if done { | ||
return nil, nil | ||
} | ||
if err := v.ctx.Err(); err != nil { | ||
return nil, err | ||
} | ||
n := int(v.nextObject.Add(1) - 1) | ||
if n >= len(v.objects) { | ||
return nil, nil | ||
} | ||
meta := v.objects[n] | ||
o, err := vng.NewObject(io.NewSectionReader(v.readerAt, meta.start, meta.offset)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return vcache.NewObjectFromVNG(o).Fetch(v.zctx, v.projection) | ||
} |