Mercurial > hg > audiodb
comparison audioDB.h @ 23:42498552b30c audiodb-debian
Merged trunk changes -r30:38 onto audiodb-debian branch
author | mas01cr |
---|---|
date | Thu, 16 Aug 2007 10:04:55 +0000 |
parents | 69eb22e09772 |
children | 5485586a5378 |
comparison
equal
deleted
inserted
replaced
16:4346f4b717e4 | 23:42498552b30c |
---|---|
14 Database Setup: | 14 Database Setup: |
15 These commands require a database argument. | 15 These commands require a database argument. |
16 -d, --database=filename database name to be used with database commands | 16 -d, --database=filename database name to be used with database commands |
17 -N, --new make a new database | 17 -N, --new make a new database |
18 -S, --status database information | 18 -S, --status database information |
19 -D, --dump list all segments: index key size | 19 -D, --dump list all tracks: index key size |
20 | 20 |
21 Database Insertion: | 21 Database Insertion: |
22 The following commands process a binary input feature file and optional | 22 The following commands process a binary input feature file and optional |
23 associated key. | 23 associated key. |
24 -I, --insert add feature vectors to an existing database | 24 -I, --insert add feature vectors to an existing database |
44 Thse commands control the behaviour of retrieval from a named database. | 44 Thse commands control the behaviour of retrieval from a named database. |
45 -Q, --query perform a content-based search on the named | 45 -Q, --query perform a content-based search on the named |
46 database using the named feature vector file | 46 database using the named feature vector file |
47 as a query | 47 as a query |
48 -q, --qtype=type the type of search (possible values="point", | 48 -q, --qtype=type the type of search (possible values="point", |
49 "segment", "sequence" default=`sequence') | 49 "track", "sequence" default=`sequence') |
50 -p, --qpoint=position ordinal position of query vector (or start of | 50 -p, --qpoint=position ordinal position of query vector (or start of |
51 sequence) in feature vector input file | 51 sequence) in feature vector input file |
52 (default=`0') | 52 (default=`0') |
53 -n, --pointnn=numpoints number of point nearest neighbours to use [per | 53 -n, --pointnn=numpoints number of point nearest neighbours to use [per |
54 segment in segment and sequence mode] | 54 track in track and sequence mode] |
55 (default=`10') | 55 (default=`10') |
56 -r, --resultlength=length maximum length of the result list | 56 -r, --resultlength=length maximum length of the result list |
57 (default=`10') | 57 (default=`10') |
58 -l, --sequencelength=length length of sequences for sequence search | 58 -l, --sequencelength=length length of sequences for sequence search |
59 (default=`16') | 59 (default=`16') |
105 #define COM_DATABASE "--database" | 105 #define COM_DATABASE "--database" |
106 #define COM_QTYPE "--qtype" | 106 #define COM_QTYPE "--qtype" |
107 #define COM_SEQLEN "--sequencelength" | 107 #define COM_SEQLEN "--sequencelength" |
108 #define COM_SEQHOP "--sequencehop" | 108 #define COM_SEQHOP "--sequencehop" |
109 #define COM_POINTNN "--pointnn" | 109 #define COM_POINTNN "--pointnn" |
110 #define COM_SEGNN "--resultlength" | 110 #define COM_TRACKNN "--resultlength" |
111 #define COM_QPOINT "--qpoint" | 111 #define COM_QPOINT "--qpoint" |
112 #define COM_FEATURES "--features" | 112 #define COM_FEATURES "--features" |
113 #define COM_QUERYKEY "--key" | 113 #define COM_QUERYKEY "--key" |
114 #define COM_KEYLIST "--keyList" | 114 #define COM_KEYLIST "--keyList" |
115 #define COM_TIMES "--times" | 115 #define COM_TIMES "--times" |
116 | 116 |
117 #define O2_MAGIC 1111765583 // 'B'<<24|'D'<<16|'2'<<8|'O' reads O2DB in little endian order | 117 #define O2_MAGIC 1111765583 // 'B'<<24|'D'<<16|'2'<<8|'O' reads O2DB in little endian order |
118 | 118 |
119 #define O2_DEFAULT_POINTNN (10U) | 119 #define O2_DEFAULT_POINTNN (10U) |
120 #define O2_DEFAULT_SEGNN (10U) | 120 #define O2_DEFAULT_TRACKNN (10U) |
121 | 121 |
122 #define O2_DEFAULTDBSIZE (2000000000) // 2GB table size | 122 #define O2_DEFAULTDBSIZE (2000000000) // 2GB table size |
123 //#define O2_DEFAULTDBSIZE (1000000000U) // 1GB table size | 123 //#define O2_DEFAULTDBSIZE (1000000000U) // 1GB table size |
124 | 124 |
125 //#define O2_MAXFILES (1000000) | 125 //#define O2_MAXFILES (1000000) |
126 #define O2_MAXFILES (10000U) // 10,000 files | 126 #define O2_MAXFILES (10000U) // 10,000 files |
127 #define O2_MAXFILESTR (256U) | 127 #define O2_MAXFILESTR (256U) |
128 #define O2_FILETABLESIZE (O2_MAXFILESTR) | 128 #define O2_FILETABLESIZE (O2_MAXFILESTR) |
129 #define O2_SEGTABLESIZE (sizeof(unsigned)) | 129 #define O2_TRACKTABLESIZE (sizeof(unsigned)) |
130 #define O2_HEADERSIZE (sizeof(dbTableHeaderT)) | 130 #define O2_HEADERSIZE (sizeof(dbTableHeaderT)) |
131 #define O2_MEANNUMVECTORS (1000U) | 131 #define O2_MEANNUMVECTORS (1000U) |
132 #define O2_MAXDIM (1000U) | 132 #define O2_MAXDIM (1000U) |
133 #define O2_MAXNN (1000U) | 133 #define O2_MAXNN (10000U) |
134 | 134 |
135 // Flags | 135 // Flags |
136 #define O2_FLAG_L2NORM (0x1U) | 136 #define O2_FLAG_L2NORM (0x1U) |
137 #define O2_FLAG_MINMAX (0x2U) | 137 #define O2_FLAG_MINMAX (0x2U) |
138 #define O2_FLAG_POINT_QUERY (0x4U) | 138 #define O2_FLAG_POINT_QUERY (0x4U) |
139 #define O2_FLAG_SEQUENCE_QUERY (0x8U) | 139 #define O2_FLAG_SEQUENCE_QUERY (0x8U) |
140 #define O2_FLAG_SEG_QUERY (0x10U) | 140 #define O2_FLAG_TRACK_QUERY (0x10U) |
141 #define O2_FLAG_TIMES (0x20U) | 141 #define O2_FLAG_TIMES (0x20U) |
142 | 142 |
143 // Error Codes | 143 // Error Codes |
144 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00) | 144 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00) |
145 | 145 |
165 unsigned dim; | 165 unsigned dim; |
166 const char *dbName; | 166 const char *dbName; |
167 const char *inFile; | 167 const char *inFile; |
168 const char *hostport; | 168 const char *hostport; |
169 const char *key; | 169 const char *key; |
170 const char* segFileName; | 170 const char* trackFileName; |
171 ifstream *segFile; | 171 ifstream *trackFile; |
172 const char *command; | 172 const char *command; |
173 const char *timesFileName; | 173 const char *timesFileName; |
174 ifstream *timesFile; | 174 ifstream *timesFile; |
175 | 175 |
176 int dbfid; | 176 int dbfid; |
178 char* db; | 178 char* db; |
179 char* indata; | 179 char* indata; |
180 struct stat statbuf; | 180 struct stat statbuf; |
181 dbTableHeaderPtr dbH; | 181 dbTableHeaderPtr dbH; |
182 size_t fileTableOffset; | 182 size_t fileTableOffset; |
183 size_t segTableOffset; | 183 size_t trackTableOffset; |
184 size_t dataoffset; | 184 size_t dataoffset; |
185 size_t l2normTableOffset; | 185 size_t l2normTableOffset; |
186 size_t timesTableOffset; | 186 size_t timesTableOffset; |
187 | 187 |
188 char *fileTable; | 188 char *fileTable; |
189 unsigned* segTable; | 189 unsigned* trackTable; |
190 double* dataBuf; | 190 double* dataBuf; |
191 double* inBuf; | 191 double* inBuf; |
192 double* l2normTable; | 192 double* l2normTable; |
193 double* qNorm; | 193 double* qNorm; |
194 double* sNorm; | 194 double* sNorm; |
196 | 196 |
197 // Flags and parameters | 197 // Flags and parameters |
198 unsigned verbosity; // how much do we want to know? | 198 unsigned verbosity; // how much do we want to know? |
199 unsigned queryType; // point queries default | 199 unsigned queryType; // point queries default |
200 unsigned pointNN; // how many point NNs ? | 200 unsigned pointNN; // how many point NNs ? |
201 unsigned segNN; // how many seg NNs ? | 201 unsigned trackNN; // how many track NNs ? |
202 unsigned sequenceLength; | 202 unsigned sequenceLength; |
203 unsigned sequenceHop; | 203 unsigned sequenceHop; |
204 unsigned queryPoint; | 204 unsigned queryPoint; |
205 unsigned usingQueryPoint; | 205 unsigned usingQueryPoint; |
206 unsigned usingTimes; | 206 unsigned usingTimes; |
207 unsigned isClient; | 207 unsigned isClient; |
208 unsigned isServer; | 208 unsigned isServer; |
209 unsigned port; | 209 unsigned port; |
210 double timesTol; | 210 double timesTol; |
211 unsigned ignoreCols; | 211 double radius; |
212 | 212 |
213 // Timers | 213 // Timers |
214 struct timeval tv1; | 214 struct timeval tv1; |
215 struct timeval tv2; | 215 struct timeval tv2; |
216 | 216 |
217 | |
218 | |
219 | |
220 // private methods | 217 // private methods |
221 void error(const char* a, const char* b = ""); | 218 void error(const char* a, const char* b = ""); |
222 void pointQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); | 219 void pointQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); |
223 void sequenceQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); | 220 void trackPointQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); |
224 void segPointQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); | 221 void trackSequenceQueryNN(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); |
225 void segSequenceQuery(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); | 222 void trackSequenceQueryRad(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); |
226 | 223 |
227 void initTables(const char* dbName, const char* inFile); | 224 void initTables(const char* dbName, const char* inFile); |
228 void NBestMatchedFilter(); | |
229 void unitNorm(double* X, unsigned d, unsigned n, double* qNorm); | 225 void unitNorm(double* X, unsigned d, unsigned n, double* qNorm); |
230 void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append); | 226 void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append); |
231 void normalize(double* X, int dim, int n); | 227 void normalize(double* X, int dim, int n); |
232 void normalize(double* X, int dim, int n, double minval, double maxval); | 228 void normalize(double* X, int dim, int n, double minval, double maxval); |
233 void insertTimeStamps(unsigned n, ifstream* timesFile, double* timesdata); | 229 void insertTimeStamps(unsigned n, ifstream* timesFile, double* timesdata); |
242 void insert(const char* dbName, const char* inFile); | 238 void insert(const char* dbName, const char* inFile); |
243 void batchinsert(const char* dbName, const char* inFile); | 239 void batchinsert(const char* dbName, const char* inFile); |
244 void query(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); | 240 void query(const char* dbName, const char* inFile, adb__queryResult *adbQueryResult=0); |
245 void status(const char* dbName); | 241 void status(const char* dbName); |
246 void ws_status(const char*dbName, char* hostport); | 242 void ws_status(const char*dbName, char* hostport); |
247 void ws_query(const char*dbName, const char *segKey, const char* hostport); | 243 void ws_query(const char*dbName, const char *trackKey, const char* hostport); |
248 void l2norm(const char* dbName); | 244 void l2norm(const char* dbName); |
249 void dump(const char* dbName); | 245 void dump(const char* dbName); |
250 void deleteDB(const char* dbName, const char* inFile); | |
251 | 246 |
252 // web services | 247 // web services |
253 void startServer(); | 248 void startServer(); |
254 | 249 |
255 }; | 250 }; |
251 |