/
compress.go
53 lines (45 loc) · 1.35 KB
/
compress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright ©2018 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package riofs
import (
"go-hep.org/x/hep/groot/internal/rcompress"
)
func (f *File) setCompression(alg rcompress.Kind, lvl int) {
f.compression = rcompress.Settings{Alg: alg, Lvl: lvl}.Compression()
}
// WithLZ4 configures a ROOT file to use LZ4 as a compression mechanism.
func WithLZ4(level int) FileOption {
return func(f *File) error {
f.setCompression(rcompress.LZ4, level)
return nil
}
}
// WithLZMA configures a ROOT file to use LZMA as a compression mechanism.
func WithLZMA(level int) FileOption {
return func(f *File) error {
f.setCompression(rcompress.LZMA, level)
return nil
}
}
// WithoutCompression configures a ROOT file to not use any compression mechanism.
func WithoutCompression() FileOption {
return func(f *File) error {
f.setCompression(0, 0)
return nil
}
}
// WithZlib configures a ROOT file to use zlib as a compression mechanism.
func WithZlib(level int) FileOption {
return func(f *File) error {
f.setCompression(rcompress.ZLIB, level)
return nil
}
}
// WithZstd configures a ROOT file to use zstd as a compression mechanism.
func WithZstd(level int) FileOption {
return func(f *File) error {
f.setCompression(rcompress.ZSTD, level)
return nil
}
}