comparison audioDB_API.h @ 670:684339bb8d21

Remove most backwards-compatibility cruft from audioDB_API.h "most": audiodb_insert() and audiodb_batchinsert(), along with adb_insert_t, are still there, basically because the distinction between LARGE_ADB and "normal" isn't exposed properly.
author mas01cr
date Fri, 05 Mar 2010 16:00:44 +0000
parents 633614461994
children a35ca2d5f238
comparison
equal deleted inserted replaced
669:780ebab29268 670:684339bb8d21
14 14
15 15
16 /*******************************************************************/ 16 /*******************************************************************/
17 /* Data types for API */ 17 /* Data types for API */
18 18
19 /* The main struct that stores the name of the database, and in future will hold all
20 * kinds of other interesting information */
21 /* This basically gets passed around to all of the other functions */
22
23 /* FIXME: it might be that "adb_" isn't such a good prefix to use, and 19 /* FIXME: it might be that "adb_" isn't such a good prefix to use, and
24 that we should prefer "audiodb_". Or else maybe we should be 20 that we should prefer "audiodb_". Or else maybe we should be
25 calling ourselves libadb? */ 21 calling ourselves libadb? */
26 typedef struct adb adb_t, *adb_ptr; 22 typedef struct adb adb_t;
27 23
28 struct adb_datum { 24 typedef struct adb_datum {
29 uint32_t nvectors; 25 uint32_t nvectors;
30 uint32_t dim; 26 uint32_t dim;
31 const char *key; 27 const char *key;
32 double *data; 28 double *data;
33 double *power; 29 double *power;
34 double *times; 30 double *times;
35 }; 31 } adb_datum_t;
36 typedef struct adb_datum adb_datum_t;
37 32
38 //used for both insert and batchinsert 33 typedef struct adb_reference {
39 struct adbinsert {
40 const char *features; 34 const char *features;
41 const char *power; 35 const char *power;
42 const char *key; 36 const char *key;
43 const char *times; 37 const char *times;
44 }; 38 } adb_reference_t, adb_insert_t;
45 typedef struct adbinsert adb_insert_t, adb_reference_t, *adb_insert_ptr;
46 39
47 /* struct for returning status results */ 40 /* struct for returning status results */
48 struct adbstatus { 41 typedef struct adb_status {
49 unsigned int numFiles; 42 unsigned int numFiles;
50 unsigned int dim; 43 unsigned int dim;
51 unsigned int dudCount; 44 unsigned int dudCount;
52 unsigned int nullCount; 45 unsigned int nullCount;
53 unsigned int flags; 46 unsigned int flags;
54 uint64_t length; 47 uint64_t length;
55 uint64_t data_region_size; 48 uint64_t data_region_size;
56 }; 49 } adb_status_t;
57 typedef struct adbstatus adb_status_t, *adb_status_ptr;
58 50
59 /* needed for constructing a query */ 51 typedef struct adb_result {
60 struct adbquery {
61
62 char * querytype;
63 char * feature; //usually a file of some kind
64 char * key;
65 char * power; //also a file
66 char * keylist; //also a file
67 char * qpoint; //position
68 char * numpoints;
69 char * radius;
70 char * resultlength; //how many results to make
71 char * sequencelength;
72 char * sequencehop;
73 double absolute_threshold;
74 double relative_threshold;
75 int exhaustive; //hidden option in gengetopt
76 double expandfactor; //hidden
77 int rotate; //hidden
78
79 };
80 typedef struct adbquery adb_query_t,*adb_query_ptr;
81
82 /* ... and for getting query results back */
83 struct adbqueryresult {
84
85 int sizeRlist; /* do I really need to return all 4 sizes here */
86 int sizeDist;
87 int sizeQpos;
88 int sizeSpos;
89 char **Rlist;
90 double *Dist;
91 unsigned int *Qpos;
92 unsigned int *Spos;
93
94 };
95 typedef struct adbqueryresult adb_queryresult_t, *adb_queryresult_ptr;
96
97 /* New ("new" == December 2008) query API */
98
99 typedef struct adbresult {
100 const char *key; 52 const char *key;
101 double dist; 53 double dist;
102 uint32_t qpos; 54 uint32_t qpos;
103 uint32_t ipos; 55 uint32_t ipos;
104 } adb_result_t; 56 } adb_result_t;
176 /*******************************************************************/ 128 /*******************************************************************/
177 /* Function prototypes for API */ 129 /* Function prototypes for API */
178 130
179 /* open an existing database */ 131 /* open an existing database */
180 /* returns a struct or NULL on failure */ 132 /* returns a struct or NULL on failure */
181 adb_ptr audiodb_open(const char *path, int flags); 133 adb_t *audiodb_open(const char *path, int flags);
182 134
183 /* create a new database */ 135 /* create a new database */
184 /* returns a struct or NULL on failure */ 136 /* returns a struct or NULL on failure */
185 adb_ptr audiodb_create(const char *path, unsigned datasize, unsigned ntracks, unsigned datadim); 137 adb_t *audiodb_create(const char *path, unsigned datasize, unsigned ntracks, unsigned datadim);
186 138
187 /* close a database */ 139 /* close a database */
188 void audiodb_close(adb_ptr db); 140 void audiodb_close(adb_t *adb);
189 141
190 /* You'll need to turn both of these on to do anything useful */ 142 /* You'll need to turn both of these on to do anything useful */
191 int audiodb_l2norm(adb_ptr mydb); 143 int audiodb_l2norm(adb_t *adb);
192 int audiodb_power(adb_ptr mydb); 144 int audiodb_power(adb_t *adb);
193 145
194 /* insert functions */ 146 /* insert functions */
195 int audiodb_insert_datum(adb_t *, const adb_datum_t *); 147 int audiodb_insert_datum(adb_t *, const adb_datum_t *);
196 int audiodb_insert_reference(adb_t *, const adb_reference_t *); 148 int audiodb_insert_reference(adb_t *, const adb_reference_t *);
197 int audiodb_insert(adb_ptr mydb, adb_insert_ptr ins);
198 int audiodb_batchinsert(adb_ptr mydb, adb_insert_ptr ins, unsigned int size);
199 149
200 /* query function */ 150 /* query function */
201 int audiodb_query(adb_ptr mydb, adb_query_ptr adbq, adb_queryresult_ptr adbqres);
202 adb_query_results_t *audiodb_query_spec(adb_t *, const adb_query_spec_t *); 151 adb_query_results_t *audiodb_query_spec(adb_t *, const adb_query_spec_t *);
203 int audiodb_query_free_results(adb_t *, const adb_query_spec_t *, adb_query_results_t *); 152 int audiodb_query_free_results(adb_t *, const adb_query_spec_t *, adb_query_results_t *);
204 153
205 /* database status */ 154 /* database status */
206 int audiodb_status(adb_ptr mydb, adb_status_ptr status); 155 int audiodb_status(adb_t *, adb_status_t *status);
207 156
208 /* retrieval of inserted data */ 157 /* retrieval of inserted data */
209 int audiodb_retrieve_datum(adb_t *, const char *, adb_datum_t *); 158 int audiodb_retrieve_datum(adb_t *, const char *, adb_datum_t *);
210 int audiodb_free_datum(adb_t *, adb_datum_t *); 159 int audiodb_free_datum(adb_t *, adb_datum_t *);
211 160
212 /* various dump formats */ 161 /* various dump formats */
213 int audiodb_dump(adb_ptr mydb, const char *outputdir); 162 int audiodb_dump(adb_t *, const char *outputdir);
214 163
215 /* liszt */ 164 /* liszt */
216 adb_liszt_results_t *audiodb_liszt(adb_t *); 165 adb_liszt_results_t *audiodb_liszt(adb_t *);
217 int audiodb_liszt_free_results(adb_t *, adb_liszt_results_t *); 166 int audiodb_liszt_free_results(adb_t *, adb_liszt_results_t *);
218 167
168 /* backwards compatibility */
169 int audiodb_insert(adb_t *, adb_insert_t *ins);
170 int audiodb_batchinsert(adb_t *, adb_insert_t *ins, unsigned int size);
171
219 #endif 172 #endif