Mercurial > hg > audiodb
diff index.cpp @ 321:da2272e029b3 large_adb
Added --adb_feature_root=path filename prefix for locating LARGE_ADB features with relative paths at QUERY time. Also added convenience argument --adb_root=path prefix for -d database command option.
author | mas01mc |
---|---|
date | Thu, 21 Aug 2008 19:16:21 +0000 |
parents | a995e5ad999a |
children | 64c844de82d0 |
line wrap: on
line diff
--- a/index.cpp Wed Aug 20 13:50:58 2008 +0000 +++ b/index.cpp Thu Aug 21 19:16:21 2008 +0000 @@ -57,6 +57,10 @@ return true; } +// If we are a server and have a memory-resident index, check the indexName against the resident index (using get_indexName()) +// If they match, i.e. path+dbName_resident == path+dbName_requested, use +// the memory-resident index. +// Else allocate a new LSH instance and load the index from disk LSH* audioDB::index_allocate(char* indexName, bool load_hashTables){ LSH* gIndx=SERVER_LSH_INDEX_SINGLETON; if(isServer && gIndx && (strncmp(gIndx->get_indexName(), indexName, MAXSTR)==0) ) @@ -245,18 +249,24 @@ // Allocate and read the power sequence if(trackTable[trackID]>=sequenceLength){ - + + char* prefixedString = new char[O2_MAXFILESTR]; + char* tmpStr = prefixedString; // Open and check dimensions of power file - powerfd = open(powerFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE, O_RDONLY); + strncpy(prefixedString, powerFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE, O2_MAXFILESTR); + prefix_name((char ** const)&prefixedString, adb_feature_root); + if(prefixedString!=tmpStr) + delete[] tmpStr; + powerfd = open(prefixedString, O_RDONLY); if (powerfd < 0) { - error("failed to open power file", powerFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE); + error("failed to open power file", prefixedString); } if (fstat(powerfd, &statbuf) < 0) { - error("fstat error finding size of power file", powerFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE, "fstat"); + error("fstat error finding size of power file", prefixedString, "fstat"); } if( (statbuf.st_size - sizeof(int)) / (sizeof(double)) != trackTable[trackID] ) - error("Dimension mismatch: numPowers != numVectors", powerFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE); + error("Dimension mismatch: numPowers != numVectors", prefixedString); *sPowerp = new double[trackTable[trackID]]; // Allocate memory for power values assert(*sPowerp); @@ -292,8 +302,14 @@ int trackfd = dbfid; for(trackID = start_track ; trackID < end_track ; trackID++ ){ if( dbH->flags & O2_FLAG_LARGE_ADB ){ + char* prefixedString = new char[O2_MAXFILESTR]; + char* tmpStr = prefixedString; // Open and check dimensions of feature file - initInputFile(featureFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE, false); // nommap, file pointer at correct position + strncpy(prefixedString, featureFileNameTable+trackID*O2_FILETABLE_ENTRY_SIZE, O2_MAXFILESTR); + prefix_name((char ** const) &prefixedString, adb_feature_root); + if(prefixedString!=tmpStr) + delete[] tmpStr; + initInputFile(prefixedString, false); // nommap, file pointer at correct position trackfd = infid; } read_data(trackfd, trackID, &fvp, &nfv); // over-writes fvp and nfv