bufioutil

package
v0.0.0-...-034a78d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBuffer

func GetBuffer(length uint32) *[]byte

GetBuffer picks a buffer from the pool and then returns it.

func GetVariantLength

func GetVariantLength(value uint64) int64

GetVariantLength returns the length of variant-encoded-bytes.

func PutBuffer

func PutBuffer(buf *[]byte)

PutBuffer returns a buffer to the pool

Types

type BufioReader

type BufioReader interface {
	// Read reads a new entry's content.
	Read() (content []byte, err error)
	// Next reads from Reader and records the content and error.
	// returns true if not exceed the end of file.
	// returns false means there is no more data can be read from the reader.
	Next() bool
	// Reset switches the buffered reader to read from a new file:
	// open the new file; close the old opening file;
	// discards any buffered data and reset the states of bufio.Reader
	// reset the content-buffer and count.
	Reset(fileName string) error
	// Count returns the total size of bytes read successfully, including length cost.
	Count() int64
	// Size returns the total size of the file.
	Size() (int64, error)
	// Close closes the underlying file.
	Close() error
}

BufioReader read entries from a specified file by buffered I/O. Not thread-safe

func NewBufioReader

func NewBufioReader(fileName string) (BufioReader, error)

NewBufioReader returns a new BufioReader from fileName.

type BufioWriter

type BufioWriter interface {
	// Write writes a new entry containing logs in order.
	// Close syncs data to disk, then closes the opened file.
	io.WriteCloser
	// Reset switches the buffered writer to write to a new file:
	// open the new file; close the old opening file;
	// discards any buffered data and reset the states of bufio.Writer
	Reset(fileName string) error
	// Sync flushes data first, then calls syscall.sync.
	Sync() error
	// Flush flushes data to io.Writer.
	Flush() error
	// Size returns the length of written data.
	Size() int64
}

BufioWriter writes entries to a specified file by buffered I/O. Not thread-safe.

func NewBufioWriter

func NewBufioWriter(fileName string) (BufioWriter, error)

NewBufioWriter returns a new BufioWriter from fileName.

Jump to

Keyboard shortcuts

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