Mercurial > hg > audiodb
comparison libtests/0024/prog1.c @ 492:f6b126b018d8 api-inversion
Yet more audiodb_query() deletions.
Also delete the libtests/notes file, with its misleading and wrong
questions, to avoid further confusion.
author | mas01cr |
---|---|
date | Sat, 10 Jan 2009 15:33:07 +0000 |
parents | f4dc8e47ee37 |
children | c291e9201a3c |
comparison
equal
deleted
inserted
replaced
491:29d28cfe0222 | 492:f6b126b018d8 |
---|---|
1 #include "audioDB_API.h" | 1 #include "audioDB_API.h" |
2 #include "test_utils_lib.h" | 2 #include "test_utils_lib.h" |
3 | 3 |
4 int main(int argc, char **argv) { | |
5 adb_t *adb; | |
6 adb_insert_t batch[2]={{0}, {0}}; | |
4 | 7 |
5 int main(int argc, char **argv){ | 8 clean_remove_db(TESTDB); |
9 if(!(adb = audiodb_create(TESTDB, 0, 0, 0))) | |
10 return 1; | |
6 | 11 |
7 int returnval=0; | 12 maketestfile("testfeature01", (int[1]){2}, (double[2]) {0, 1}, 2); |
8 adb_ptr mydbp={0}; | 13 maketestfile("testfeature10", (int[1]){2}, (double[2]) {1, 0}, 2); |
9 int ivals[10]; | |
10 double dvals[10]; | |
11 adb_insert_t myinsert={0}; | |
12 unsigned int myerr=0; | |
13 char * databasename="testdb"; | |
14 adb_query_t myadbquery={0}; | |
15 adb_queryresult_t myadbqueryresult={0}; | |
16 adb_query_t myadbquery2={0}; | |
17 adb_queryresult_t myadbqueryresult2={0}; | |
18 int size=0; | |
19 adb_insert_t ins1[2]={0}; | |
20 | 14 |
21 /* remove old directory */ | 15 batch[0].features="testfeature01"; |
22 //if [ -f testdb ]; then rm -f testdb; fi | 16 batch[1].features="testfeature10"; |
23 clean_remove_db(databasename); | 17 if(audiodb_batchinsert(adb, batch, 2)) |
18 return 1; | |
19 if(audiodb_l2norm(adb)) | |
20 return 1; | |
24 | 21 |
25 /* create new db */ | 22 adb_datum_t query = {2, 2, "testquery", (double[4]) {0, 0.5, 0.5, 0}}; |
26 //${AUDIODB} -d testdb -N | 23 adb_query_id_t qid = {0}; |
27 mydbp=audiodb_create(databasename,0,0,0); | 24 qid.datum = &query; |
25 qid.sequence_length = 1; | |
26 qid.flags = ADB_QID_FLAG_EXHAUSTIVE; | |
27 adb_query_parameters_t parms = | |
28 {ADB_ACCUMULATION_PER_TRACK, ADB_DISTANCE_EUCLIDEAN_NORMED, 10, 10}; | |
29 adb_query_refine_t refine = {0}; | |
30 refine.hopsize = 1; | |
28 | 31 |
29 //intstring 2 > testfeature01 | 32 adb_query_spec_t spec; |
30 //floatstring 0 1 >> testfeature01 | 33 spec.qid = qid; |
31 //intstring 2 > testfeature10 | 34 spec.params = parms; |
32 //floatstring 1 0 >> testfeature10 | 35 spec.refine = refine; |
33 ivals[0]=2; | 36 |
34 dvals[0]=0; dvals[1]=1; | 37 adb_query_results_t *results = audiodb_query_spec(adb, &spec); |
35 maketestfile("testfeature01",ivals,dvals,2); | 38 if(!results || results->nresults != 4) return 1; |
36 ivals[0]=2; | 39 result_present_or_fail(results, "testfeature01", 0, 0, 0); |
37 dvals[0]=1; dvals[1]=0; | 40 result_present_or_fail(results, "testfeature01", 2, 1, 0); |
38 maketestfile("testfeature10",ivals,dvals,2); | 41 result_present_or_fail(results, "testfeature10", 2, 0, 0); |
42 result_present_or_fail(results, "testfeature10", 0, 1, 0); | |
43 audiodb_query_free_results(adb, &spec, results); | |
39 | 44 |
40 //cat > testfeaturefiles <<EOF | 45 spec.params.npoints = 1; |
41 //testfeature01 | 46 results = audiodb_query_spec(adb, &spec); |
42 //testfeature10 | 47 if(!results || results->nresults != 2) return 1; |
43 //EOF | 48 result_present_or_fail(results, "testfeature01", 0, 0, 0); |
44 ins1[0].features="testfeature01"; | 49 result_present_or_fail(results, "testfeature10", 0, 1, 0); |
45 ins1[1].features="testfeature10"; | 50 audiodb_query_free_results(adb, &spec, results); |
46 | 51 |
47 | 52 return 104; |
48 //${AUDIODB} -d testdb -B -F testfeaturefiles | |
49 returnval=audiodb_batchinsert(mydbp,ins1,2); | |
50 | |
51 //# sequence queries require L2NORM | |
52 //${AUDIODB} -d testdb -L | |
53 audiodb_l2norm(mydbp); | |
54 | |
55 //echo "exhaustive search" | |
56 //intstring 2 > testquery | |
57 //floatstring 0 0.5 >> testquery | |
58 //floatstring 0.5 0 >> testquery | |
59 ivals[0]=2; | |
60 dvals[0]=0; dvals[1]=0.5; | |
61 dvals[2]=0.5; dvals[3]=0; | |
62 maketestfile("testquery",ivals,dvals,4); | |
63 | |
64 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -e > testoutput | |
65 //echo testfeature01 1 0 0 > test-expected-output | |
66 //echo testfeature10 1 1 0 >> test-expected-output | |
67 //cmp testoutput test-expected-output | |
68 myadbquery.querytype="sequence"; | |
69 myadbquery.feature="testquery"; | |
70 myadbquery.sequencelength="1"; | |
71 myadbquery.exhaustive=1; | |
72 audiodb_query(mydbp,&myadbquery,&myadbqueryresult); | |
73 size=myadbqueryresult.sizeRlist; | |
74 | |
75 //printf("size:%d\n",size); | |
76 ///* check the test values */ | |
77 if (size != 2) {returnval = -1;}; | |
78 if (testoneresult(&myadbqueryresult,0,"testfeature01",1,0,0)) {returnval = -1;}; | |
79 if (testoneresult(&myadbqueryresult,1,"testfeature10",1,1,0)) {returnval = -1;}; | |
80 | |
81 //${AUDIODB} -d testdb -Q sequence -l 1 -f testquery -n 1 -e > testoutput | |
82 //echo testfeature01 0 0 0 > test-expected-output | |
83 //echo testfeature10 0 1 0 >> test-expected-output | |
84 //cmp testoutput test-expected-output | |
85 myadbquery.querytype="sequence"; | |
86 myadbquery.feature="testquery"; | |
87 myadbquery.sequencelength="1"; | |
88 myadbquery.exhaustive=1; | |
89 myadbquery.numpoints="1"; | |
90 audiodb_query(mydbp,&myadbquery,&myadbqueryresult); | |
91 size=myadbqueryresult.sizeRlist; | |
92 | |
93 //printf("size:%d\n",size); | |
94 ///* check the test values */ | |
95 if (size != 2) {returnval = -1;}; | |
96 if (testoneresult(&myadbqueryresult,0,"testfeature01",0,0,0)) {returnval = -1;}; | |
97 if (testoneresult(&myadbqueryresult,1,"testfeature10",0,1,0)) {returnval = -1;}; | |
98 | |
99 | |
100 printf("returnval:%d\n",returnval); | |
101 return(returnval); | |
102 } | 53 } |
103 |