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@302
|
14 #include <string>
|
mas01cr@0
|
15 #include <math.h>
|
mas01cr@0
|
16 #include <sys/time.h>
|
mas01cr@0
|
17 #include <assert.h>
|
mas01cr@62
|
18 #include <float.h>
|
mas01cr@104
|
19 #include <signal.h>
|
mas01cr@280
|
20 #include <gsl/gsl_rng.h>
|
mas01cr@0
|
21
|
mas01mc@292
|
22 // includes for LSH indexing
|
mas01mc@292
|
23 #include "ReporterBase.h"
|
mas01mc@292
|
24 #include "lshlib.h"
|
mas01mc@292
|
25
|
mas01cr@0
|
26 // includes for web services
|
mas01cr@0
|
27 #include "soapH.h"
|
mas01cr@0
|
28 #include "cmdline.h"
|
mas01cr@0
|
29
|
mas01cr@0
|
30 #define MAXSTR 512
|
mas01cr@0
|
31
|
mas01cr@0
|
32 // Databse PRIMARY commands
|
mas01cr@0
|
33 #define COM_CREATE "--NEW"
|
mas01cr@0
|
34 #define COM_INSERT "--INSERT"
|
mas01cr@0
|
35 #define COM_BATCHINSERT "--BATCHINSERT"
|
mas01cr@0
|
36 #define COM_QUERY "--QUERY"
|
mas01cr@0
|
37 #define COM_STATUS "--STATUS"
|
mas01cr@0
|
38 #define COM_L2NORM "--L2NORM"
|
mas01cr@193
|
39 #define COM_POWER "--POWER"
|
mas01cr@0
|
40 #define COM_DUMP "--DUMP"
|
mas01cr@0
|
41 #define COM_SERVER "--SERVER"
|
mas01mc@292
|
42 #define COM_INDEX "--INDEX"
|
mas01cr@280
|
43 #define COM_SAMPLE "--SAMPLE"
|
mas01cr@0
|
44
|
mas01cr@0
|
45 // parameters
|
mas01cr@0
|
46 #define COM_CLIENT "--client"
|
mas01cr@0
|
47 #define COM_DATABASE "--database"
|
mas01cr@0
|
48 #define COM_QTYPE "--qtype"
|
mas01cr@0
|
49 #define COM_SEQLEN "--sequencelength"
|
mas01cr@0
|
50 #define COM_SEQHOP "--sequencehop"
|
mas01cr@0
|
51 #define COM_POINTNN "--pointnn"
|
mas01mc@18
|
52 #define COM_TRACKNN "--resultlength"
|
mas01cr@0
|
53 #define COM_QPOINT "--qpoint"
|
mas01cr@0
|
54 #define COM_FEATURES "--features"
|
mas01cr@0
|
55 #define COM_QUERYKEY "--key"
|
mas01cr@0
|
56 #define COM_KEYLIST "--keyList"
|
mas01cr@0
|
57 #define COM_TIMES "--times"
|
mas01cr@193
|
58 #define COM_QUERYPOWER "--power"
|
mas01cr@193
|
59 #define COM_RELATIVE_THRESH "--relative-threshold"
|
mas01cr@193
|
60 #define COM_ABSOLUTE_THRESH "--absolute-threshold"
|
mas01cr@0
|
61
|
mas01cr@108
|
62 #define O2_OLD_MAGIC ('O'|'2'<<8|'D'<<16|'B'<<24)
|
mas01cr@108
|
63 #define O2_MAGIC ('o'|'2'<<8|'d'<<16|'b'<<24)
|
mas01cr@210
|
64 #define O2_FORMAT_VERSION (4U)
|
mas01cr@0
|
65
|
mas01cr@0
|
66 #define O2_DEFAULT_POINTNN (10U)
|
mas01mc@18
|
67 #define O2_DEFAULT_TRACKNN (10U)
|
mas01cr@0
|
68
|
mas01mc@248
|
69 //#define O2_DEFAULTDBSIZE (4000000000) // 4GB table size
|
mas01mc@7
|
70 #define O2_DEFAULTDBSIZE (2000000000) // 2GB table size
|
mas01cr@0
|
71
|
mas01mc@295
|
72 // Bit masks for packing (trackID,pointID) into 32-bit unsigned int
|
mas01mc@295
|
73 #define LSH_N_POINT_BITS 14
|
mas01mc@295
|
74 #define LSH_TRACK_MASK 0xFFFFC000U // 2^18 = 262144 tracks
|
mas01mc@295
|
75 #define LSH_POINT_MASK 0x00003FFFU // 2^14 = 16384 points per track
|
mas01mc@295
|
76
|
mas01mc@295
|
77 // LIMIT PARAMETERS
|
mas01cr@256
|
78 #define O2_DEFAULT_DATASIZE (1355U) // in MB
|
mas01cr@256
|
79 #define O2_DEFAULT_NTRACKS (20000U)
|
mas01cr@256
|
80 #define O2_DEFAULT_DATADIM (9U)
|
mas01mc@292
|
81 #define O2_REALTYPE (double)
|
mas01cr@239
|
82 #define O2_MAXFILES (20000U)
|
mas01cr@0
|
83 #define O2_MAXFILESTR (256U)
|
mas01cr@256
|
84 #define O2_FILETABLE_ENTRY_SIZE (O2_MAXFILESTR)
|
mas01cr@256
|
85 #define O2_TRACKTABLE_ENTRY_SIZE (sizeof(unsigned))
|
mas01cr@0
|
86 #define O2_HEADERSIZE (sizeof(dbTableHeaderT))
|
mas01cr@0
|
87 #define O2_MEANNUMVECTORS (1000U)
|
mas01mc@292
|
88 #define O2_MAXDIM (2000U)
|
mas01mc@263
|
89 #define O2_MAXNN (1000000U)
|
mas01mc@292
|
90 #define O2_MAXSEQLEN (8000U) // maximum feature vectors in a sequence
|
mas01mc@292
|
91 #define O2_MAXTRACKS (10000U) // maximum number of tracks
|
mas01mc@295
|
92 #define O2_MAXTRACKLEN ((LSH_POINT_MASK+1)) // maximum shingles in a track
|
mas01mc@292
|
93 #define O2_MAXDOTPRODUCTMEMORY (sizeof(O2_REALTYPE)*O2_MAXSEQLEN*O2_MAXSEQLEN) // 512MB
|
mas01mc@292
|
94 #define O2_DISTANCE_TOLERANCE (1e-6)
|
mas01mc@292
|
95 #define O2_SERIAL_MAX_TRACKBATCH (10000)
|
mas01cr@0
|
96
|
mas01cr@0
|
97 // Flags
|
mas01cr@0
|
98 #define O2_FLAG_L2NORM (0x1U)
|
mas01cr@0
|
99 #define O2_FLAG_MINMAX (0x2U)
|
mas01cr@193
|
100 #define O2_FLAG_POWER (0x4U)
|
mas01cr@0
|
101 #define O2_FLAG_TIMES (0x20U)
|
mas01mc@301
|
102 #define DISPLAY_FLAG(x) (x?"on":"off")
|
mas01cr@0
|
103
|
mas01cr@105
|
104 // Query types
|
mas01cr@105
|
105 #define O2_POINT_QUERY (0x4U)
|
mas01cr@105
|
106 #define O2_SEQUENCE_QUERY (0x8U)
|
mas01cr@105
|
107 #define O2_TRACK_QUERY (0x10U)
|
mas01mc@248
|
108 #define O2_N_SEQUENCE_QUERY (0x20U)
|
mas01mc@263
|
109 #define O2_ONE_TO_ONE_N_SEQUENCE_QUERY (0x40U)
|
mas01mc@248
|
110
|
mas01cr@0
|
111 // Error Codes
|
mas01cr@0
|
112 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00)
|
mas01cr@0
|
113
|
mas01cr@0
|
114 // Macros
|
mas01cr@0
|
115 #define O2_ACTION(a) (strcmp(command,a)==0)
|
mas01cr@0
|
116
|
mas01cr@108
|
117 #define ALIGN_UP(x,w) ((x) + ((1<<w)-1) & ~((1<<w)-1))
|
mas01cr@108
|
118 #define ALIGN_DOWN(x,w) ((x) & ~((1<<w)-1))
|
mas01cr@108
|
119
|
mas01cr@196
|
120 #define ALIGN_PAGE_UP(x) ((x) + (getpagesize()-1) & ~(getpagesize()-1))
|
mas01cr@196
|
121 #define ALIGN_PAGE_DOWN(x) ((x) & ~(getpagesize()-1))
|
mas01cr@196
|
122
|
mas01cr@166
|
123 #define ENSURE_STRING(x) ((x) ? (x) : "")
|
mas01cr@166
|
124
|
mas01cr@239
|
125 #define CHECKED_MMAP(type, var, start, length) \
|
mas01cr@239
|
126 { void *tmp = mmap(0, length, (PROT_READ | (forWrite ? PROT_WRITE : 0)), MAP_SHARED, dbfid, (start)); \
|
mas01cr@239
|
127 if(tmp == (void *) -1) { \
|
mas01cr@239
|
128 error("mmap error for db table", #var, "mmap"); \
|
mas01cr@239
|
129 } \
|
mas01cr@239
|
130 var = (type) tmp; \
|
mas01cr@239
|
131 }
|
mas01cr@239
|
132
|
mas01cr@239
|
133 #define VERB_LOG(vv, ...) \
|
mas01cr@239
|
134 if(verbosity > vv) { \
|
mas01cr@239
|
135 fprintf(stderr, __VA_ARGS__); \
|
mas01cr@239
|
136 fflush(stderr); \
|
mas01cr@239
|
137 }
|
mas01cr@0
|
138
|
mas01cr@210
|
139 typedef struct dbTableHeader {
|
mas01cr@114
|
140 uint32_t magic;
|
mas01cr@114
|
141 uint32_t version;
|
mas01cr@114
|
142 uint32_t numFiles;
|
mas01cr@114
|
143 uint32_t dim;
|
mas01cr@114
|
144 uint32_t flags;
|
mas01cr@210
|
145 uint32_t headerSize;
|
mas01cr@196
|
146 off_t length;
|
mas01cr@196
|
147 off_t fileTableOffset;
|
mas01cr@196
|
148 off_t trackTableOffset;
|
mas01cr@196
|
149 off_t dataOffset;
|
mas01cr@196
|
150 off_t l2normTableOffset;
|
mas01cr@196
|
151 off_t timesTableOffset;
|
mas01cr@196
|
152 off_t powerTableOffset;
|
mas01cr@196
|
153 off_t dbSize;
|
mas01cr@0
|
154 } dbTableHeaderT, *dbTableHeaderPtr;
|
mas01cr@0
|
155
|
mas01mc@292
|
156
|
mas01mc@292
|
157 class PointPair{
|
mas01mc@292
|
158 public:
|
mas01mc@292
|
159 Uns32T trackID;
|
mas01mc@292
|
160 Uns32T qpos;
|
mas01mc@292
|
161 Uns32T spos;
|
mas01mc@292
|
162 PointPair(Uns32T a, Uns32T b, Uns32T c);
|
mas01mc@292
|
163 };
|
mas01mc@292
|
164
|
mas01mc@292
|
165 bool operator<(const PointPair& a, const PointPair& b);
|
mas01cr@0
|
166
|
mas01cr@0
|
167 class audioDB{
|
mas01cr@0
|
168
|
mas01cr@0
|
169 private:
|
mas01cr@0
|
170 gengetopt_args_info args_info;
|
mas01cr@0
|
171 unsigned dim;
|
mas01cr@0
|
172 const char *dbName;
|
mas01cr@0
|
173 const char *inFile;
|
mas01cr@0
|
174 const char *hostport;
|
mas01cr@0
|
175 const char *key;
|
mas01mc@18
|
176 const char* trackFileName;
|
mas01cr@239
|
177 std::ifstream *trackFile;
|
mas01cr@0
|
178 const char *command;
|
mas01cr@131
|
179 const char *output;
|
mas01cr@0
|
180 const char *timesFileName;
|
mas01cr@239
|
181 std::ifstream *timesFile;
|
mas01cr@193
|
182 const char *powerFileName;
|
mas01cr@239
|
183 std::ifstream *powerFile;
|
mas01cr@193
|
184 int powerfd;
|
mas01cr@0
|
185
|
mas01cr@0
|
186 int dbfid;
|
mas01mc@292
|
187 int lshfid;
|
mas01cr@196
|
188 bool forWrite;
|
mas01cr@0
|
189 int infid;
|
mas01cr@0
|
190 char* db;
|
mas01cr@0
|
191 char* indata;
|
mas01cr@0
|
192 struct stat statbuf;
|
mas01cr@0
|
193 dbTableHeaderPtr dbH;
|
mas01cr@284
|
194
|
mas01cr@284
|
195 gsl_rng *rng;
|
mas01cr@0
|
196
|
mas01cr@0
|
197 char *fileTable;
|
mas01mc@18
|
198 unsigned* trackTable;
|
mas01mc@292
|
199 off_t *trackOffsetTable;
|
mas01cr@0
|
200 double* dataBuf;
|
mas01cr@0
|
201 double* inBuf;
|
mas01cr@0
|
202 double* l2normTable;
|
mas01cr@196
|
203 double* timesTable;
|
mas01cr@193
|
204 double* powerTable;
|
mas01cr@0
|
205
|
mas01cr@196
|
206 size_t fileTableLength;
|
mas01cr@196
|
207 size_t trackTableLength;
|
mas01cr@196
|
208 off_t dataBufLength;
|
mas01cr@196
|
209 size_t timesTableLength;
|
mas01cr@196
|
210 size_t powerTableLength;
|
mas01cr@196
|
211 size_t l2normTableLength;
|
mas01cr@196
|
212
|
mas01cr@0
|
213 // Flags and parameters
|
mas01cr@0
|
214 unsigned verbosity; // how much do we want to know?
|
mas01cr@256
|
215
|
mas01cr@280
|
216 unsigned nsamples;
|
mas01cr@280
|
217
|
mas01cr@256
|
218 //off_t size; // given size (for creation)
|
mas01cr@256
|
219 unsigned datasize; // size in MB
|
mas01cr@256
|
220 unsigned ntracks;
|
mas01cr@256
|
221 unsigned datadim;
|
mas01cr@256
|
222
|
mas01cr@0
|
223 unsigned queryType; // point queries default
|
mas01cr@0
|
224 unsigned pointNN; // how many point NNs ?
|
mas01mc@18
|
225 unsigned trackNN; // how many track NNs ?
|
mas01cr@0
|
226 unsigned sequenceLength;
|
mas01cr@0
|
227 unsigned sequenceHop;
|
mas01cr@239
|
228 bool normalizedDistance;
|
mas01mc@292
|
229 bool no_unit_norming;
|
mas01cr@0
|
230 unsigned queryPoint;
|
mas01cr@0
|
231 unsigned usingQueryPoint;
|
mas01cr@0
|
232 unsigned usingTimes;
|
mas01cr@193
|
233 unsigned usingPower;
|
mas01cr@0
|
234 unsigned isClient;
|
mas01cr@0
|
235 unsigned isServer;
|
mas01cr@0
|
236 unsigned port;
|
mas01cr@0
|
237 double timesTol;
|
mas01mc@17
|
238 double radius;
|
mas01mc@292
|
239 bool query_from_key;
|
mas01mc@292
|
240 Uns32T query_from_key_index;
|
mas01cr@193
|
241 bool use_absolute_threshold;
|
mas01cr@193
|
242 double absolute_threshold;
|
mas01cr@193
|
243 bool use_relative_threshold;
|
mas01cr@193
|
244 double relative_threshold;
|
mas01cr@193
|
245
|
mas01mc@292
|
246 ReporterBase* reporter; // track/point reporter
|
mas01mc@292
|
247 priority_queue<PointPair, std::vector<PointPair>, std::less<PointPair> >* exact_evaluation_queue;
|
mas01mc@292
|
248
|
mas01cr@0
|
249 // Timers
|
mas01cr@0
|
250 struct timeval tv1;
|
mas01cr@0
|
251 struct timeval tv2;
|
mas01cr@0
|
252
|
mas01cr@0
|
253 // private methods
|
mas01cr@32
|
254 void error(const char* a, const char* b = "", const char *sysFunc = 0);
|
mas01cr@193
|
255 void sequence_sum(double *buffer, int length, int seqlen);
|
mas01cr@193
|
256 void sequence_sqrt(double *buffer, int length, int seqlen);
|
mas01cr@193
|
257 void sequence_average(double *buffer, int length, int seqlen);
|
mas01cr@193
|
258
|
mas01cr@239
|
259 void initialize_arrays(int track, unsigned int numVectors, double *query, double *data_buffer, double **D, double **DD);
|
mas01cr@239
|
260 void delete_arrays(int track, unsigned int numVectors, double **D, double **DD);
|
mas01cr@239
|
261 void read_data(int track, double **data_buffer_p, size_t *data_buffer_size_p);
|
mas01cr@239
|
262 void set_up_query(double **qp, double **vqp, double **qnp, double **vqnp, double **qpp, double **vqpp, double *mqdp, unsigned int *nvp);
|
mas01mc@292
|
263 void set_up_query_from_key(double **qp, double **vqp, double **qnp, double **vqnp, double **qpp, double **vqpp, double *mqdp, unsigned *nvp, Uns32T queryIndex);
|
mas01cr@239
|
264 void set_up_db(double **snp, double **vsnp, double **spp, double **vspp, double **mddp, unsigned int *dvp);
|
mas01mc@292
|
265 void query_loop(const char* dbName, Uns32T queryIndex);
|
mas01mc@292
|
266 void query_loop_points(double* query, double* qnPtr, double* qpPtr, double meanQdur, Uns32T numVectors);
|
mas01mc@292
|
267 double dot_product_points(double* q, double* p, Uns32T L);
|
mas01cr@284
|
268 void initRNG();
|
mas01cr@196
|
269 void initDBHeader(const char *dbName);
|
mas01cr@169
|
270 void initInputFile(const char *inFile);
|
mas01mc@292
|
271 void initTables(const char* dbName, const char* inFile = 0);
|
mas01mc@292
|
272 void initTablesFromKey(const char* dbName, const Uns32T queryIndex);
|
mas01cr@0
|
273 void unitNorm(double* X, unsigned d, unsigned n, double* qNorm);
|
mas01cr@0
|
274 void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append);
|
mas01cr@239
|
275 void insertTimeStamps(unsigned n, std::ifstream* timesFile, double* timesdata);
|
mas01cr@193
|
276 void insertPowerData(unsigned n, int powerfd, double *powerdata);
|
mas01cr@0
|
277 unsigned getKeyPos(char* key);
|
mas01cr@0
|
278 public:
|
mas01cr@76
|
279 audioDB(const unsigned argc, char* const argv[]);
|
mas01cr@133
|
280 audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse);
|
mas01cr@133
|
281 audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse);
|
mas01cr@97
|
282 void cleanup();
|
mas01cr@0
|
283 ~audioDB();
|
mas01cr@0
|
284 int processArgs(const unsigned argc, char* const argv[]);
|
mas01cr@30
|
285 void get_lock(int fd, bool exclusive);
|
mas01cr@30
|
286 void release_lock(int fd);
|
mas01cr@0
|
287 void create(const char* dbName);
|
mas01cr@0
|
288 void drop();
|
mas01cr@251
|
289 bool enough_per_file_space_free();
|
mas01cr@196
|
290 bool enough_data_space_free(off_t size);
|
mas01cr@196
|
291 void insert_data_vectors(off_t offset, void *buffer, size_t size);
|
mas01cr@0
|
292 void insert(const char* dbName, const char* inFile);
|
mas01cr@0
|
293 void batchinsert(const char* dbName, const char* inFile);
|
mas01cr@133
|
294 void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);
|
mas01cr@133
|
295 void status(const char* dbName, adb__statusResponse *adbStatusResponse=0);
|
mas01cr@284
|
296 unsigned random_track(unsigned *propTable, unsigned total);
|
mas01cr@280
|
297 void sample(const char *dbName);
|
mas01cr@0
|
298 void ws_status(const char*dbName, char* hostport);
|
mas01mc@18
|
299 void ws_query(const char*dbName, const char *trackKey, const char* hostport);
|
mas01cr@0
|
300 void l2norm(const char* dbName);
|
mas01cr@193
|
301 void power_flag(const char *dbName);
|
mas01cr@193
|
302 bool powers_acceptable(double p1, double p2);
|
mas01cr@0
|
303 void dump(const char* dbName);
|
mas01cr@0
|
304
|
mas01mc@292
|
305 // LSH indexing parameters and data structures
|
mas01mc@292
|
306 LSH* lsh;
|
mas01mc@292
|
307 bool lsh_in_core; // load LSH tables for query into core (true) or keep on disk (false)
|
mas01mc@292
|
308 bool lsh_use_u_functions;
|
mas01mc@292
|
309 bool lsh_exact; // flag to indicate use exact evaluation of points returned by LSH
|
mas01mc@292
|
310 double lsh_param_w; // Width of LSH hash-function bins
|
mas01mc@292
|
311 Uns32T lsh_param_k; // Number of independent hash functions
|
mas01mc@292
|
312 Uns32T lsh_param_m; // Combinatorial parameter for m(m-1)/2 hash tables
|
mas01mc@292
|
313 Uns32T lsh_param_N; // Number of rows per hash table
|
mas01mc@292
|
314 Uns32T lsh_param_b; // Batch size, in number of tracks, per indexing iteration
|
mas01mc@292
|
315 Uns32T lsh_param_ncols; // Maximum number of collision in a hash-table row
|
mas01mc@292
|
316
|
mas01mc@292
|
317 // LSH vector<> containers for one in-core copy of a set of feature vectors
|
mas01mc@292
|
318 vector<float>::iterator vi; // feature vector iterator
|
mas01mc@292
|
319 vector<vector<float> > *vv; // one-track's worth data
|
mas01mc@292
|
320
|
mas01mc@292
|
321 // LSH indexing and retrieval methods
|
mas01mc@292
|
322 void index_index_db(const char* dbName);
|
mas01mc@292
|
323 void index_initialize(double**,double**,double**,double**,unsigned int*);
|
mas01mc@292
|
324 void index_insert_tracks(Uns32T start_track, Uns32T end_track, double** fvpp, double** sNormpp,double** snPtrp, double** sPowerp, double** spPtrp);
|
mas01mc@292
|
325 int index_insert_track(Uns32T trackID, double** fvpp, double** snpp, double** sppp);
|
mas01mc@292
|
326 Uns32T index_insert_shingles(vector<vector<float> >*, Uns32T trackID, double* spp);
|
mas01mc@292
|
327 void index_make_shingle(vector<vector<float> >*, Uns32T idx, double* fvp, Uns32T dim, Uns32T seqLen);
|
mas01mc@292
|
328 int index_norm_shingles(vector<vector<float> >*, double* snp, double* spp);
|
mas01mc@292
|
329 int index_query_loop(const char* dbName, Uns32T queryIndex);
|
mas01mc@292
|
330 vector<vector<float> >* index_initialize_shingles(Uns32T sz);
|
mas01mc@292
|
331 int index_init_query(const char* dbName);
|
mas01mc@292
|
332 int index_exists(const char* dbName, double radius, Uns32T sequenceLength);
|
mas01mc@292
|
333 char* index_get_name(const char*dbName, double radius, Uns32T sequenceLength);
|
mas01mc@292
|
334 static void index_add_point_approximate(void* instance, Uns32T pointID, Uns32T qpos, float dist); // static point reporter callback method
|
mas01mc@292
|
335 static void index_add_point_exact(void* instance, Uns32T pointID, Uns32T qpos, float dist); // static point reporter callback method
|
mas01mc@292
|
336 static Uns32T index_to_trackID(Uns32T lshID); // Convert lsh point index to audioDB trackID
|
mas01mc@292
|
337 static Uns32T index_to_trackPos(Uns32T lshID); // Convert lsh point index to audioDB trackPos (spos)
|
mas01mc@292
|
338 static Uns32T index_from_trackInfo(Uns32T, Uns32T); // Convert audioDB trackID and trackPos to an lsh point index
|
mas01mc@292
|
339 void initialize_exact_evalutation_queue();
|
mas01mc@292
|
340 void index_insert_exact_evaluation_queue(Uns32T trackID, Uns32T qpos, Uns32T spos);
|
mas01mc@292
|
341
|
mas01mc@292
|
342 // Web Services
|
mas01cr@0
|
343 void startServer();
|
mas01cr@0
|
344
|
mas01cr@0
|
345 };
|
mas01mc@17
|
346
|
mas01mc@292
|
347 #define O2_AUDIODB_INITIALIZERS \
|
mas01mc@292
|
348 dim(0), \
|
mas01mc@292
|
349 dbName(0), \
|
mas01mc@292
|
350 inFile(0), \
|
mas01mc@292
|
351 key(0), \
|
mas01mc@292
|
352 trackFileName(0), \
|
mas01mc@292
|
353 trackFile(0), \
|
mas01mc@292
|
354 command(0), \
|
mas01mc@292
|
355 output(0), \
|
mas01mc@292
|
356 timesFileName(0), \
|
mas01mc@292
|
357 timesFile(0), \
|
mas01mc@292
|
358 powerFileName(0), \
|
mas01mc@292
|
359 powerFile(0), \
|
mas01mc@292
|
360 powerfd(0), \
|
mas01mc@292
|
361 dbfid(0), \
|
mas01mc@292
|
362 lshfid(0), \
|
mas01mc@292
|
363 forWrite(false), \
|
mas01mc@292
|
364 infid(0), \
|
mas01mc@292
|
365 db(0), \
|
mas01mc@292
|
366 indata(0), \
|
mas01mc@292
|
367 dbH(0), \
|
mas01mc@292
|
368 rng(0), \
|
mas01mc@292
|
369 fileTable(0), \
|
mas01mc@292
|
370 trackTable(0), \
|
mas01mc@292
|
371 trackOffsetTable(0), \
|
mas01mc@292
|
372 dataBuf(0), \
|
mas01mc@292
|
373 l2normTable(0), \
|
mas01mc@292
|
374 timesTable(0), \
|
mas01mc@292
|
375 fileTableLength(0), \
|
mas01mc@292
|
376 trackTableLength(0), \
|
mas01mc@292
|
377 dataBufLength(0), \
|
mas01mc@292
|
378 timesTableLength(0), \
|
mas01mc@292
|
379 powerTableLength(0), \
|
mas01mc@292
|
380 l2normTableLength(0), \
|
mas01mc@292
|
381 verbosity(1), \
|
mas01mc@292
|
382 nsamples(2000), \
|
mas01mc@292
|
383 datasize(O2_DEFAULT_DATASIZE), \
|
mas01mc@292
|
384 ntracks(O2_DEFAULT_NTRACKS), \
|
mas01mc@292
|
385 datadim(O2_DEFAULT_DATADIM), \
|
mas01mc@292
|
386 queryType(O2_POINT_QUERY), \
|
mas01mc@292
|
387 pointNN(O2_DEFAULT_POINTNN), \
|
mas01mc@292
|
388 trackNN(O2_DEFAULT_TRACKNN), \
|
mas01mc@292
|
389 sequenceLength(16), \
|
mas01mc@292
|
390 sequenceHop(1), \
|
mas01mc@292
|
391 normalizedDistance(true), \
|
mas01mc@292
|
392 no_unit_norming(false), \
|
mas01mc@292
|
393 queryPoint(0), \
|
mas01mc@292
|
394 usingQueryPoint(0), \
|
mas01mc@292
|
395 usingTimes(0), \
|
mas01mc@292
|
396 usingPower(0), \
|
mas01mc@292
|
397 isClient(0), \
|
mas01mc@292
|
398 isServer(0), \
|
mas01mc@292
|
399 port(0), \
|
mas01mc@292
|
400 timesTol(0.1), \
|
mas01mc@292
|
401 radius(0), \
|
mas01mc@292
|
402 query_from_key(false), \
|
mas01mc@292
|
403 query_from_key_index(O2_ERR_KEYNOTFOUND), \
|
mas01mc@292
|
404 use_absolute_threshold(false), \
|
mas01mc@292
|
405 absolute_threshold(0.0), \
|
mas01mc@292
|
406 use_relative_threshold(false), \
|
mas01mc@292
|
407 relative_threshold(0.0), \
|
mas01mc@292
|
408 reporter(0), \
|
mas01mc@292
|
409 exact_evaluation_queue(0), \
|
mas01mc@292
|
410 lsh(0), \
|
mas01mc@292
|
411 lsh_in_core(false), \
|
mas01mc@292
|
412 lsh_use_u_functions(false), \
|
mas01mc@292
|
413 lsh_exact(false), \
|
mas01mc@292
|
414 lsh_param_k(0), \
|
mas01mc@292
|
415 lsh_param_m(0), \
|
mas01mc@292
|
416 lsh_param_N(0), \
|
mas01mc@292
|
417 lsh_param_b(0), \
|
mas01mc@292
|
418 lsh_param_ncols(0), \
|
mas01mc@292
|
419 vv(0)
|
mas01mc@292
|
420 #endif
|