Пример #1
0
// NewReader creates a new Reader reading the given reader.
func NewReader(r io.Reader) (io.ReadCloser, error) {
	z := &reader{
		r: r,
		h: xxhash.New(0),
	}
	if err := z.readFrame(); err != nil {
		return nil, err
	}
	return z, nil
}
Пример #2
0
// NewWriterLevel is like NewWriter but specifies the compression level instead
// of assuming the default compression level.
func NewWriterLevel(w io.Writer, level int) (io.WriteCloser, error) {
	if level < defaultCompression || level > BestCompression {
		return nil, fmt.Errorf("lz4: invalid compression level: %d", level)
	}
	return &writer{
		level: level,
		w:     w,
		h:     xxhash.New(0),
	}, nil
}
Пример #3
0
// newBitReader returns a new bitReader reading from r. If r is not
// already an io.ByteReader, it will be converted via a bufio.Reader.
func newBitReader(r io.Reader) bitReader {
	br, ok := r.(io.ByteReader)
	if !ok {
		br = bufio.NewReader(r)
	}
	return bitReader{
		r: br,
		h: xxhash.New(0),
	}
}