annotate libtests/0037/prog1.c @ 755:37c2b9cce23a multiprobeLSH

Adding mkc_lsh_update branch, trunk candidate with improved LSH: merged trunk 1095 and branch multiprobe_lsh
author mas01mc
date Thu, 25 Nov 2010 13:42:40 +0000
parents 342822c2d49a
children bcc7a6ddb2c8
rev   line source
mas01cr@498 1 #include "audioDB_API.h"
mas01cr@498 2 #include "test_utils_lib.h"
mas01cr@498 3
mas01cr@498 4 int main(int argc, char *argv[]) {
mas01cr@498 5 adb_t *adb;
mas01cr@498 6 adb_insert_t *batch = 0;
mas01cr@498 7 adb_status_t status;
mas01cr@498 8
mas01cr@498 9 clean_remove_db(TESTDB);
mas01cr@498 10 adb = audiodb_create(TESTDB, 0, 0, 0);
mas01cr@498 11 if(!adb) {
mas01cr@498 12 return 1;
mas01cr@498 13 }
mas01cr@498 14
mas01cr@498 15 maketestfile("testfeature01", 2, (double[4]) {0,1,1,0}, 4);
mas01cr@498 16 maketestfile("testfeature10", 2, (double[4]) {1,0,0,1}, 4);
mas01cr@498 17
mas01cr@498 18 batch = (adb_insert_t *) calloc(6, sizeof(adb_insert_t));
mas01cr@498 19 if(!batch) {
mas01cr@498 20 return 1;
mas01cr@498 21 }
mas01cr@498 22 batch[0].features = "testfeature01";
mas01cr@498 23 batch[1].features = "testfeature01";
mas01cr@498 24 batch[2].features = "testfeature10";
mas01cr@498 25 batch[3].features = "testfeature10";
mas01cr@498 26 batch[4].features = "testfeature01";
mas01cr@498 27 batch[5].features = "testfeature10";
mas01cr@498 28
mas01cr@498 29 audiodb_batchinsert(adb, batch, 6);
mas01cr@498 30 free(batch);
mas01cr@498 31
mas01cr@498 32 if(audiodb_status(adb, &status) || status.numFiles != 2)
mas01cr@498 33 return 1;
mas01cr@498 34
mas01cr@498 35 if(audiodb_l2norm(adb))
mas01cr@498 36 return 1;
mas01cr@498 37
mas01cr@498 38 adb_datum_t datum = {1, 2, NULL, (double [2]){0, 0.5}, NULL, NULL};
mas01cr@498 39 adb_query_id_t qid = {0};
mas01cr@498 40 qid.datum = &datum;
mas01cr@498 41 qid.sequence_length = 1;
mas01cr@498 42 adb_query_parameters_t parms =
mas01cr@498 43 {ADB_ACCUMULATION_PER_TRACK, ADB_DISTANCE_EUCLIDEAN_NORMED, 10, 10};
mas01cr@498 44 adb_query_refine_t refine = {0};
mas01cr@498 45 refine.hopsize = 1;
mas01cr@498 46
mas01cr@498 47 adb_query_spec_t spec;
mas01cr@498 48 spec.qid = qid;
mas01cr@498 49 spec.params = parms;
mas01cr@498 50 spec.refine = refine;
mas01cr@498 51
mas01cr@498 52 adb_query_results_t *results = audiodb_query_spec(adb, &spec);
mas01cr@498 53
mas01cr@498 54 if(!results || results->nresults != 4) return 1;
mas01cr@498 55 result_present_or_fail(results, "testfeature01", 0, 0, 0);
mas01cr@498 56 result_present_or_fail(results, "testfeature01", 2, 0, 1);
mas01cr@498 57 result_present_or_fail(results, "testfeature10", 0, 0, 1);
mas01cr@498 58 result_present_or_fail(results, "testfeature10", 2, 0, 0);
mas01cr@498 59 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 60
mas01cr@498 61 spec.params.npoints = 2;
mas01cr@498 62 results = audiodb_query_spec(adb, &spec);
mas01cr@498 63
mas01cr@498 64 if(!results || results->nresults != 4) return 1;
mas01cr@498 65 result_present_or_fail(results, "testfeature01", 0, 0, 0);
mas01cr@498 66 result_present_or_fail(results, "testfeature01", 2, 0, 1);
mas01cr@498 67 result_present_or_fail(results, "testfeature10", 0, 0, 1);
mas01cr@498 68 result_present_or_fail(results, "testfeature10", 2, 0, 0);
mas01cr@498 69 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 70
mas01cr@498 71 spec.params.npoints = 5;
mas01cr@498 72 results = audiodb_query_spec(adb, &spec);
mas01cr@498 73
mas01cr@498 74 if(!results || results->nresults != 4) return 1;
mas01cr@498 75 result_present_or_fail(results, "testfeature01", 0, 0, 0);
mas01cr@498 76 result_present_or_fail(results, "testfeature01", 2, 0, 1);
mas01cr@498 77 result_present_or_fail(results, "testfeature10", 0, 0, 1);
mas01cr@498 78 result_present_or_fail(results, "testfeature10", 2, 0, 0);
mas01cr@498 79 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 80
mas01cr@498 81 spec.params.npoints = 1;
mas01cr@498 82 results = audiodb_query_spec(adb, &spec);
mas01cr@498 83
mas01cr@498 84 if(!results || results->nresults != 2) return 1;
mas01cr@498 85 result_present_or_fail(results, "testfeature01", 0, 0, 0);
mas01cr@498 86 result_present_or_fail(results, "testfeature10", 0, 0, 1);
mas01cr@498 87
mas01cr@498 88 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 89
mas01cr@498 90 spec.qid.datum->data = (double [2]) {0.5, 0};
mas01cr@498 91 spec.params.npoints = 10;
mas01cr@498 92 results = audiodb_query_spec(adb, &spec);
mas01cr@498 93
mas01cr@498 94 if(!results || results->nresults != 4) return 1;
mas01cr@498 95 result_present_or_fail(results, "testfeature01", 0, 0, 1);
mas01cr@498 96 result_present_or_fail(results, "testfeature01", 2, 0, 0);
mas01cr@498 97 result_present_or_fail(results, "testfeature10", 0, 0, 0);
mas01cr@498 98 result_present_or_fail(results, "testfeature10", 2, 0, 1);
mas01cr@498 99 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 100
mas01cr@498 101 spec.params.npoints = 2;
mas01cr@498 102 results = audiodb_query_spec(adb, &spec);
mas01cr@498 103
mas01cr@498 104 if(!results || results->nresults != 4) return 1;
mas01cr@498 105 result_present_or_fail(results, "testfeature01", 0, 0, 1);
mas01cr@498 106 result_present_or_fail(results, "testfeature01", 2, 0, 0);
mas01cr@498 107 result_present_or_fail(results, "testfeature10", 0, 0, 0);
mas01cr@498 108 result_present_or_fail(results, "testfeature10", 2, 0, 1);
mas01cr@498 109 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 110
mas01cr@498 111 spec.params.npoints = 5;
mas01cr@498 112 results = audiodb_query_spec(adb, &spec);
mas01cr@498 113
mas01cr@498 114 if(!results || results->nresults != 4) return 1;
mas01cr@498 115 result_present_or_fail(results, "testfeature01", 0, 0, 1);
mas01cr@498 116 result_present_or_fail(results, "testfeature01", 2, 0, 0);
mas01cr@498 117 result_present_or_fail(results, "testfeature10", 0, 0, 0);
mas01cr@498 118 result_present_or_fail(results, "testfeature10", 2, 0, 1);
mas01cr@498 119 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 120
mas01cr@498 121 spec.params.npoints = 1;
mas01cr@498 122 results = audiodb_query_spec(adb, &spec);
mas01cr@498 123
mas01cr@498 124 if(!results || results->nresults != 2) return 1;
mas01cr@498 125 result_present_or_fail(results, "testfeature01", 0, 0, 1);
mas01cr@498 126 result_present_or_fail(results, "testfeature10", 0, 0, 0);
mas01cr@498 127 audiodb_query_free_results(adb, &spec, results);
mas01cr@498 128
mas01cr@498 129 audiodb_close(adb);
mas01cr@498 130
mas01cr@498 131 return 104;
mas01cr@498 132 }