# HG changeset patch # User mas01cr # Date 1193758128 0 # Node ID 7162a8e9ab122e634d54d5af04c552695a1e5dcc # Parent 6ae98686811434ca2cb6e2958f604a9e7dbd5783 Hack in batchinsert support for power. diff -r 6ae986868114 -r 7162a8e9ab12 audioDB.cpp --- 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 diff -r 6ae986868114 -r 7162a8e9ab12 audioDB.h --- 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), \