From: Alex Schmidt Date: Wed, 20 Mar 2013 15:00:06 +0000 (+0100) Subject: only storing concurrent config file HASHES instead of full names. X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/7f5403eed95da4350dcc03d817eb8468dab07142?ds=sidebyside only storing concurrent config file HASHES instead of full names. --- diff --git a/configcache.cpp b/configcache.cpp index b375230..1095775 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -172,7 +172,7 @@ void * configcache::getHeader(const string& headerid) { return NULL; } -bool configcache::readConfig(vector *excludefiles) +bool configcache::readConfig(vector *excludeFileHashes) { if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return false; @@ -190,9 +190,9 @@ bool configcache::readConfig(vector *excludefiles) openFileDesc = inFiles.back(); - if (excludefiles != NULL) - for (vector::iterator exit = excludefiles->begin(); exit != excludefiles->end(); ++exit) - if ( *exit == inFiles.back().filename ) { + if (excludeFileHashes != NULL) + for (vector::iterator exit = excludeFileHashes->begin(); exit != excludeFileHashes->end(); ++exit) + if ( *exit == hash(inFiles.back().filename) ) { excludethisfile = true; break; } diff --git a/configcache.h b/configcache.h index eaf610a..17c8606 100644 --- a/configcache.h +++ b/configcache.h @@ -38,7 +38,7 @@ class configcache{ ~configcache(); configcache(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, writeout *out_a=NULL); - bool readConfig(vector *excludefiles=NULL); + bool readConfig(vector *excludeFileHashes=NULL); void writeConfig(); void addPara(const string& parid, const double& val=0); void setPara(const string& parid, const double& value); diff --git a/hypercache.cpp b/hypercache.cpp index 16de2a2..b025ba6 100644 --- a/hypercache.cpp +++ b/hypercache.cpp @@ -5,7 +5,7 @@ configcache *hypercache::C = NULL; vector hypercache::delayedParaAdd; vector hypercache::delayedParaSet; string hypercache::activeCFile = ""; -vector hypercache::parentConfigs; +vector hypercache::parentConfigs; writeout *hypercache::out = NULL; void hypercache::initCache(configcache **cache, @@ -88,8 +88,10 @@ void hypercache::writeC() { } void hypercache::writeO() { - if ( activeCFile != "" ) - O->writeHeader("concurrent_cfile", activeCFile.c_str(), (activeCFile.length()+1)*sizeof(char)); + if ( activeCFile != "" ) { + unsigned long afilehash = configcache::hash(activeCFile); + O->writeHeader("concurrent_cfile", (char*)(&afilehash), sizeof(unsigned long)); + } O->writeConfig(); } @@ -98,7 +100,7 @@ bool hypercache::readO() { bool readret; if ( readret = O->readConfig() ) { - char *parentconfig = (char*)O->getHeader("concurrent_cfile"); + unsigned long *parentconfig = (unsigned long*)O->getHeader("concurrent_cfile"); if ( parentconfig != NULL ) addParentConfig(parentconfig); } @@ -106,10 +108,10 @@ bool hypercache::readO() { return readret; } -void hypercache::addParentConfig(const char* parentconfig) { - for (vector::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit) - if ( *parit == parentconfig ) +void hypercache::addParentConfig(const unsigned long *parentconfig) { + for (vector::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit) + if ( *parit == *parentconfig ) return; - parentConfigs.push_back(parentconfig); + parentConfigs.push_back(*parentconfig); } diff --git a/hypercache.h b/hypercache.h index f37bb0f..11e1565 100644 --- a/hypercache.h +++ b/hypercache.h @@ -52,8 +52,8 @@ class hypercache { static string fileOfPath(const string& dressedfile); static string activeCFile; - static vector parentConfigs; - static void addParentConfig(const char* parentconfig); + static vector parentConfigs; + static void addParentConfig(const unsigned long *parentconfig); }; #endif