changeset 181:c22d53219112 no-big-mmap

inserting the data vectors goes through lseek()/write()
author mas01cr
date Thu, 15 Nov 2007 17:04:55 +0000
parents d434e771c776
children a6853791a275
files audioDB.cpp audioDB.h
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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);