Unhashed parastrings are stored in first line of cachefiles and checked on open.
Using hashed parameter string for cache file names.
Generating parastring in seperate function.
Write parastring into first line of cachefile.
Checking unhashed parastring when opening cachefile.
refetchDataFiles = false;
}
refetchDataFiles = false;
}
+string configcache::paraString() {
+ stringstream parastring;
+
+ for(int ipara=0; ipara<Paras.size(); ipara++)
+ parastring << "_" << Paras[ipara].id << Paras[ipara].val;
+
+ return parastring.str();
+}
+
string configcache::getFileId(int actnequi, const bool& shortid)
{
stringstream fileid;
if(!shortid) fileid << CACHEID << "_" << actnequi << "_" << NSKIP;
string configcache::getFileId(int actnequi, const bool& shortid)
{
stringstream fileid;
if(!shortid) fileid << CACHEID << "_" << actnequi << "_" << NSKIP;
- for(int ipara=0; ipara<Paras.size(); ipara++)
- fileid << "_" << Paras[ipara].id << Paras[ipara].val;
+
+ fileid << "_" << hash( paraString() );
}
while( (!inFile.is_open()) && inFiles.size() > 0 ) {
}
while( (!inFile.is_open()) && inFiles.size() > 0 ) {
+ string inFileParaString;
+
openFileDesc = *inFileIt;
if (openFileDesc.nequi < NEQUI)
openFileDesc = *inFileIt;
if (openFileDesc.nequi < NEQUI)
if(log) *log << "CCACHE: Opening dat-file: " << inFileIt->filename << endl << flush;
inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary );
if(log) *log << "CCACHE: Opening dat-file: " << inFileIt->filename << endl << flush;
inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary );
+ getline( inFile, inFileParaString );
+ if( inFileParaString != paraString() ) {
+ if(log) *log << "CCACHE: Parastring does not match. Closing dat-file..." << endl << flush;
+ inFile.close();
+ }
+
inFiles.erase(inFileIt);
if( !inFile.is_open() ) continue;
inFiles.erase(inFileIt);
if( !inFile.is_open() ) continue;
outFile.open( outFileName.str().c_str(), std::ios::binary );
outFile.open( outFileName.str().c_str(), std::ios::binary );
+ outFile << paraString() << endl;
+
ioBuffers->out = new boost::iostreams::filtering_ostreambuf;
ioBuffers->out->push(boost::iostreams::bzip2_compressor());
ioBuffers->out->push(outFile);
ioBuffers->out = new boost::iostreams::filtering_ostreambuf;
ioBuffers->out->push(boost::iostreams::bzip2_compressor());
ioBuffers->out->push(outFile);
int nequileft_internal;
bool doVirtualEquilibration, firstUsedConfig;
int nequileft_internal;
bool doVirtualEquilibration, firstUsedConfig;