Mercurial > hg > audiodb
comparison query.cpp @ 423:b09d2eb1a2b2 api-inversion
Cheap hackery abounds.
Include an accumulator into the query_loop chain. Somewhat
surprisingly, very few tests fail, and those that do are due to
over-specific reporting requirements in the case of ties, so rewrite
those tests to be more permissive.
There are probably codepaths which ignore the accumulator completely;
they will still work, because the accumulator will return zero points
when it is asked to ->get_points().
author | mas01cr |
---|---|
date | Wed, 24 Dec 2008 10:55:08 +0000 |
parents | a7d61291fbda |
children | c6046dd80570 |
comparison
equal
deleted
inserted
replaced
422:a7d61291fbda | 423:b09d2eb1a2b2 |
---|---|
96 else{ | 96 else{ |
97 VERB_LOG(1, "Calling brute-force query on database %s\n", dbName); | 97 VERB_LOG(1, "Calling brute-force query on database %s\n", dbName); |
98 query_loop(dbName, query_from_key_index); | 98 query_loop(dbName, query_from_key_index); |
99 } | 99 } |
100 | 100 |
101 adb_query_results_t *rs = accumulator->get_points(); | |
102 for(unsigned int k = 0; k < rs->nresults; k++) { | |
103 adb_result_t r = rs->results[k]; | |
104 reporter->add_point(getKeyPos(r.key), r.qpos, r.ipos, r.dist); | |
105 } | |
106 | |
101 reporter->report(fileTable, adbQueryResponse); | 107 reporter->report(fileTable, adbQueryResponse); |
102 } | 108 } |
103 | 109 |
104 // return ordinal position of key in keyTable | 110 // return ordinal position of key in keyTable |
105 // this should really be a STL hash map search | 111 // this should really be a STL hash map search |
106 unsigned audioDB::getKeyPos(char* key){ | 112 unsigned audioDB::getKeyPos(const char* key){ |
107 if(!dbH) | 113 if(!dbH) |
108 error("dbH not initialized","getKeyPos"); | 114 error("dbH not initialized","getKeyPos"); |
109 for(unsigned k=0; k<dbH->numFiles; k++) | 115 for(unsigned k=0; k<dbH->numFiles; k++) |
110 if(strncmp(fileTable + k*O2_FILETABLE_ENTRY_SIZE, key, strlen(key))==0) | 116 if(strncmp(fileTable + k*O2_FILETABLE_ENTRY_SIZE, key, strlen(key))==0) |
111 return k; | 117 return k; |
756 | 762 |
757 // Power test | 763 // Power test |
758 if ((!usingPower) || powers_acceptable(qpPtr[j], sPower[trackIndexOffset + k])) { | 764 if ((!usingPower) || powers_acceptable(qpPtr[j], sPower[trackIndexOffset + k])) { |
759 // radius test | 765 // radius test |
760 if((!radius) || thisDist <= (radius+O2_DISTANCE_TOLERANCE)) { | 766 if((!radius) || thisDist <= (radius+O2_DISTANCE_TOLERANCE)) { |
761 reporter->add_point(track, usingQueryPoint ? queryPoint : j, k, thisDist); | 767 adb_result_t r; |
768 r.key = fileTable + track * O2_FILETABLE_ENTRY_SIZE; | |
769 r.dist = thisDist; | |
770 r.qpos = usingQueryPoint ? queryPoint : j; | |
771 r.ipos = k; | |
772 accumulator->add_point(&r); | |
762 } | 773 } |
763 } | 774 } |
764 } | 775 } |
765 } | 776 } |
766 } // Duration match | 777 } // Duration match |