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)
| 62 | // |
| 63 | // Default is the maximum limit of 4MB. |
| 64 | func 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. |
no outgoing calls
searching dependent graphs…