readahead

package
v0.0.0-...-4336771 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package readahead will do asynchronous read-ahead from an input io.Reader and make the data available as an io.Reader.

This should be fully transparent, except that once an error has been returned from the Reader, it will not recover.

The readahead object also fulfills the io.WriterTo interface, which is likely to speed up copies.

Package home: https://github.com/klauspost/readahead

Index

Constants

View Source
const (
	// DefaultBuffers is the default number of buffers used.
	DefaultBuffers = 4

	// DefaultBufferSize is the default buffer size, 1 MB.
	DefaultBufferSize = 1 << 20
)

Variables

This section is empty.

Functions

func NewReadCloser

func NewReadCloser(rd io.ReadCloser) io.ReadCloser

NewReadCloser returns a reader that will asynchronously read from the supplied reader into 4 buffers of 1MB each.

It will start reading from the input at once, maybe even before this function has returned.

The input can be read from the returned reader. When done use Close() to release the buffers, which will also close the supplied closer. If a reader supporting the io.Seeker is given, the returned reader will also support it.

func NewReadCloserBuffer

func NewReadCloserBuffer(rc io.ReadCloser, buffers [][]byte) (res io.ReadCloser, err error)

NewReadCloserBuffer returns a reader with a custom number of buffers and size. All buffers must be the same size. Buffers can be reused after Close has been called.

func NewReadCloserSize

func NewReadCloserSize(rc io.ReadCloser, buffers, size int) (res io.ReadCloser, err error)

NewReadCloserSize returns a reader with a custom number of buffers and size. buffers is the number of queued buffers and size is the size of each buffer in bytes.

func NewReader

func NewReader(rd io.Reader) io.ReadCloser

NewReader returns a reader that will asynchronously read from the supplied reader into 4 buffers of 1MB each.

It will start reading from the input at once, maybe even before this function has returned.

The input can be read from the returned reader. When done use Close() to release the buffers. If a reader supporting the io.Seeker is given, the returned reader will also support it.

func NewReaderBuffer

func NewReaderBuffer(rd io.Reader, buffers [][]byte) (res io.ReadCloser, err error)

NewReaderBuffer returns a reader with a custom number of buffers and size. All buffers must be the same size. Buffers can be reused after Close has been called.

func NewReaderSize

func NewReaderSize(rd io.Reader, buffers, size int) (res io.ReadCloser, err error)

NewReaderSize returns a reader with a custom number of buffers and size. buffers is the number of queued buffers and size is the size of each buffer in bytes.

Types

type ReadSeekCloser

type ReadSeekCloser interface {
	io.ReadCloser
	io.Seeker
}

func NewReadSeekCloser

func NewReadSeekCloser(rd ReadSeekCloser) ReadSeekCloser

NewReadSeekCloser returns a reader that will asynchronously read from the supplied reader into 4 buffers of 1MB each.

It will start reading from the input at once, maybe even before this function has returned.

The input can be read and seeked from the returned reader. When done use Close() to release the buffers, which will also close the supplied closer.

func NewReadSeekCloserBuffer

func NewReadSeekCloserBuffer(rd ReadSeekCloser, buffers [][]byte) (res ReadSeekCloser, err error)

NewReadSeekCloserBuffer returns a reader with a custom number of buffers and size. All buffers must be the same size. Buffers can be reused after Close has been called.

func NewReadSeekCloserSize

func NewReadSeekCloserSize(rd ReadSeekCloser, buffers, size int) (res ReadSeekCloser, err error)

NewReadSeekCloserSize returns a reader with a custom number of buffers and size. buffers is the number of queued buffers and size is the size of each buffer in bytes.

func NewReadSeeker

func NewReadSeeker(rd io.ReadSeeker) ReadSeekCloser

NewReadSeeker returns a reader that will asynchronously read from the supplied reader into 4 buffers of 1MB each.

It will start reading from the input at once, maybe even before this function has returned.

The input can be read and seeked from the returned reader. When done use Close() to release the buffers.

func NewReadSeekerSize

func NewReadSeekerSize(rd io.ReadSeeker, buffers, size int) (res ReadSeekCloser, err error)

NewReadSeekerSize returns a reader with a custom number of buffers and size. buffers is the number of queued buffers and size is the size of each buffer in bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL