diff query.cpp @ 468:4dbd7917bf9e api-inversion

YAY! audioDB::index_query_loop is now disentangled. Hardwired lsh_in_core to true, and invented a new QID flag for !lsh_exact. All tests continue to pass. The plans now: - extract the audiodb_query_spec() function from inside audioDB::query, and move audioDB::query (and the timestamps function) to audioDB.cpp; - write libtests/0036 and libtests/0037 in terms of audiodb_query_spec(); - rewrite all the other libtests in terms of audiodb_query_spec(); - delete audiodb_query() [ and maybe rename audiodb_query_spec(), I dunno]; - implement example bindings (probably to Lisp, because that's what I know best); - see if anyone other than me can work out how the API works. If not, provide documentation; - revise API in the light of user feedback.
author mas01cr
date Wed, 31 Dec 2008 15:44:12 +0000
parents 11fccb6a3bd5
children d3afc91d205d
line wrap: on
line diff
--- a/query.cpp	Wed Dec 31 12:25:22 2008 +0000
+++ b/query.cpp	Wed Dec 31 15:44:12 2008 +0000
@@ -116,7 +116,9 @@
 
   qspec.qid.datum = &datum;
   qspec.qid.sequence_length = sequenceLength;
-  qspec.qid.flags = usingQueryPoint ? 0 : ADB_QUERY_ID_FLAG_EXHAUSTIVE;
+  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;
 
   switch(queryType) {
@@ -228,7 +230,7 @@
   // Test for index (again) here
   if((qspec.refine.flags & ADB_REFINE_RADIUS) && audiodb_index_exists(adb->path, qspec.refine.radius, qspec.qid.sequence_length)){ 
     VERB_LOG(1, "Calling indexed query on database %s, radius=%f, sequence_length=%d\n", adb->path, qspec.refine.radius, qspec.qid.sequence_length);
-    if(index_query_loop(adb, &qspec, &qstate) < 0) {
+    if(audiodb_index_query_loop(adb, &qspec, &qstate) < 0) {
       error("index_query_loop failed");
     }
   } else {
@@ -508,7 +510,7 @@
   audiodb_datum_qpointers(&d, sequence_length, vector_data, vector, qpointers);
 
   /* Finally, if applicable, set up the moving qpointers. */
-  if(spec->qid.flags & ADB_QUERY_ID_FLAG_EXHAUSTIVE) {
+  if(spec->qid.flags & ADB_QID_FLAG_EXHAUSTIVE) {
     /* the qpointers are already at the start, and so correct. */
   } else {
     /* adjust the qpointers to point to the correct place in the sequence */
@@ -659,7 +661,7 @@
       }
       audiodb_free_datum(&d);
     }
-    Uns32T qPos = (spec->qid.flags & ADB_QUERY_ID_FLAG_EXHAUSTIVE) ? pp.qpos : 0;
+    Uns32T qPos = (spec->qid.flags & ADB_QID_FLAG_EXHAUSTIVE) ? pp.qpos : 0;
     Uns32T sPos = pp.spos; // index into l2norm table
     // Test power thresholds before computing distance
     if( ( (!power_refine) || audiodb_powers_acceptable(&spec->refine, qpointers->power[qPos], dbpointers.power[sPos])) &&
@@ -784,7 +786,7 @@
                 adb_result_t r;
                 r.key = (*adb->keys)[track].c_str();
                 r.dist = thisDist;
-                if(spec->qid.flags & ADB_QUERY_ID_FLAG_EXHAUSTIVE) {
+                if(spec->qid.flags & ADB_QID_FLAG_EXHAUSTIVE) {
                   r.qpos = j;
                 } else {
                   r.qpos = spec->qid.sequence_start;