comparison audioDB.h @ 279:dee55886eca0 sampling

make the RNG a part of the audioDB object. Easier to deal with memory discipline and initialization (though note the FIXME comment in audioDB::initTables()). Also initialize the RNG from the current time. A mature implementation would use a proper source of entropy...
author mas01cr
date Wed, 02 Jul 2008 13:53:23 +0000
parents d9dba57becd4
children
comparison
equal deleted inserted replaced
278:d9dba57becd4 279:dee55886eca0
157 int infid; 157 int infid;
158 char* db; 158 char* db;
159 char* indata; 159 char* indata;
160 struct stat statbuf; 160 struct stat statbuf;
161 dbTableHeaderPtr dbH; 161 dbTableHeaderPtr dbH;
162
163 gsl_rng *rng;
162 164
163 char *fileTable; 165 char *fileTable;
164 unsigned* trackTable; 166 unsigned* trackTable;
165 double* dataBuf; 167 double* dataBuf;
166 double* inBuf; 168 double* inBuf;
222 void read_data(int track, double **data_buffer_p, size_t *data_buffer_size_p); 224 void read_data(int track, double **data_buffer_p, size_t *data_buffer_size_p);
223 void set_up_query(double **qp, double **vqp, double **qnp, double **vqnp, double **qpp, double **vqpp, double *mqdp, unsigned int *nvp); 225 void set_up_query(double **qp, double **vqp, double **qnp, double **vqnp, double **qpp, double **vqpp, double *mqdp, unsigned int *nvp);
224 void set_up_db(double **snp, double **vsnp, double **spp, double **vspp, double **mddp, unsigned int *dvp); 226 void set_up_db(double **snp, double **vsnp, double **spp, double **vspp, double **mddp, unsigned int *dvp);
225 void query_loop(const char* dbName, const char* inFile, Reporter *reporter); 227 void query_loop(const char* dbName, const char* inFile, Reporter *reporter);
226 228
229 void initRNG();
227 void initDBHeader(const char *dbName); 230 void initDBHeader(const char *dbName);
228 void initInputFile(const char *inFile); 231 void initInputFile(const char *inFile);
229 void initTables(const char* dbName, const char* inFile); 232 void initTables(const char* dbName, const char* inFile);
230 void unitNorm(double* X, unsigned d, unsigned n, double* qNorm); 233 void unitNorm(double* X, unsigned d, unsigned n, double* qNorm);
231 void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append); 234 void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append);
249 void insert_data_vectors(off_t offset, void *buffer, size_t size); 252 void insert_data_vectors(off_t offset, void *buffer, size_t size);
250 void insert(const char* dbName, const char* inFile); 253 void insert(const char* dbName, const char* inFile);
251 void batchinsert(const char* dbName, const char* inFile); 254 void batchinsert(const char* dbName, const char* inFile);
252 void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0); 255 void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);
253 void status(const char* dbName, adb__statusResponse *adbStatusResponse=0); 256 void status(const char* dbName, adb__statusResponse *adbStatusResponse=0);
254 unsigned random_track(unsigned *propTable, unsigned total, gsl_rng *); 257 unsigned random_track(unsigned *propTable, unsigned total);
255 void sample(const char *dbName); 258 void sample(const char *dbName);
256 void ws_status(const char*dbName, char* hostport); 259 void ws_status(const char*dbName, char* hostport);
257 void ws_query(const char*dbName, const char *trackKey, const char* hostport); 260 void ws_query(const char*dbName, const char *trackKey, const char* hostport);
258 void l2norm(const char* dbName); 261 void l2norm(const char* dbName);
259 void power_flag(const char *dbName); 262 void power_flag(const char *dbName);
283 forWrite(false), \ 286 forWrite(false), \
284 infid(0), \ 287 infid(0), \
285 db(0), \ 288 db(0), \
286 indata(0), \ 289 indata(0), \
287 dbH(0), \ 290 dbH(0), \
291 rng(0), \
288 fileTable(0), \ 292 fileTable(0), \
289 trackTable(0), \ 293 trackTable(0), \
290 dataBuf(0), \ 294 dataBuf(0), \
291 l2normTable(0), \ 295 l2normTable(0), \
292 timesTable(0), \ 296 timesTable(0), \