| 27 | } |
| 28 | |
| 29 | func NewReader(sctx *super.Context, r io.Reader, fields []field.Path) (sio.Reader, error) { |
| 30 | ra, ok := r.(io.ReaderAt) |
| 31 | if !ok { |
| 32 | return nil, errors.New("Super Columnar requires a seekable input") |
| 33 | } |
| 34 | // CSUP autodetection requires that we return error on open if invalid format. |
| 35 | if _, err := csup.ReadHeader(ra); err != nil { |
| 36 | return nil, err |
| 37 | } |
| 38 | ctx, cancel := context.WithCancel(context.Background()) |
| 39 | return &reader{ |
| 40 | sctx: sctx, |
| 41 | stream: &stream{ctx: ctx, r: ra}, |
| 42 | projection: field.NewProjection(fields), |
| 43 | readerAt: ra, |
| 44 | cancel: cancel, |
| 45 | }, nil |
| 46 | } |
| 47 | |
| 48 | func (r *reader) Read() (*super.Value, error) { |
| 49 | again: |