mas01mc@292
|
1 #ifndef __AUDIODB_H_
|
mas01mc@292
|
2 #define __AUDIODB_H_
|
mas01mc@292
|
3
|
mas01cr@0
|
4 #include <stdio.h>
|
mas01cr@0
|
5 #include <stdlib.h>
|
mas01cr@0
|
6 #include <sys/types.h>
|
mas01cr@0
|
7 #include <sys/stat.h>
|
mas01cr@0
|
8 #include <sys/mman.h>
|
mas01cr@0
|
9 #include <fcntl.h>
|
mas01cr@0
|
10 #include <string.h>
|
mas01cr@0
|
11 #include <iostream>
|
mas01cr@0
|
12 #include <fstream>
|
mas01cr@302
|
13 #include <set>
|
mas01cr@430
|
14 #include <map>
|
mas01cr@302
|
15 #include <string>
|
mas01cr@0
|
16 #include <math.h>
|
mas01cr@0
|
17 #include <sys/time.h>
|
mas01cr@0
|
18 #include <assert.h>
|
mas01cr@62
|
19 #include <float.h>
|
mas01cr@104
|
20 #include <signal.h>
|
mas01cr@280
|
21 #include <gsl/gsl_rng.h>
|
mas01cr@0
|
22
|
mas01mc@292
|
23 // includes for LSH indexing
|
mas01cr@421
|
24 extern "C" {
|
mas01cr@421
|
25 #include "audioDB_API.h"
|
mas01cr@421
|
26 }
|
mas01mc@292
|
27 #include "ReporterBase.h"
|
mas01cr@421
|
28 #include "accumulator.h"
|
mas01mc@292
|
29 #include "lshlib.h"
|
mas01mc@292
|
30
|
mas01cr@0
|
31 // includes for web services
|
mas01cr@0
|
32 #include "soapH.h"
|
mas01cr@0
|
33 #include "cmdline.h"
|
mas01cr@0
|
34
|
mas01cr@458
|
35 // should probably be rewritten
|
mas01cr@458
|
36 class PointPair{
|
mas01cr@458
|
37 public:
|
mas01cr@458
|
38 Uns32T trackID;
|
mas01cr@458
|
39 Uns32T qpos;
|
mas01cr@458
|
40 Uns32T spos;
|
mas01cr@458
|
41 PointPair(Uns32T a, Uns32T b, Uns32T c);
|
mas01cr@458
|
42 };
|
mas01cr@458
|
43 bool operator<(const PointPair& a, const PointPair& b);
|
mas01cr@458
|
44
|
mas01cr@437
|
45 // should be in -internals.h
|
mas01cr@437
|
46 typedef struct adb_qpointers_internal {
|
mas01cr@437
|
47 uint32_t nvectors;
|
mas01cr@437
|
48 double *l2norm_data;
|
mas01cr@437
|
49 double *l2norm;
|
mas01cr@437
|
50 double *power_data;
|
mas01cr@437
|
51 double *power;
|
mas01cr@437
|
52 double *mean_duration;
|
mas01cr@437
|
53 } adb_qpointers_internal_t;
|
mas01cr@437
|
54
|
mas01cr@458
|
55 typedef struct adb_qstate_internal {
|
mas01cr@458
|
56 Accumulator *accumulator;
|
mas01cr@458
|
57 std::set<std::string> *allowed_keys;
|
mas01cr@458
|
58 std::priority_queue<PointPair> *exact_evaluation_queue;
|
mas01cr@458
|
59 } adb_qstate_internal_t;
|
mas01cr@458
|
60
|
mas01cr@0
|
61 #define MAXSTR 512
|
mas01cr@0
|
62
|
mas01cr@0
|
63 // Databse PRIMARY commands
|
mas01cr@0
|
64 #define COM_CREATE "--NEW"
|
mas01cr@0
|
65 #define COM_INSERT "--INSERT"
|
mas01cr@0
|
66 #define COM_BATCHINSERT "--BATCHINSERT"
|
mas01cr@0
|
67 #define COM_QUERY "--QUERY"
|
mas01cr@0
|
68 #define COM_STATUS "--STATUS"
|
mas01cr@0
|
69 #define COM_L2NORM "--L2NORM"
|
mas01cr@193
|
70 #define COM_POWER "--POWER"
|
mas01cr@0
|
71 #define COM_DUMP "--DUMP"
|
mas01cr@0
|
72 #define COM_SERVER "--SERVER"
|
mas01mc@292
|
73 #define COM_INDEX "--INDEX"
|
mas01cr@280
|
74 #define COM_SAMPLE "--SAMPLE"
|
mas01mc@334
|
75 #define COM_LISZT "--LISZT"
|
mas01cr@0
|
76
|
mas01cr@0
|
77 // parameters
|
mas01cr@0
|
78 #define COM_CLIENT "--client"
|
mas01cr@0
|
79 #define COM_DATABASE "--database"
|
mas01cr@0
|
80 #define COM_QTYPE "--qtype"
|
mas01cr@0
|
81 #define COM_SEQLEN "--sequencelength"
|
mas01cr@0
|
82 #define COM_SEQHOP "--sequencehop"
|
mas01cr@0
|
83 #define COM_POINTNN "--pointnn"
|
mas01mc@307
|
84 #define COM_RADIUS "--radius"
|
mas01mc@18
|
85 #define COM_TRACKNN "--resultlength"
|
mas01cr@0
|
86 #define COM_QPOINT "--qpoint"
|
mas01cr@0
|
87 #define COM_FEATURES "--features"
|
mas01cr@0
|
88 #define COM_QUERYKEY "--key"
|
mas01cr@0
|
89 #define COM_KEYLIST "--keyList"
|
mas01cr@0
|
90 #define COM_TIMES "--times"
|
mas01cr@193
|
91 #define COM_QUERYPOWER "--power"
|
mas01cr@193
|
92 #define COM_RELATIVE_THRESH "--relative-threshold"
|
mas01cr@193
|
93 #define COM_ABSOLUTE_THRESH "--absolute-threshold"
|
mas01mc@310
|
94 #define COM_EXHAUSTIVE "--exhaustive"
|
mas01mc@310
|
95 #define COM_LSH_EXACT "--lsh_exact"
|
mas01cr@0
|
96
|
mas01mc@314
|
97 // Because LSH returns NN with P(1)<1 we want to return exact
|
mas01mc@314
|
98 // points above this boundary.
|
mas01mc@314
|
99 // Because we work in Radius^2 units,
|
mas01mc@314
|
100 // The sqrt of this number is the multiplier on the radius
|
mas01mc@314
|
101
|
mas01mc@314
|
102 #define O2_LSH_EXACT_MULT 9
|
mas01mc@314
|
103
|
mas01cr@108
|
104 #define O2_OLD_MAGIC ('O'|'2'<<8|'D'<<16|'B'<<24)
|
mas01cr@108
|
105 #define O2_MAGIC ('o'|'2'<<8|'d'<<16|'b'<<24)
|
mas01cr@210
|
106 #define O2_FORMAT_VERSION (4U)
|
mas01cr@0
|
107
|
mas01cr@0
|
108 #define O2_DEFAULT_POINTNN (10U)
|
mas01mc@18
|
109 #define O2_DEFAULT_TRACKNN (10U)
|
mas01cr@0
|
110
|
mas01mc@248
|
111 //#define O2_DEFAULTDBSIZE (4000000000) // 4GB table size
|
mas01mc@7
|
112 #define O2_DEFAULTDBSIZE (2000000000) // 2GB table size
|
mas01cr@0
|
113
|
mas01mc@295
|
114 // Bit masks for packing (trackID,pointID) into 32-bit unsigned int
|
mas01mc@324
|
115 // This can be controlled at compile time
|
mas01mc@324
|
116 #define O2_DEFAULT_LSH_N_POINT_BITS 14
|
mas01mc@324
|
117
|
mas01mc@324
|
118 // Override the default point bit width for large database support
|
mas01mc@324
|
119 #ifndef LSH_N_POINT_BITS
|
mas01mc@324
|
120 #define LSH_N_POINT_BITS O2_DEFAULT_LSH_N_POINT_BITS
|
mas01mc@324
|
121 #endif
|
mas01mc@295
|
122
|
mas01mc@295
|
123 // LIMIT PARAMETERS
|
mas01cr@256
|
124 #define O2_DEFAULT_DATASIZE (1355U) // in MB
|
mas01cr@256
|
125 #define O2_DEFAULT_NTRACKS (20000U)
|
mas01cr@256
|
126 #define O2_DEFAULT_DATADIM (9U)
|
mas01mc@292
|
127 #define O2_REALTYPE (double)
|
mas01mc@324
|
128 #define O2_MAXFILES (1000000U)
|
mas01cr@0
|
129 #define O2_MAXFILESTR (256U)
|
mas01cr@256
|
130 #define O2_FILETABLE_ENTRY_SIZE (O2_MAXFILESTR)
|
mas01cr@256
|
131 #define O2_TRACKTABLE_ENTRY_SIZE (sizeof(unsigned))
|
mas01cr@0
|
132 #define O2_HEADERSIZE (sizeof(dbTableHeaderT))
|
mas01cr@0
|
133 #define O2_MEANNUMVECTORS (1000U)
|
mas01mc@292
|
134 #define O2_MAXDIM (2000U)
|
mas01mc@263
|
135 #define O2_MAXNN (1000000U)
|
mas01mc@292
|
136 #define O2_MAXSEQLEN (8000U) // maximum feature vectors in a sequence
|
mas01mc@324
|
137 #define O2_MAXTRACKS (1000000U) // maximum number of tracks
|
mas01mc@324
|
138 #define O2_MAXTRACKLEN (1<<LSH_N_POINT_BITS) // maximum shingles in a track
|
mas01mc@292
|
139 #define O2_MAXDOTPRODUCTMEMORY (sizeof(O2_REALTYPE)*O2_MAXSEQLEN*O2_MAXSEQLEN) // 512MB
|
mas01mc@292
|
140 #define O2_DISTANCE_TOLERANCE (1e-6)
|
mas01mc@324
|
141 #define O2_SERIAL_MAX_TRACKBATCH (1000000)
|
mas01mc@324
|
142 #define O2_LARGE_ADB_SIZE (O2_DEFAULT_DATASIZE+1) // datasize at which features are kept externally (in Mbytes)
|
mas01mc@324
|
143 #define O2_LARGE_ADB_NTRACKS (O2_DEFAULT_NTRACKS+1) // ntracks at which features are kept externally
|
mas01mc@324
|
144 #define O2_MAX_VECTORS ( O2_MEANNUMVECTORS * O2_MAXTRACKS )
|
mas01cr@0
|
145
|
mas01cr@0
|
146 // Flags
|
mas01cr@0
|
147 #define O2_FLAG_L2NORM (0x1U)
|
mas01cr@0
|
148 #define O2_FLAG_MINMAX (0x2U)
|
mas01cr@193
|
149 #define O2_FLAG_POWER (0x4U)
|
mas01cr@0
|
150 #define O2_FLAG_TIMES (0x20U)
|
mas01mc@324
|
151 #define O2_FLAG_LARGE_ADB (0x40U)
|
mas01mc@301
|
152 #define DISPLAY_FLAG(x) (x?"on":"off")
|
mas01cr@0
|
153
|
mas01cr@105
|
154 // Query types
|
mas01cr@105
|
155 #define O2_POINT_QUERY (0x4U)
|
mas01cr@105
|
156 #define O2_SEQUENCE_QUERY (0x8U)
|
mas01cr@105
|
157 #define O2_TRACK_QUERY (0x10U)
|
mas01mc@248
|
158 #define O2_N_SEQUENCE_QUERY (0x20U)
|
mas01mc@263
|
159 #define O2_ONE_TO_ONE_N_SEQUENCE_QUERY (0x40U)
|
mas01mc@248
|
160
|
mas01cr@0
|
161 // Error Codes
|
mas01cr@0
|
162 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00)
|
mas01cr@0
|
163
|
mas01cr@0
|
164 // Macros
|
mas01cr@0
|
165 #define O2_ACTION(a) (strcmp(command,a)==0)
|
mas01cr@0
|
166
|
mas01cr@370
|
167 #define ALIGN_UP(x,w) (((x) + ((1<<w)-1)) & ~((1<<w)-1))
|
mas01cr@108
|
168 #define ALIGN_DOWN(x,w) ((x) & ~((1<<w)-1))
|
mas01cr@108
|
169
|
mas01cr@370
|
170 #define ALIGN_PAGE_UP(x) (((x) + (getpagesize()-1)) & ~(getpagesize()-1))
|
mas01cr@196
|
171 #define ALIGN_PAGE_DOWN(x) ((x) & ~(getpagesize()-1))
|
mas01cr@196
|
172
|
mas01cr@166
|
173 #define ENSURE_STRING(x) ((x) ? (x) : "")
|
mas01cr@166
|
174
|
mas01cr@239
|
175 #define CHECKED_MMAP(type, var, start, length) \
|
mas01cr@239
|
176 { void *tmp = mmap(0, length, (PROT_READ | (forWrite ? PROT_WRITE : 0)), MAP_SHARED, dbfid, (start)); \
|
mas01cr@239
|
177 if(tmp == (void *) -1) { \
|
mas01cr@239
|
178 error("mmap error for db table", #var, "mmap"); \
|
mas01cr@239
|
179 } \
|
mas01cr@239
|
180 var = (type) tmp; \
|
mas01cr@239
|
181 }
|
mas01cr@239
|
182
|
mas01cr@370
|
183 #define CHECKED_READ(fd, buf, count) \
|
mas01cr@370
|
184 { size_t tmpcount = count; \
|
mas01cr@370
|
185 ssize_t tmp = read(fd, buf, tmpcount); \
|
mas01cr@370
|
186 if(tmp == -1) { \
|
mas01cr@370
|
187 error("read error", "", "read"); \
|
mas01cr@370
|
188 } else if((size_t) tmp != tmpcount) { \
|
mas01cr@370
|
189 error("short read", ""); \
|
mas01cr@370
|
190 } \
|
mas01cr@370
|
191 }
|
mas01cr@370
|
192
|
mas01cr@370
|
193 #define CHECKED_WRITE(fd, buf, count) \
|
mas01cr@370
|
194 { size_t tmpcount = count; \
|
mas01cr@370
|
195 ssize_t tmp = write(fd, buf, tmpcount); \
|
mas01cr@370
|
196 if(tmp == -1) { \
|
mas01cr@370
|
197 error("write error", "", "write"); \
|
mas01cr@370
|
198 } else if((size_t) tmp != tmpcount) { \
|
mas01cr@370
|
199 error("short write", ""); \
|
mas01cr@370
|
200 } \
|
mas01cr@370
|
201 }
|
mas01cr@370
|
202
|
mas01cr@239
|
203 #define VERB_LOG(vv, ...) \
|
mas01cr@239
|
204 if(verbosity > vv) { \
|
mas01cr@239
|
205 fprintf(stderr, __VA_ARGS__); \
|
mas01cr@239
|
206 fflush(stderr); \
|
mas01cr@239
|
207 }
|
mas01cr@0
|
208
|
mas01mc@324
|
209 // We will only use this in a 32-bit address space
|
mas01mc@324
|
210 // So map the off_t down to 32-bits first
|
mas01mc@324
|
211 #define INSERT_FILETABLE_STRING(TABLE, STR) \
|
mas01mc@324
|
212 strncpy(TABLE + dbH->numFiles*O2_FILETABLE_ENTRY_SIZE, STR, strlen(STR));
|
mas01mc@324
|
213
|
mas01mc@324
|
214 #define SAFE_DELETE(PTR) delete PTR; PTR=0;
|
mas01mc@324
|
215 #define SAFE_DELETE_ARRAY(PTR) delete[] PTR; PTR=0;
|
mas01mc@324
|
216
|
mas01mc@308
|
217 extern LSH* SERVER_LSH_INDEX_SINGLETON;
|
mas01mc@324
|
218 extern char* SERVER_ADB_ROOT;
|
mas01mc@324
|
219 extern char* SERVER_ADB_FEATURE_ROOT;
|
mas01mc@308
|
220
|
mas01cr@210
|
221 typedef struct dbTableHeader {
|
mas01cr@114
|
222 uint32_t magic;
|
mas01cr@114
|
223 uint32_t version;
|
mas01cr@114
|
224 uint32_t numFiles;
|
mas01cr@114
|
225 uint32_t dim;
|
mas01cr@114
|
226 uint32_t flags;
|
mas01cr@210
|
227 uint32_t headerSize;
|
mas01cr@196
|
228 off_t length;
|
mas01cr@196
|
229 off_t fileTableOffset;
|
mas01cr@196
|
230 off_t trackTableOffset;
|
mas01cr@196
|
231 off_t dataOffset;
|
mas01cr@196
|
232 off_t l2normTableOffset;
|
mas01cr@196
|
233 off_t timesTableOffset;
|
mas01cr@196
|
234 off_t powerTableOffset;
|
mas01cr@196
|
235 off_t dbSize;
|
mas01cr@0
|
236 } dbTableHeaderT, *dbTableHeaderPtr;
|
mas01cr@0
|
237
|
mas01mc@308
|
238 class audioDB{
|
mas01cr@0
|
239 private:
|
mas01cr@0
|
240 gengetopt_args_info args_info;
|
mas01cr@0
|
241 unsigned dim;
|
mas01cr@0
|
242 const char *dbName;
|
mas01cr@0
|
243 const char *inFile;
|
mas01cr@0
|
244 const char *hostport;
|
mas01cr@0
|
245 const char *key;
|
mas01mc@18
|
246 const char* trackFileName;
|
mas01cr@239
|
247 std::ifstream *trackFile;
|
mas01cr@0
|
248 const char *command;
|
mas01cr@131
|
249 const char *output;
|
mas01cr@0
|
250 const char *timesFileName;
|
mas01cr@239
|
251 std::ifstream *timesFile;
|
mas01cr@193
|
252 const char *powerFileName;
|
mas01cr@239
|
253 std::ifstream *powerFile;
|
mas01mc@324
|
254 const char* adb_root;
|
mas01mc@324
|
255 const char* adb_feature_root;
|
mas01mc@324
|
256
|
mas01cr@193
|
257 int powerfd;
|
mas01cr@0
|
258 int dbfid;
|
mas01mc@292
|
259 int lshfid;
|
mas01cr@196
|
260 bool forWrite;
|
mas01cr@0
|
261 int infid;
|
mas01cr@0
|
262 struct stat statbuf;
|
mas01cr@0
|
263 dbTableHeaderPtr dbH;
|
mas01cr@392
|
264 struct adb *adb;
|
mas01cr@284
|
265
|
mas01cr@284
|
266 gsl_rng *rng;
|
mas01cr@0
|
267
|
mas01mc@324
|
268 char* fileTable;
|
mas01mc@18
|
269 unsigned* trackTable;
|
mas01cr@0
|
270 double* l2normTable;
|
mas01cr@196
|
271 double* timesTable;
|
mas01cr@193
|
272 double* powerTable;
|
mas01cr@0
|
273
|
mas01mc@324
|
274 char* featureFileNameTable;
|
mas01mc@324
|
275 char* timesFileNameTable;
|
mas01mc@324
|
276 char* powerFileNameTable;
|
mas01mc@324
|
277
|
mas01cr@196
|
278 size_t fileTableLength;
|
mas01cr@196
|
279 size_t trackTableLength;
|
mas01cr@196
|
280 size_t timesTableLength;
|
mas01cr@196
|
281 size_t powerTableLength;
|
mas01cr@196
|
282 size_t l2normTableLength;
|
mas01cr@196
|
283
|
mas01cr@0
|
284 // Flags and parameters
|
mas01cr@0
|
285 unsigned verbosity; // how much do we want to know?
|
mas01cr@256
|
286
|
mas01cr@280
|
287 unsigned nsamples;
|
mas01cr@280
|
288
|
mas01cr@256
|
289 //off_t size; // given size (for creation)
|
mas01cr@256
|
290 unsigned datasize; // size in MB
|
mas01cr@256
|
291 unsigned ntracks;
|
mas01cr@256
|
292 unsigned datadim;
|
mas01cr@256
|
293
|
mas01cr@0
|
294 unsigned queryType; // point queries default
|
mas01cr@0
|
295 unsigned pointNN; // how many point NNs ?
|
mas01mc@18
|
296 unsigned trackNN; // how many track NNs ?
|
mas01cr@0
|
297 unsigned sequenceLength;
|
mas01cr@0
|
298 unsigned sequenceHop;
|
mas01cr@239
|
299 bool normalizedDistance;
|
mas01mc@292
|
300 bool no_unit_norming;
|
mas01cr@0
|
301 unsigned queryPoint;
|
mas01cr@0
|
302 unsigned usingQueryPoint;
|
mas01cr@0
|
303 unsigned usingTimes;
|
mas01cr@193
|
304 unsigned usingPower;
|
mas01cr@0
|
305 unsigned isClient;
|
mas01cr@0
|
306 unsigned isServer;
|
mas01cr@0
|
307 unsigned port;
|
mas01cr@0
|
308 double timesTol;
|
mas01mc@17
|
309 double radius;
|
mas01mc@292
|
310 bool query_from_key;
|
mas01mc@292
|
311 Uns32T query_from_key_index;
|
mas01cr@193
|
312 bool use_absolute_threshold;
|
mas01cr@193
|
313 double absolute_threshold;
|
mas01cr@193
|
314 bool use_relative_threshold;
|
mas01cr@193
|
315 double relative_threshold;
|
mas01mc@334
|
316
|
mas01mc@292
|
317 ReporterBase* reporter; // track/point reporter
|
mas01mc@292
|
318
|
mas01mc@334
|
319 // LISZT parameters
|
mas01mc@334
|
320 unsigned lisztOffset;
|
mas01mc@334
|
321 unsigned lisztLength;
|
mas01mc@334
|
322
|
mas01ik@355
|
323 //for lib / API
|
mas01cr@370
|
324 int apierrortemp;
|
mas01ik@355
|
325 unsigned UseApiError;
|
mas01ik@355
|
326
|
mas01cr@0
|
327 // private methods
|
mas01cr@32
|
328 void error(const char* a, const char* b = "", const char *sysFunc = 0);
|
mas01ik@355
|
329
|
mas01cr@405
|
330 void insertTimeStamps(unsigned n, std::ifstream* timesFile, double* timesdata);
|
mas01cr@458
|
331 int query_loop(adb_t *adb, adb_query_spec_t *spec, adb_qstate_internal_t *qstate);
|
mas01cr@458
|
332 void query_loop_points(adb_t *adb, adb_query_spec_t *spec, adb_qstate_internal_t *qstate, double *query, adb_qpointers_internal_t *qpointers);
|
mas01cr@284
|
333 void initRNG();
|
mas01cr@196
|
334 void initDBHeader(const char *dbName);
|
mas01cr@454
|
335 void initInputFile(const char *inFile);
|
mas01mc@292
|
336 void initTables(const char* dbName, const char* inFile = 0);
|
mas01mc@292
|
337 void initTablesFromKey(const char* dbName, const Uns32T queryIndex);
|
mas01mc@324
|
338 void prefix_name(char** const name, const char* prefix);
|
mas01mc@324
|
339
|
mas01cr@0
|
340 public:
|
mas01cr@370
|
341 audioDB(const unsigned argc, const char *argv[]);
|
mas01cr@370
|
342 audioDB(const unsigned argc, const char *argv[], adb__queryResponse *adbQueryResponse);
|
mas01cr@370
|
343 audioDB(const unsigned argc, const char *argv[], adb__statusResponse *adbStatusResponse);
|
mas01cr@370
|
344 audioDB(const unsigned argc, const char *argv[], adb__lisztResponse *adbLisztResponse);
|
mas01cr@395
|
345 audioDB(const unsigned argc, const char *argv[],adb__queryResponse *adbQueryResponse, int * apierror, struct adb *a);
|
mas01ik@355
|
346
|
mas01mc@334
|
347
|
mas01cr@97
|
348 void cleanup();
|
mas01cr@0
|
349 ~audioDB();
|
mas01cr@370
|
350 int processArgs(const unsigned argc, const char* argv[]);
|
mas01cr@30
|
351 void get_lock(int fd, bool exclusive);
|
mas01cr@30
|
352 void release_lock(int fd);
|
mas01cr@0
|
353 void create(const char* dbName);
|
mas01cr@0
|
354 void insert(const char* dbName, const char* inFile);
|
mas01cr@0
|
355 void batchinsert(const char* dbName, const char* inFile);
|
mas01cr@133
|
356 void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);
|
mas01cr@133
|
357 void status(const char* dbName, adb__statusResponse *adbStatusResponse=0);
|
mas01ik@355
|
358
|
mas01cr@284
|
359 unsigned random_track(unsigned *propTable, unsigned total);
|
mas01cr@280
|
360 void sample(const char *dbName);
|
mas01cr@0
|
361 void l2norm(const char* dbName);
|
mas01cr@193
|
362 void power_flag(const char *dbName);
|
mas01cr@0
|
363 void dump(const char* dbName);
|
mas01mc@334
|
364 void liszt(const char* dbName, unsigned offset, unsigned numLines, adb__lisztResponse* adbLisztResponse=0);
|
mas01cr@0
|
365
|
mas01mc@292
|
366 // LSH indexing parameters and data structures
|
mas01mc@292
|
367 LSH* lsh;
|
mas01mc@292
|
368 bool lsh_in_core; // load LSH tables for query into core (true) or keep on disk (false)
|
mas01mc@292
|
369 bool lsh_use_u_functions;
|
mas01mc@292
|
370 bool lsh_exact; // flag to indicate use exact evaluation of points returned by LSH
|
mas01mc@308
|
371 bool WS_load_index; // flag to indicate that we want to make a Web Services index memory resident
|
mas01mc@292
|
372 double lsh_param_w; // Width of LSH hash-function bins
|
mas01mc@292
|
373 Uns32T lsh_param_k; // Number of independent hash functions
|
mas01mc@292
|
374 Uns32T lsh_param_m; // Combinatorial parameter for m(m-1)/2 hash tables
|
mas01mc@292
|
375 Uns32T lsh_param_N; // Number of rows per hash table
|
mas01mc@292
|
376 Uns32T lsh_param_b; // Batch size, in number of tracks, per indexing iteration
|
mas01mc@292
|
377 Uns32T lsh_param_ncols; // Maximum number of collision in a hash-table row
|
mas01mc@324
|
378
|
mas01mc@292
|
379 // LSH indexing and retrieval methods
|
mas01mc@292
|
380 void index_index_db(const char* dbName);
|
mas01mc@292
|
381 void index_initialize(double**,double**,double**,double**,unsigned int*);
|
mas01mc@292
|
382 void index_insert_tracks(Uns32T start_track, Uns32T end_track, double** fvpp, double** sNormpp,double** snPtrp, double** sPowerp, double** spPtrp);
|
mas01mc@292
|
383 int index_insert_track(Uns32T trackID, double** fvpp, double** snpp, double** sppp);
|
mas01mc@292
|
384 Uns32T index_insert_shingles(vector<vector<float> >*, Uns32T trackID, double* spp);
|
mas01cr@458
|
385 int index_query_loop(adb_t *adb, adb_query_spec_t *spec, adb_qstate_internal_t *qstate);
|
mas01mc@292
|
386 int index_init_query(const char* dbName);
|
mas01mc@292
|
387 int index_exists(const char* dbName, double radius, Uns32T sequenceLength);
|
mas01mc@292
|
388 char* index_get_name(const char*dbName, double radius, Uns32T sequenceLength);
|
mas01mc@308
|
389 LSH* index_allocate(char* indexName, bool load_hashTables);
|
mas01cr@405
|
390 void insertPowerData(unsigned n, int powerfd, double *powerdata);
|
mas01mc@324
|
391 void init_track_aux_data(Uns32T trackID, double* fvp, double** sNormpp,double** snPtrp, double** sPowerp, double** spPtrp);
|
mas01mc@324
|
392
|
mas01mc@292
|
393 // Web Services
|
mas01cr@0
|
394 void startServer();
|
mas01ik@355
|
395
|
mas01mc@308
|
396 void ws_status(const char*dbName, char* hostport);
|
mas01mc@308
|
397 void ws_query(const char*dbName, const char *featureFileName, const char* hostport);
|
mas01mc@328
|
398 void ws_query_by_key(const char*dbName, const char *trackKey, const char* featureFileName, const char* hostport);
|
mas01mc@334
|
399 void ws_liszt(const char* dbName, char* hostport);
|
mas01mc@334
|
400
|
mas01cr@0
|
401 };
|
mas01mc@17
|
402
|
mas01mc@292
|
403 #define O2_AUDIODB_INITIALIZERS \
|
mas01mc@292
|
404 dim(0), \
|
mas01mc@292
|
405 dbName(0), \
|
mas01mc@292
|
406 inFile(0), \
|
mas01mc@292
|
407 key(0), \
|
mas01mc@292
|
408 trackFileName(0), \
|
mas01mc@292
|
409 trackFile(0), \
|
mas01mc@292
|
410 command(0), \
|
mas01mc@292
|
411 output(0), \
|
mas01mc@292
|
412 timesFileName(0), \
|
mas01mc@292
|
413 timesFile(0), \
|
mas01mc@292
|
414 powerFileName(0), \
|
mas01mc@292
|
415 powerFile(0), \
|
mas01mc@324
|
416 adb_root(0), \
|
mas01mc@324
|
417 adb_feature_root(0), \
|
mas01mc@324
|
418 powerfd(0), \
|
mas01mc@292
|
419 dbfid(0), \
|
mas01mc@292
|
420 lshfid(0), \
|
mas01mc@292
|
421 forWrite(false), \
|
mas01mc@292
|
422 infid(0), \
|
mas01mc@292
|
423 dbH(0), \
|
mas01cr@392
|
424 adb(0), \
|
mas01mc@292
|
425 rng(0), \
|
mas01mc@292
|
426 fileTable(0), \
|
mas01mc@292
|
427 trackTable(0), \
|
mas01mc@292
|
428 l2normTable(0), \
|
mas01mc@292
|
429 timesTable(0), \
|
mas01mc@314
|
430 powerTable(0), \
|
mas01mc@324
|
431 featureFileNameTable(0), \
|
mas01mc@324
|
432 timesFileNameTable(0), \
|
mas01mc@324
|
433 powerFileNameTable(0), \
|
mas01mc@292
|
434 fileTableLength(0), \
|
mas01mc@292
|
435 trackTableLength(0), \
|
mas01mc@292
|
436 timesTableLength(0), \
|
mas01mc@292
|
437 powerTableLength(0), \
|
mas01mc@292
|
438 l2normTableLength(0), \
|
mas01mc@292
|
439 verbosity(1), \
|
mas01mc@292
|
440 nsamples(2000), \
|
mas01mc@292
|
441 datasize(O2_DEFAULT_DATASIZE), \
|
mas01mc@292
|
442 ntracks(O2_DEFAULT_NTRACKS), \
|
mas01mc@292
|
443 datadim(O2_DEFAULT_DATADIM), \
|
mas01mc@292
|
444 queryType(O2_POINT_QUERY), \
|
mas01mc@292
|
445 pointNN(O2_DEFAULT_POINTNN), \
|
mas01mc@292
|
446 trackNN(O2_DEFAULT_TRACKNN), \
|
mas01mc@292
|
447 sequenceLength(16), \
|
mas01mc@292
|
448 sequenceHop(1), \
|
mas01mc@292
|
449 normalizedDistance(true), \
|
mas01mc@292
|
450 no_unit_norming(false), \
|
mas01mc@292
|
451 queryPoint(0), \
|
mas01mc@292
|
452 usingQueryPoint(0), \
|
mas01mc@292
|
453 usingTimes(0), \
|
mas01mc@292
|
454 usingPower(0), \
|
mas01mc@292
|
455 isClient(0), \
|
mas01mc@292
|
456 isServer(0), \
|
mas01mc@292
|
457 port(0), \
|
mas01mc@292
|
458 timesTol(0.1), \
|
mas01mc@292
|
459 radius(0), \
|
mas01mc@292
|
460 query_from_key(false), \
|
mas01cr@430
|
461 query_from_key_index((uint32_t) -1), \
|
mas01mc@292
|
462 use_absolute_threshold(false), \
|
mas01mc@292
|
463 absolute_threshold(0.0), \
|
mas01mc@292
|
464 use_relative_threshold(false), \
|
mas01mc@292
|
465 relative_threshold(0.0), \
|
mas01mc@292
|
466 reporter(0), \
|
mas01mc@334
|
467 lisztOffset(0), \
|
mas01mc@334
|
468 lisztLength(0), \
|
mas01cr@370
|
469 apierrortemp(0), \
|
mas01cr@370
|
470 UseApiError(0), \
|
mas01mc@292
|
471 lsh(0), \
|
mas01mc@292
|
472 lsh_in_core(false), \
|
mas01mc@292
|
473 lsh_use_u_functions(false), \
|
mas01mc@292
|
474 lsh_exact(false), \
|
mas01mc@308
|
475 WS_load_index(false), \
|
mas01mc@292
|
476 lsh_param_k(0), \
|
mas01mc@292
|
477 lsh_param_m(0), \
|
mas01mc@292
|
478 lsh_param_N(0), \
|
mas01mc@292
|
479 lsh_param_b(0), \
|
mas01cr@459
|
480 lsh_param_ncols(0)
|
mas01mc@292
|
481 #endif
|