// NewReader reads from the buffer which is concurrently filled with data from the passed src.
331465
func NewReader(src io.Reader, buf Buffer) io.ReadCloser {
	r, w := Pipe(buf)

	go func() {
		_, err := io.Copy(w, src)
		w.CloseWithError(err)
	}()

	return r
}
1309164
func (c *CSV) NewReader(res *exchange.Resource, context *qor.Context) (exchange.Rows, error) {
	var rows = Rows{CSV: c, Resource: res}

	readCloser, err := c.getReader()
	if err == nil {
		defer readCloser.Close()
		reader := csv.NewReader(readCloser)
		reader.TrimLeadingSpace = true

		rows.records, err = reader.ReadAll()

		if c.config.TrimSpace {
			for _, rows := range rows.records {
				for i, record := range rows {
					rows[i] = strings.TrimSpace(record)
				}
			}
		}

		rows.total = len(rows.records) - 1
		if res.Config.WithoutHeader {
			rows.total++
		}
	}

	return &rows, err
}
167768
func (lc *LimitedClient) NewReader(p Path, offset, length int64) (io.ReadCloser, error) {
	if lc.MaxReadBytes <= 0 || (length > 0 && length <= lc.MaxReadBytes) {
		return lc.Client.NewReader(p, offset, length)
	}

	lr := limitedReader{
		lc:           lc,
		path:         p,
		maxReadBytes: lc.MaxReadBytes,
		nextOffset:   offset,
		nextLength:   length,
	}
	if err := lr.nextReader(); err != nil {
		return nil, err
	}
	return &lr, nil
}
1015646
func NewReader(ctx context.Context, r io.Reader) *Reader {
	return &Reader{
		ctx:    ctx,
		reader: r,
	}
}
1000164
func NewReader(buf []byte, simple bool) (reader *Reader) {
	reader = new(Reader)
	reader.buf = buf
	reader.Simple = simple
	return
}
989167
func NewReader(src io.Reader) (*Reader, error) {
	var err error

	result := &Reader{}

	result.cmd = exec.Command("xz", "--decompress", "--stdout")
	result.input, err = result.cmd.StdinPipe()
	if err != nil {
		return nil, err
	}
	result.output, err = result.cmd.StdoutPipe()
	if err != nil {
		return nil, err
	}

	err = result.cmd.Start()
	if err != nil {
		return nil, err
	}

	go func() {
		io.Copy(result.input, src)
		result.input.Close()
	}()

	return result, nil
}
1212186
func newReader(fileName string) (*tarReader, error) {
	file, err := os.OpenFile(fileName, os.O_RDONLY, os.ModePerm)
	if err != nil {
		return nil, err
	}

	// Reads the header from the file to see which compression
	// this file has been using.
	compression, err := detectCompression(file)
	if err != nil {
		return nil, err
	}

	var compressReader io.ReadCloser

	switch compression {
	case Gzip:
		if compressReader, err = gzip.NewReader(file); err != nil {
			file.Close()
			return nil, err
		}
	case Bzip2:
		compressReader = &readCloserWrapper{Reader: bzip2.NewReader(file)}
	}

	var reader *tar.Reader

	if compressReader == nil {
		reader = tar.NewReader(file)
	} else {
		reader = tar.NewReader(compressReader)
	}

	return &tarReader{
		file:           file,
		fileName:       fileName,
		reader:         reader,
		compressReader: compressReader,
	}, nil
}
390462
func (d Decoder) NewReader(rd io.Reader) *Reader {
	b := new(Reader)
	b.buf = make([]byte, defaultBufSize)
	b.rd = rd
	b.decode = d
	return b
}
1323778
func NewReader(r io.Reader) *Reader {
	return &Reader{
		Delimiter: '\t',
		r:         bufio.NewReader(r),
	}
}
1348768
func NewReader(r io.Reader, dropper Dropper, strict, checksum bool) *Reader {
	return &Reader{
		r:        r,
		dropper:  dropper,
		strict:   strict,
		checksum: checksum,
		last:     true,
	}
}
752520
func NewReader(rd io.ReadSeeker, size int64) (wav *Reader, err error) {
	if size > maxSize {
		return nil, ErrInputToLarge
	}

	wav = new(Reader)
	wav.input = rd
	wav.size = size

	err = wav.parseHeaders()
	if err != nil {
		return nil, err
	}

	wav.samplesRead = 0

	return wav, nil
}
330013
func NewReader(rd io.Reader) *Reader {
	return &Reader{
		rd:  bufio.NewReader(rd),
		buf: make([]byte, 4096),
	}
}
976930
func NewReader(opts ...reader.Option) reader.Reader {
	options := reader.NewOptions(opts...)
	return &jsonReader{
		json: json.NewEncoder(),
		opts: options,
	}
}
828832
func (m *Client) NewReader(o string) (io.ReadCloser, error) {
	return m.NewReaderWithContext(context.Background(), o)
}
707507
func (s *File) NewReader(id string) (io.ReadCloser, error) {
	return os.OpenFile(s.join(s.Prefixed.Name(id)), os.O_RDONLY, 0400)
}
356057
func NewReader(conn net.Conn, timeout time.Duration) io.Reader {
	return &reader{
		Conn:    conn,
		timeout: timeout,
	}
}
214045
func NewReader(getReaderFunc func(offset, length int64) (io.ReadCloser, error), args *ReaderArgs) (*Reader, error) {
	reader, err := parquetgo.NewReader(getReaderFunc, nil)
	if err != nil {
		if err != io.EOF {
			return nil, errParquetParsingError(err)
		}

		return nil, err
	}

	return &Reader{
		args:   args,
		reader: reader,
	}, nil
}