diff audioDB.cpp @ 538:02e0a9ecfd0f multiprobeLSH

Added back single-query point I/O behaviour from pre API-inversion. Thus only those query vectors required are loaded when using query-from-file. Tests 0006 and 0007 fail silently with this change.
author mas01mc
date Fri, 06 Feb 2009 21:08:35 +0000
parents c7bdb7913762
children 283b412083db
line wrap: on
line diff
--- a/audioDB.cpp	Tue Feb 03 02:04:06 2009 +0000
+++ b/audioDB.cpp	Fri Feb 06 21:08:35 2009 +0000
@@ -737,7 +737,7 @@
     }
   } while(!filesIn->eof());
 
-  VERB_LOG(0, "%s %s %u vectors %ju bytes.\n", COM_BATCHINSERT, dbName, totalVectors, (intmax_t) (totalVectors * dbH->dim * sizeof(double)));
+  VERB_LOG(0, "%s %s %u vectors %ju bytes.\n", COM_BATCHINSERT, dbName, totalVectors, (intmax_t) (totalVectors * adb->header->dim * sizeof(double)));
 
   delete [] thisPowerFileName;
   if(key && (key != inFile)) {
@@ -831,10 +831,19 @@
     }
     fstat(fd, &st);
     read(fd, &datum.dim, sizeof(uint32_t));
-    datum.nvectors = (st.st_size - sizeof(uint32_t)) / (datum.dim * sizeof(double));
-    datum.data = (double *) malloc(st.st_size - sizeof(uint32_t));
-    read(fd, datum.data, st.st_size - sizeof(uint32_t));
-    close(fd);
+    if(usingQueryPoint){
+      datum.nvectors = sequenceLength;
+      datum.data = (double *) malloc(datum.nvectors*datum.dim*sizeof(double));
+      lseek(fd, queryPoint*sizeof(double)*datum.dim, SEEK_CUR);
+      read(fd, datum.data, datum.nvectors*datum.dim*sizeof(double));
+      close(fd);
+    }
+    else{
+      datum.nvectors = (st.st_size - sizeof(uint32_t)) / (datum.dim * sizeof(double));
+      datum.data = (double *) malloc(st.st_size - sizeof(uint32_t));
+      read(fd, datum.data, st.st_size - sizeof(uint32_t));
+      close(fd);
+    }
     if(usingPower) {
       uint32_t one;
       fd = open(powerFileName, O_RDONLY);
@@ -846,8 +855,10 @@
         error("malformed power file dimensionality", powerFileName);
       }
       datum.power = (double *) malloc(datum.nvectors * sizeof(double));
+      if(usingQueryPoint)
+	lseek(fd, queryPoint*sizeof(double), SEEK_CUR);
       if(read(fd, datum.power, datum.nvectors * sizeof(double)) != (ssize_t) (datum.nvectors * sizeof(double))) {
-        error("malformed power file", powerFileName);
+	error("malformed power file", powerFileName);
       }
       close(fd);
     }
@@ -862,7 +873,10 @@
   qspec.qid.flags = 0;
   qspec.qid.flags |= usingQueryPoint ? 0 : ADB_QID_FLAG_EXHAUSTIVE;
   qspec.qid.flags |= lsh_exact ? 0 : ADB_QID_FLAG_ALLOW_FALSE_POSITIVES;
-  qspec.qid.sequence_start = queryPoint;
+  if(usingQueryPoint)
+    qspec.qid.sequence_start = 0;
+  else
+    qspec.qid.sequence_start = queryPoint;
 
   switch(queryType) {
   case O2_POINT_QUERY:
@@ -912,7 +926,7 @@
     if(!(qspec.refine.flags & ADB_REFINE_RADIUS)) {
       error("query-type not yet supported");
     } else {
-      reporter = new trackSequenceQueryRadNNReporterOneToOne(pointNN,trackNN, dbH->numFiles);
+      reporter = new trackSequenceQueryRadNNReporterOneToOne(pointNN,trackNN, adb->header->numFiles);
     }
     break;
   default: