MCPcopy
hub / github.com/klauspost/compress / ReaderMaxBlockSize

Function ReaderMaxBlockSize

s2/reader.go:64–75  ·  view source on GitHub ↗

ReaderMaxBlockSize allows to control allocations if the stream has been compressed with a smaller WriterBlockSize, or with the default 1MB. Blocks must be this size or smaller to decompress, otherwise the decoder will return ErrUnsupported. For streams compressed with Snappy this can safely be set

(blockSize int)

Source from the content-addressed store, hash-verified

62//
63// Default is the maximum limit of 4MB.
64func ReaderMaxBlockSize(blockSize int) ReaderOption {
65 return func(r *Reader) error {
66 if blockSize > maxBlockSize || blockSize <= 0 {
67 return errors.New("s2: block size too large. Must be <= 4MB and > 0")
68 }
69 if r.lazyBuf == 0 && blockSize < defaultBlockSize {
70 r.lazyBuf = blockSize
71 }
72 r.maxBlock = blockSize
73 return nil
74 }
75}
76
77// ReaderAllocBlock allows to control upfront stream allocations
78// and not allocate for frames bigger than this initially.

Callers 2

NewReaderFunction · 0.92
TestDecoderMaxBlockSizeFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDecoderMaxBlockSizeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…