# HG changeset patch # User mas01cr # Date 1193757181 0 # Node ID 6ae98686811434ca2cb6e2958f604a9e7dbd5783 # Parent 9bcece53de9e75d7569b58daec023753da3f950c Hack in power table filling for single track insert. diff -r 9bcece53de9e -r 6ae986868114 audioDB.cpp --- a/audioDB.cpp Tue Oct 30 14:39:12 2007 +0000 +++ b/audioDB.cpp Tue Oct 30 15:13:01 2007 +0000 @@ -234,6 +234,15 @@ usingTimes=1; } } + if (args_info.power_given) { + powerFileName = args_info.power_arg; + if (strlen(powerFileName) > 0) { + if (!(powerfd = open(powerFileName, O_RDONLY))) { + error("Could not open power file for reading", powerFileName, "open"); + } + usingPower = 1; + } + } return 0; } @@ -556,6 +565,9 @@ assert(timesdata+numVectorsnumFiles++; @@ -641,6 +653,28 @@ } } +void audioDB::insertPowerData(unsigned numVectors, int powerfd, double *powerdata) { + if (usingPower) { + int one; + unsigned int count; + + count = read(powerfd, &one, sizeof(unsigned int)); + if (count != sizeof(unsigned int)) { + error("powerfd read failed", "int", "read"); + } + if (one != 1) { + error("dimensionality of power file not 1", powerFileName); + } + + // FIXME: should check that the powerfile is the right size for + // this. -- CSR, 2007-10-30 + count = read(powerfd, powerdata, numVectors * sizeof(double)); + if (count != numVectors * sizeof(double)) { + error("powerfd read failed", "double", "read"); + } + } +} + void audioDB::batchinsert(const char* dbName, const char* inFile) { initDBHeader(dbName, true); diff -r 9bcece53de9e -r 6ae986868114 audioDB.h --- a/audioDB.h Tue Oct 30 14:39:12 2007 +0000 +++ b/audioDB.h Tue Oct 30 15:13:01 2007 +0000 @@ -125,6 +125,8 @@ const char *output; const char *timesFileName; ifstream *timesFile; + const char *powerFileName; + int powerfd; int dbfid; int infid; @@ -154,6 +156,7 @@ unsigned queryPoint; unsigned usingQueryPoint; unsigned usingTimes; + unsigned usingPower; unsigned isClient; unsigned isServer; unsigned port; @@ -176,6 +179,7 @@ void unitNorm(double* X, unsigned d, unsigned n, double* qNorm); void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append); void insertTimeStamps(unsigned n, ifstream* timesFile, double* timesdata); + void insertPowerData(unsigned n, int powerfd, double *powerdata); unsigned getKeyPos(char* key); public: @@ -214,6 +218,8 @@ output(0), \ timesFileName(0), \ timesFile(0), \ + powerFileName(0), \ + powerfd(0), \ dbfid(0), \ infid(0), \ db(0), \ @@ -235,6 +241,7 @@ queryPoint(0), \ usingQueryPoint(0), \ usingTimes(0), \ + usingPower(0), \ isClient(0), \ isServer(0), \ port(0), \