Documentation
¶
Index ¶
- Variables
- func InitZipWriter(writer io.Writer, zipAlgorithm ZipAlgorithm, compression CompressionLevel) (io.Writer, func() error, error)
- func OpenReader(fileName string, zipAlgorithm ZipAlgorithm) (io.Reader, func() error, error)
- func ParseZip(zipSetting string) (ZipAlgorithm, CompressionLevel, error)
- type CompressionLevel
- type FileWriterBase
- type Read
- type ZipAlgorithm
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrPoolClosed = errors.New("pool closed")
View Source
var InnerWriterFactory = newBufferedFileWriter
InnerWriterFactory lets you override writer creation for testing purposes
Functions ¶
func InitZipWriter ¶
func InitZipWriter(writer io.Writer, zipAlgorithm ZipAlgorithm, compression CompressionLevel) (io.Writer, func() error, error)
func OpenReader ¶
func ParseZip ¶
func ParseZip(zipSetting string) (ZipAlgorithm, CompressionLevel, error)
ParseZip parses a string with format 'algo' or 'algo:level' e.g. 'zstd' or 'zstd:fastest' Allowed algorithms: "" (none), "gzip", "default" (zstd), "zstd", "deflate" Allowed compression levels: "default" (fastest), "fastest", "fast", "better", "best". Note that for 'deflate', the compression level will not make any difference.
Types ¶
type CompressionLevel ¶
type CompressionLevel int
CompressionLevel controls the level of compression to use.
const ( // CompressionFastest provides the fastest compression speed with the given ZipAlgorithm // When changing compression levels, always make sure that your machine can // write the data as fast as it is collected. Otherwise memory will overflow. CompressionFastest CompressionLevel = iota // CompressionFast provides a fast compression speed with the given ZipAlgorithm // But smaller file sizes than CompressionFastest. // When changing compression levels, always make sure that your machine can // write the data as fast as it is collected. Otherwise memory will overflow. CompressionFast // CompressionBetter provides a smaller file size than CompressionFast and CompressionFastest // using the given ZipAlgorithm. CompressionBetter can lead to memory on many machines, // as data cannot be written as fast as it is collected. When changing compression levels, // always make sure that data can be written fast enough CompressionBetter // CompressionBest provides a smaller file size than CompressionFast and CompressionFastest // using the given ZipAlgorithm. CompressionBest )
type FileWriterBase ¶
type FileWriterBase struct { OutDir string FilePrefix string FileExtension string OutputFileSize uint ZipAlgorithm ZipAlgorithm CompressionLevel CompressionLevel // RandomFileSuffix avoids that subsequent runs in the same directory overwrite files // Just a small safeguard against data loss. RandomFileSuffix string // contains filtered or unexported fields }
func NewFileWriterBase ¶
func NewFileWriterBase(outDir string, filePrefix string, fileExtension string, outputFileSize uint, parallelFiles uint32, renameFiles bool, zipAlgo ZipAlgorithm, compression CompressionLevel) *FileWriterBase
func (*FileWriterBase) CloseAll ¶
func (j *FileWriterBase) CloseAll() error
CloseAll flushes and closes all writer in the pool Not safe to use concurrently with GetWriter() or writing
func (*FileWriterBase) GetWriter ¶
func (j *FileWriterBase) GetWriter() (io.WriteCloser, error)
type ZipAlgorithm ¶
type ZipAlgorithm int
ZipAlgorithm is the type of the zip algorithm to use.
const ( // ZipNone will not compress the output ZipNone ZipAlgorithm = iota // ZipDefault will choose the default compression algorithm. // which is currently ZipZSTD. ZipDefault // ZipDeflate will use the Deflate compression algorithm. // It will produce a .zip archive. // When using Deflate, consider adding some writeParallelism, // as it does not parallelize inherently. However, too much // writeParallelism comes with other downsides. ZipDeflate // ZipZSTD will use the ZSTD compression algorithm. // It will produce a .zst file // It provides the fastest and best compression. ZipZSTD // ZipGZIP will use the GZIP compression algorithm. // It will produce a .gz file // When using GZIP, consider adding some writeParallelism, // as it does not parallelize inherently. However, too much // writeParallelism comes with other downsides. ZipGZIP )
func GetZipAlgoFromExtensions ¶
func GetZipAlgoFromExtensions(fileName string) ZipAlgorithm
Click to show internal directories.
Click to hide internal directories.