Mercurial > hg > audiodb
changeset 145:7162a8e9ab12 powertable
Hack in batchinsert support for power.
author | mas01cr |
---|---|
date | Tue, 30 Oct 2007 15:28:48 +0000 |
parents | 6ae986868114 |
children | c9c508be69b3 |
files | audioDB.cpp audioDB.h |
diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Tue Oct 30 15:13:01 2007 +0000 +++ b/audioDB.cpp Tue Oct 30 15:28:48 2007 +0000 @@ -270,6 +270,14 @@ usingTimes=1; } } + if(args_info.powerList_given){ + powerFileName=args_info.powerList_arg; + if(strlen(powerFileName)>0){ + if(!(powerFile = new ifstream(powerFileName,ios::in))) + error("Could not open powerList file for reading", powerFileName); + usingPower=1; + } + } return 0; } @@ -684,6 +692,7 @@ ifstream *filesIn = 0; ifstream *keysIn = 0; ifstream* thisTimesFile = 0; + int thispowerfd = 0; if(!(filesIn = new ifstream(inFile))) error("Could not open batch in file", inFile); @@ -698,6 +707,7 @@ char *thisKey = new char[MAXSTR]; char *thisFile = new char[MAXSTR]; char *thisTimesFileName = new char[MAXSTR]; + char *thisPowerFileName = new char[MAXSTR]; do{ filesIn->getline(thisFile,MAXSTR); @@ -707,6 +717,8 @@ thisKey = thisFile; if(usingTimes) timesFile->getline(thisTimesFileName,MAXSTR); + if(usingPower) + powerFile->getline(thisPowerFileName, MAXSTR); if(filesIn->eof()) break; @@ -764,7 +776,7 @@ cerr << "Warning: ignoring zero-length feature vector file:" << thisKey << endl; } } - else{ + else{ if(usingTimes){ if(timesFile->eof()) error("not enough timestamp files in timesList"); @@ -779,7 +791,23 @@ if(thisTimesFile) delete thisTimesFile; } - + + if (usingPower) { + if(powerFile->eof()) { + error("not enough power files in powerList", powerFileName); + } + thispowerfd = open(thisPowerFileName, O_RDONLY); + if (thispowerfd < 0) { + error("failed to open power file", thisPowerFileName); + } + unsigned insertoffset = dbH->length; + unsigned poweroffset = insertoffset / (dbH->dim * sizeof(double)); + double *powerdata = powerTable + poweroffset; + insertPowerData(numVectors, thispowerfd, powerdata); + if (0 < thispowerfd) { + close(thispowerfd); + } + } strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, thisKey, strlen(thisKey)); unsigned insertoffset = dbH->length;// Store current state
--- a/audioDB.h Tue Oct 30 15:13:01 2007 +0000 +++ b/audioDB.h Tue Oct 30 15:28:48 2007 +0000 @@ -126,6 +126,7 @@ const char *timesFileName; ifstream *timesFile; const char *powerFileName; + ifstream *powerFile; int powerfd; int dbfid; @@ -219,6 +220,7 @@ timesFileName(0), \ timesFile(0), \ powerFileName(0), \ + powerFile(0), \ powerfd(0), \ dbfid(0), \ infid(0), \