# HG changeset patch # User mas01cr # Date 1195146295 0 # Node ID c22d532191127e46301e9a5c09caea2ca6063689 # Parent d434e771c7763d884f46981905de6a0674e860fd inserting the data vectors goes through lseek()/write() diff -r d434e771c776 -r c22d53219112 audioDB.cpp --- a/audioDB.cpp Thu Nov 15 16:38:53 2007 +0000 +++ b/audioDB.cpp Thu Nov 15 17:04:55 2007 +0000 @@ -546,6 +546,11 @@ return(dbH->timesTableOffset > dbH->dataOffset + dbH->length + size); } +void audioDB::insert_data_vectors(off_t offset, void *buffer, size_t size) { + lseek(dbfid, dbH->dataOffset + offset, SEEK_SET); + write(dbfid, buffer, size); +} + void audioDB::insert(const char* dbName, const char* inFile) { forWrite = true; initTables(dbName, inFile); @@ -606,8 +611,7 @@ // Update track to file index map memcpy (trackTable+dbH->numFiles-1, &numVectors, sizeof(unsigned)); - // Update the feature database - memcpy (((char *) dataBuf) + insertoffset, indata+sizeof(int), statbuf.st_size-sizeof(int)); + insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); // Norm the vectors on input if the database is already L2 normed if(dbH->flags & O2_FLAG_L2NORM) @@ -776,7 +780,8 @@ // Update track to file index map memcpy (trackTable+dbH->numFiles-1, &numVectors, sizeof(unsigned)); - // Update the feature database + insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); + memcpy (((char *) dataBuf) + insertoffset, indata+sizeof(int), statbuf.st_size-sizeof(int)); // Norm the vectors on input if the database is already L2 normed diff -r d434e771c776 -r c22d53219112 audioDB.h --- a/audioDB.h Thu Nov 15 16:38:53 2007 +0000 +++ b/audioDB.h Thu Nov 15 17:04:55 2007 +0000 @@ -200,6 +200,7 @@ void create(const char* dbName); void drop(); bool enough_data_space_free(off_t size); + void insert_data_vectors(off_t offset, void *buffer, size_t size); void insert(const char* dbName, const char* inFile); void batchinsert(const char* dbName, const char* inFile); void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);