Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Compression.h
Go to the documentation of this file.
1 // @(#)root/zip:$Id$
2 // Author: David Dagenhart May 2011
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_Compression
13 #define ROOT_Compression
14 
15 #include "Rtypes.h"
16 
17 namespace ROOT {
18 
19 /// The global settings depend on a global variable named R__ZipMode which can be
20 /// modified by a global function named R__SetZipMode. Both are defined in Bits.h.
21 ///
22 /// - The default is to use the global setting and the default of the global
23 /// setting is to use the ZLIB compression algorithm.
24 /// - The LZMA algorithm (from the XZ package) is also available. The LZMA
25 /// compression usually results in greater compression factors, but takes
26 /// more CPU time and memory when compressing. LZMA memory usage is particularly
27 /// high for compression levels 8 and 9.
28 /// - Finally, the LZ4 package results in worse compression ratios
29 /// than ZLIB but achieves much faster decompression rates.
30 ///
31 /// The current algorithms support level 1 to 9. The higher the level the greater
32 /// the compression and more CPU time and memory resources used during compression.
33 /// Level 0 means no compression.
34 ///
35 /// Recommendation for the compression algorithm's levels:
36 /// - ZLIB is recommended to be used with compression level 1 [101]
37 /// - LZMA is recommended to be used with compression level 7-8 (higher is better,
38 /// since in the case of LZMA we don't care about compression/decompression speed)
39 /// [207 - 208]
40 /// - LZ4 is recommended to be used with compression level 4 [404]
41 /// - ZSTD is recommended to be used with compression level 5 [505]
42 
43 struct RCompressionSetting {
44  struct EDefaults { /// Note: this is only temporarily a struct and will become a enum class hence the name convention
45  /// used.
46  enum EValues {
47  /// Use the global compression setting for this process; may be affected by rootrc.
48  kUseGlobal = 0,
49  /// Use the compile-time default setting
50  kUseCompiledDefault = 101,
51  /// Use the default analysis setting; fast reading but poor compression ratio
52  kUseAnalysis = 404,
53  /// Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/decompression speed
54  kUseGeneralPurpose = 505,
55  /// Use the setting that results in the smallest files; very slow read and write
56  kUseSmallest = 207,
57  };
58  };
59  struct ELevel { /// Note: this is only temporarily a struct and will become a enum class hence the name convention
60  /// used.
61  enum EValues {
62  /// Some objects use this value to denote that the compression algorithm
63  /// should be inherited from the parent object
64  kInherit = -1,
65  // Compression level reserved for "uncompressed state"
66  kUncompressed = 0,
67  // Compression level reserved when we are not sure what to use (1 is for the fastest compression)
68  kUseMin = 1,
69  kDefaultZLIB = 1,
70  kDefaultLZ4 = 4,
71  kDefaultZSTD = 5,
72  kDefaultOld = 6,
73  kDefaultLZMA = 7
74  };
75  };
76  struct EAlgorithm { /// Note: this is only temporarily a struct and will become a enum class hence the name
77  /// convention used.
78  enum EValues {
79  /// Some objects use this value to denote that the compression algorithm
80  /// should be inherited from the parent object (e.g., TBranch should get the algorithm from the TTree)
81  kInherit = -1,
82  /// Use the global compression algorithm
83  kUseGlobal = 0,
84  /// Use ZLIB compression
85  kZLIB,
86  /// Use LZMA compression
87  kLZMA,
88  /// Use the old compression algorithm
89  kOldCompressionAlgo,
90  /// Use LZ4 compression
91  kLZ4,
92  /// Use ZSTD compression
93  kZSTD,
94  /// Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added).
95  kUndefined
96  };
97  };
98 };
99 
100 enum ECompressionAlgorithm {
101  /// Deprecated name, do *not* use:
102  kUseGlobalCompressionSetting = RCompressionSetting::EAlgorithm::kUseGlobal,
103  /// Deprecated name, do *not* use:
104  kUseGlobalSetting = RCompressionSetting::EAlgorithm::kUseGlobal,
105  /// Deprecated name, do *not* use:
106  kZLIB = RCompressionSetting::EAlgorithm::kZLIB,
107  /// Deprecated name, do *not* use:
108  kLZMA = RCompressionSetting::EAlgorithm::kLZMA,
109  /// Deprecated name, do *not* use:
110  kOldCompressionAlgo = RCompressionSetting::EAlgorithm::kOldCompressionAlgo,
111  /// Deprecated name, do *not* use:
112  kLZ4 = RCompressionSetting::EAlgorithm::kLZ4,
113  /// Deprecated name, do *not* use:
114  kZSTD = RCompressionSetting::EAlgorithm::kZSTD,
115  /// Deprecated name, do *not* use:
116  kUndefinedCompressionAlgorithm = RCompressionSetting::EAlgorithm::kUndefined
117 };
118 
119 int CompressionSettings(RCompressionSetting::EAlgorithm algorithm, int compressionLevel);
120 /// Deprecated name, do *not* use:
121 int CompressionSettings(ROOT::ECompressionAlgorithm algorithm, int compressionLevel);
122 } // namespace ROOT
123 
124 #endif