Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:15

0001 // @(#)root/zip:$Id$
0002 // Author: David Dagenhart   May 2011
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_Compression
0013 #define ROOT_Compression
0014 
0015 #include "RtypesCore.h"
0016 
0017 #include <string>
0018 
0019 namespace ROOT {
0020 
0021 /// The global settings depend on a global variable named R__ZipMode which can be
0022 /// modified by a global function named R__SetZipMode. Both are defined in Bits.h.
0023 ///
0024 ///  - The default is to use the global setting and the default of the global
0025 ///    setting is to use the ZLIB compression algorithm.
0026 ///  - The LZMA algorithm (from the XZ package) is also available. The LZMA
0027 ///    compression usually results in greater compression factors, but takes
0028 ///    more CPU time and memory when compressing. LZMA memory usage is particularly
0029 ///    high for compression levels 8 and 9.
0030 ///  - Finally, the LZ4 package results in worse compression ratios
0031 ///    than ZLIB but achieves much faster decompression rates.
0032 ///
0033 /// The current algorithms support level 1 to 9. The higher the level the greater
0034 /// the compression and more CPU time and memory resources used during compression.
0035 /// Level 0 means no compression.
0036 ///
0037 /// Recommendation for the compression algorithm's levels:
0038 ///  - ZLIB is recommended to be used with compression level 1 [101]
0039 ///  - LZMA is recommended to be used with compression level 7-8 (higher is better,
0040 ///   since in the case of LZMA we don't care about compression/decompression speed)
0041 ///   [207 - 208]
0042 ///  - LZ4 is recommended to be used with compression level 4 [404]
0043 ///  - ZSTD is recommended to be used with compression level 5 [505]
0044 
0045 struct RCompressionSetting {
0046    struct EDefaults { /// Note: this is only temporarily a struct and will become a enum class hence the name convention
0047                       /// used.
0048       enum EValues {
0049          /// Use the global compression setting for this process; may be affected by rootrc.
0050          kUseGlobal = 0,
0051          /// Use the compile-time default setting
0052          kUseCompiledDefault = 101,
0053          /// Use the default analysis setting; fast reading but poor compression ratio
0054          kUseAnalysis = 404,
0055          /// Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/decompression speed
0056          kUseGeneralPurpose = 505,
0057          /// Use the setting that results in the smallest files; very slow read and write
0058          kUseSmallest = 207,
0059       };
0060    };
0061    struct ELevel { /// Note: this is only temporarily a struct and will become a enum class hence the name convention
0062                    /// used.
0063       enum EValues {
0064          /// Some objects use this value to denote that the compression algorithm
0065          /// should be inherited from the parent object
0066          kInherit = -1,
0067          /// Compression level reserved for "uncompressed state"
0068          kUncompressed = 0,
0069          /// Compression level reserved when we are not sure what to use (1 is for the fastest compression)
0070          kUseMin = 1,
0071          /// Compression level reserved for ZLIB compression algorithm (fastest compression)
0072          kDefaultZLIB = 1,
0073          /// Compression level reserved for LZ4 compression algorithm (trade-off between file ratio/decompression speed)
0074          kDefaultLZ4 = 4,
0075          /// Compression level reserved for ZSTD compression algorithm (trade-off between file ratio/decompression speed)
0076          kDefaultZSTD = 5,
0077          /// Compression level reserved for old ROOT compression algorithm
0078          kDefaultOld = 6,
0079          /// Compression level reserved for LZMA compression algorithm (slowest compression with smallest files)
0080          kDefaultLZMA = 7
0081       };
0082    };
0083    struct EAlgorithm { /// Note: this is only temporarily a struct and will become a enum class hence the name
0084                         /// convention used.
0085       enum EValues {
0086          /// Some objects use this value to denote that the compression algorithm
0087          /// should be inherited from the parent object (e.g., TBranch should get the algorithm from the TTree)
0088          kInherit = -1,
0089          /// Use the global compression algorithm
0090          kUseGlobal = 0,
0091          /// Use ZLIB compression
0092          kZLIB,
0093          /// Use LZMA compression
0094          kLZMA,
0095          /// Use the old compression algorithm
0096          kOldCompressionAlgo,
0097          /// Use LZ4 compression
0098          kLZ4,
0099          /// Use ZSTD compression
0100          kZSTD,
0101          /// Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added).
0102          kUndefined
0103       };
0104    };
0105 
0106    static std::string AlgorithmToString(EAlgorithm::EValues algorithm);
0107 };
0108 
0109 enum ECompressionAlgorithm {
0110    /// Deprecated name, do *not* use:
0111    kUseGlobalCompressionSetting = RCompressionSetting::EAlgorithm::kUseGlobal,
0112    /// Deprecated name, do *not* use:
0113    kUseGlobalSetting = RCompressionSetting::EAlgorithm::kUseGlobal,
0114    /// Deprecated name, do *not* use:
0115    kZLIB = RCompressionSetting::EAlgorithm::kZLIB,
0116    /// Deprecated name, do *not* use:
0117    kLZMA = RCompressionSetting::EAlgorithm::kLZMA,
0118    /// Deprecated name, do *not* use:
0119    kOldCompressionAlgo = RCompressionSetting::EAlgorithm::kOldCompressionAlgo,
0120    /// Deprecated name, do *not* use:
0121    kLZ4 = RCompressionSetting::EAlgorithm::kLZ4,
0122    /// Deprecated name, do *not* use:
0123    kZSTD = RCompressionSetting::EAlgorithm::kZSTD,
0124    /// Deprecated name, do *not* use:
0125    kUndefinedCompressionAlgorithm = RCompressionSetting::EAlgorithm::kUndefined
0126 };
0127 
0128 int CompressionSettings(RCompressionSetting::EAlgorithm::EValues algorithm, int compressionLevel);
0129 /// Deprecated name, do *not* use:
0130 int CompressionSettings(ROOT::ECompressionAlgorithm algorithm, int compressionLevel);
0131 } // namespace ROOT
0132 
0133 #endif