From 7f5403eed95da4350dcc03d817eb8468dab07142 Mon Sep 17 00:00:00 2001 From: Alex Schmidt Date: Wed, 20 Mar 2013 16:00:06 +0100 Subject: [PATCH 1/1] only storing concurrent config file HASHES instead of full names. --- configcache.cpp | 8 ++++---- configcache.h | 2 +- hypercache.cpp | 18 ++++++++++-------- hypercache.h | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) 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 -- 2.39.5