diff --git a/Database/APR/RootStorageSvc/src/RootDatabase.cpp b/Database/APR/RootStorageSvc/src/RootDatabase.cpp index 971f9b14a256aa3bdcf0b344245b726b40d86cc2..a124cbee75f169a902d030ba6a867a2fce581951 100644 --- a/Database/APR/RootStorageSvc/src/RootDatabase.cpp +++ b/Database/APR/RootStorageSvc/src/RootDatabase.cpp @@ -43,7 +43,8 @@ using namespace std; /// Standard Constuctor RootDatabase::RootDatabase(IOODatabase* idb) : DbDatabaseImp(idb), m_file(0), - m_defCompression(1), + m_defCompression(1), + m_defCompressionAlg(1), m_defSplitLevel(99), m_defAutoSave(16*1024*1024), m_defBufferSize(16*1024), @@ -107,20 +108,23 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess const char* fname = nam.c_str(); Bool_t result = ( mode == pool::READ ) ? kFALSE : gSystem->AccessPathName(fname, kFileExists); DbOption opt1("DEFAULT_COMPRESSION",""); - DbOption opt2("DEFAULT_SPLITLEVEL",""); - DbOption opt3("DEFAULT_AUTOSAVE",""); - DbOption opt4("DEFAULT_BUFFERSIZE",""); - DbOption opt5("TREE_BRANCH_OFFSETTAB_LEN",""); + DbOption opt2("DEFAULT_COMPRESSIONALG",""); + DbOption opt3("DEFAULT_SPLITLEVEL",""); + DbOption opt4("DEFAULT_AUTOSAVE",""); + DbOption opt5("DEFAULT_BUFFERSIZE",""); + DbOption opt6("TREE_BRANCH_OFFSETTAB_LEN",""); domH.getOption(opt1); domH.getOption(opt2); domH.getOption(opt3); domH.getOption(opt4); domH.getOption(opt5); + domH.getOption(opt6); opt1._getValue(m_defCompression); - opt2._getValue(m_defSplitLevel); - opt3._getValue(m_defAutoSave); - opt4._getValue(m_defBufferSize); - opt5._getValue(m_branchOffsetTabLen); + opt2._getValue(m_defCompressionAlg); + opt3._getValue(m_defSplitLevel); + opt4._getValue(m_defAutoSave); + opt5._getValue(m_defBufferSize); + opt6._getValue(m_branchOffsetTabLen); //gDebug = 2; TDirectory::TContext dirCtxt(0); @@ -149,11 +153,9 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess } if ( mode == pool::READ ) { - if (m_fileMgr == 0) { m_file = TFile::Open(fname); } else { - void *vf(0); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::READ,vf,"POOL",false); if (r < 0) { @@ -164,13 +166,10 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess m_file = (TFile*)vf; } } - - } else if ( mode&pool::UPDATE && result == kFALSE ) { - if (m_fileMgr == 0) { - m_file = TFile::Open(fname, "UPDATE", fname, m_defCompression); + m_file = TFile::Open(fname, "UPDATE", fname); } else { void *vf(0); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::APPEND,vf,"POOL",true); @@ -180,16 +179,16 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess << DbPrint::endmsg; } else { m_file = (TFile*)vf; - if (m_file != 0) { - m_file->SetCompressionLevel(m_defCompression); - } } } - + if (m_file != 0) { + m_file->SetCompressionLevel(m_defCompression); + m_file->SetCompressionAlgorithm(m_defCompressionAlg); + } } else if ( pool::RECREATE == (mode&pool::RECREATE) ) { if (m_fileMgr == 0) { - m_file = TFile::Open(fname, "RECREATE", fname, m_defCompression); + m_file = TFile::Open(fname, "RECREATE", fname); } else { void *vf(0); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::WRITE|Io::CREATE,vf,"POOL",true); @@ -199,15 +198,16 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess << DbPrint::endmsg; } else { m_file = (TFile*)vf; - if (m_file != 0) { - m_file->SetCompressionLevel(m_defCompression); - } } } + if (m_file != 0) { + m_file->SetCompressionLevel(m_defCompression); + m_file->SetCompressionAlgorithm(m_defCompressionAlg); + } } else if ( mode&pool::CREATE && result == kTRUE ) { if (m_fileMgr == 0) { - m_file = TFile::Open(fname, "RECREATE", fname, m_defCompression); + m_file = TFile::Open(fname, "RECREATE", fname); } else { void *vf(0); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::WRITE|Io::CREATE,vf,"POOL",true); @@ -217,11 +217,12 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess << DbPrint::endmsg; } else { m_file = (TFile*)vf; - if (m_file != 0) { - m_file->SetCompressionLevel(m_defCompression); - } } } + if (m_file != 0) { + m_file->SetCompressionLevel(m_defCompression); + m_file->SetCompressionAlgorithm(m_defCompressionAlg); + } } else if ( mode&pool::CREATE && result == kFALSE ) { log << DbPrintLvl::Error << "You cannot open a ROOT file in mode CREATE" @@ -371,6 +372,8 @@ DbStatus RootDatabase::getOption(DbOption& opt) const { return Error; else if ( !strcasecmp(n, "COMPRESSION_LEVEL") ) // int return opt._setValue(int(m_file->GetCompressionLevel())); + else if ( !strcasecmp(n, "COMPRESSION_ALGORITHM") ) // int + return opt._setValue(int(m_file->GetCompressionAlgorithm())); else if ( !strcasecmp(n, "COMPRESSION_FACTOR") ) // float return opt._setValue(double(m_file->GetCompressionFactor())); else if ( !strcasecmp(n, "CONTAINER_SPLITLEVEL") ) { @@ -407,6 +410,8 @@ DbStatus RootDatabase::getOption(DbOption& opt) const { case 'D': if ( !strcasecmp(n,"DEFAULT_COMPRESSION") ) // int return opt._setValue(int(m_defCompression)); + else if ( !strcasecmp(n,"DEFAULT_COMPRESSIONALG") ) // int + return opt._setValue(int(m_defCompressionAlg)); else if ( !strcasecmp(n, "DEFAULT_SPLITLEVEL") ) // int return opt._setValue(int(m_defSplitLevel)); else if ( !strcasecmp(n, "DEFAULT_AUTOSAVE") ) // int @@ -512,6 +517,12 @@ DbStatus RootDatabase::setOption(const DbOption& opt) { m_file->SetCompressionLevel(val); return Success; } + else if ( !strcasecmp(n, "COMPRESSION_ALGORITHM") ) { + int val=1; + opt._getValue(val); + m_file->SetCompressionAlgorithm(val); + return Success; + } else if ( !strcasecmp(n, "CONTAINER_SPLITLEVEL") ) { if (!opt.option().size()) { DbPrint log("RootDatabase.setOption"); @@ -526,15 +537,17 @@ DbStatus RootDatabase::setOption(const DbOption& opt) { } break; case 'D': - if ( !strcasecmp(n, "DEFAULT_COMPRESSION") ) + if ( !strcasecmp(n, "DEFAULT_COMPRESSION") ) // int return opt._getValue(m_defCompression); - else if ( !strcasecmp(n, "DEFAULT_SPLITLEVEL") ) + else if ( !strcasecmp(n, "DEFAULT_COMPRESSIONALG") )// int + return opt._getValue(m_defCompressionAlg); + else if ( !strcasecmp(n, "DEFAULT_SPLITLEVEL") ) // int return opt._getValue(m_defSplitLevel); else if ( !strcasecmp(n, "DEFAULT_AUTOSAVE") ) // int return opt._getValue(m_defAutoSave); else if ( !strcasecmp(n, "DEFAULT_BUFFERSIZE") ) // int return opt._getValue(m_defBufferSize); - else if ( !strcasecmp(n, "DEFAULT_WRITEPOLICY") ) // int + else if ( !strcasecmp(n, "DEFAULT_WRITEPOLICY") ) // int return opt._getValue(m_defWritePolicy); break; case 'F': @@ -753,6 +766,8 @@ void RootDatabase::registerBranchContainer(RootTreeContainer* cont) /// Start/Commit/Rollback Database Transaction DbStatus RootDatabase::transAct(DbTransaction& refTr ) { + // process flush to write file + if( refTr.state() == Transaction::TRANSACT_FLUSH ) m_file->Write(); // process commits only if( refTr.state() != Transaction::TRANSACT_COMMIT ) return Success; diff --git a/Database/APR/RootStorageSvc/src/RootDatabase.h b/Database/APR/RootStorageSvc/src/RootDatabase.h index a5c8d96d1e337be04fe309fe3dfaa0ebdd593842..74a8401137714bbc794fd1fe8d58b77178b79fcf 100644 --- a/Database/APR/RootStorageSvc/src/RootDatabase.h +++ b/Database/APR/RootStorageSvc/src/RootDatabase.h @@ -51,6 +51,8 @@ namespace pool { long long int m_counters[3]; /// Default compression level int m_defCompression; + /// Default compressionalgorithm + int m_defCompressionAlg; /// Default split level int m_defSplitLevel; /// Default Autosave parameter for trees diff --git a/Database/APR/RootStorageSvc/src/RootDomain.cpp b/Database/APR/RootStorageSvc/src/RootDomain.cpp index 09f5d307c5c268c57b3a8feb5edcfe0c74ab86aa..907afa28e0d670b0a53b92d11403ca9cfc151b37 100755 --- a/Database/APR/RootStorageSvc/src/RootDomain.cpp +++ b/Database/APR/RootStorageSvc/src/RootDomain.cpp @@ -28,6 +28,7 @@ using namespace pool; RootDomain::RootDomain(IOODatabase* idb) : DbDomainImp(idb), m_defCompression(1), + m_defCompressionAlg(1), m_defSplitLevel(99), m_defAutoSave(16*1024*1024), m_defBufferSize(16*1024), @@ -62,6 +63,9 @@ DbStatus RootDomain::setOption(const DbOption& opt) { if ( !strcasecmp(n, "DEFAULT_COMPRESSION") ) { return opt._getValue(m_defCompression); } + else if ( !strcasecmp(n, "DEFAULT_COMPRESSIONALG") ) { + return opt._getValue(m_defCompressionAlg); + } else if ( !strcasecmp(n, "DEFAULT_SPLITLEVEL") ) { return opt._getValue(m_defSplitLevel); } @@ -148,6 +152,9 @@ DbStatus RootDomain::getOption(DbOption& opt) const { if ( !strcasecmp(n, "DEFAULT_COMPRESSION") ) { return opt._setValue(int(m_defCompression)); } + else if ( !strcasecmp(n, "DEFAULT_COMPRESSIONALG") ) { + return opt._setValue(int(m_defCompressionAlg)); + } else if ( !strcasecmp(n, "DEFAULT_SPLITLEVEL") ) { return opt._setValue(int(m_defSplitLevel)); } diff --git a/Database/APR/RootStorageSvc/src/RootDomain.h b/Database/APR/RootStorageSvc/src/RootDomain.h index 994f399dd16029753b4c3cda861c5d5a6859cba5..98b94e8cb89599273f5029295c1c3e2392915bf8 100755 --- a/Database/APR/RootStorageSvc/src/RootDomain.h +++ b/Database/APR/RootStorageSvc/src/RootDomain.h @@ -36,6 +36,8 @@ namespace pool { protected: /// Default compression level int m_defCompression; + /// Default compression algorithm + int m_defCompressionAlg; /// Default split level int m_defSplitLevel; /// Default Autosave parameter for trees diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp index a837c5da66a6cb436a3a19f63f5f7d329c2a87a3..2776a67ff9bae6244e34f2b9a270716ab2a1fa76 100755 --- a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp +++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp @@ -667,27 +667,24 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, branchOffsetTabLen=0, containerSplitLevel=defSplitLevel, auxSplitLevel=defSplitLevel; DbStatus res = Success; try { - DbOption opt1("DEFAULT_COMPRESSION",""); - DbOption opt2("DEFAULT_SPLITLEVEL",""); - DbOption opt3("DEFAULT_AUTOSAVE",""); - DbOption opt4("DEFAULT_BUFFERSIZE",""); - DbOption opt5("TREE_BRANCH_OFFSETTAB_LEN",""); - DbOption opt6("CONTAINER_SPLITLEVEL", m_name); - DbOption opt7("CONTAINER_SPLITLEVEL", RootAuxDynIO::AUX_POSTFIX); + DbOption opt1("DEFAULT_SPLITLEVEL",""); + DbOption opt2("DEFAULT_AUTOSAVE",""); + DbOption opt3("DEFAULT_BUFFERSIZE",""); + DbOption opt4("TREE_BRANCH_OFFSETTAB_LEN",""); + DbOption opt5("CONTAINER_SPLITLEVEL", m_name); + DbOption opt6("CONTAINER_SPLITLEVEL", RootAuxDynIO::AUX_POSTFIX); dbH.getOption(opt1); dbH.getOption(opt2); dbH.getOption(opt3); dbH.getOption(opt4); dbH.getOption(opt5); dbH.getOption(opt6); - dbH.getOption(opt7); - opt1._getValue(defCompression); - opt2._getValue(defSplitLevel); - opt3._getValue(defAutoSave); - opt4._getValue(defBufferSize); - opt5._getValue(branchOffsetTabLen); - opt6._getValue(containerSplitLevel); - opt7._getValue(auxSplitLevel); + opt1._getValue(defSplitLevel); + opt2._getValue(defAutoSave); + opt3._getValue(defBufferSize); + opt4._getValue(branchOffsetTabLen); + opt5._getValue(containerSplitLevel); + opt6._getValue(auxSplitLevel); if (containerSplitLevel == defSplitLevel) { if ( (m_name.size() >= 5 && m_name.substr(m_name.size()-5, 4) == RootAuxDynIO::AUX_POSTFIX) || info->clazz().Properties().HasProperty("IAuxStore") ) containerSplitLevel = auxSplitLevel; @@ -1017,6 +1014,8 @@ DbStatus RootTreeContainer::getOption(DbOption& opt) const { case 'C': if ( !strcasecmp(n+7,"COMPRESSION_LEVEL") ) return opt._setValue(int(b->GetCompressionLevel())); + if ( !strcasecmp(n+7,"COMPRESSION_ALGORITHM") ) + return opt._setValue(int(b->GetCompressionAlgorithm())); break; case 'E': if ( !strcasecmp(n+7,"ENTRIES") ) @@ -1139,6 +1138,12 @@ DbStatus RootTreeContainer::setOption(const DbOption& opt) { b->SetCompressionLevel(val); return Success; } + if ( !strcasecmp(n+7,"COMPRESSION_ALGORITHM") ) { + int val=1; + opt._getValue(val); + b->SetCompressionAlgorithm(val); + return Success; + } break; case 'P': if ( !strcasecmp(n+7,"PRINT") ) {