Mercurial > hg > audiodb
comparison audioDB.cpp @ 140:ddd83d773d6c
Smaller databases
Adjust the sizes of the various tables (file, track, times, l2norm)
linearly with the overall size of the database.
Now it makes sense to allow 50Mb databases, as the various fixed-size
tables shrink, rather than being fixed to somewhere over that size...
author | mas01cr |
---|---|
date | Mon, 29 Oct 2007 11:47:42 +0000 |
parents | a5d5a55a412d |
children | c74048e9b569 5fa52830e532 |
comparison
equal
deleted
inserted
replaced
139:7c7072a8626a | 140:ddd83d773d6c |
---|---|
151 verbosity=1; | 151 verbosity=1; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 if(args_info.size_given) { | 155 if(args_info.size_given) { |
156 if (args_info.size_arg < 250 || args_info.size_arg > 4000) { | 156 if (args_info.size_arg < 50 || args_info.size_arg > 4000) { |
157 error("Size out of range", ""); | 157 error("Size out of range", ""); |
158 } | 158 } |
159 size = args_info.size_arg * 1000000; | 159 size = args_info.size_arg * 1000000; |
160 } | 160 } |
161 | 161 |
396 error("mmap error for creating database", "", "mmap"); | 396 error("mmap error for creating database", "", "mmap"); |
397 | 397 |
398 dbH = new dbTableHeaderT(); | 398 dbH = new dbTableHeaderT(); |
399 assert(dbH); | 399 assert(dbH); |
400 | 400 |
401 unsigned int maxfiles = (unsigned int) rint((double) O2_MAXFILES * (double) size / (double) O2_DEFAULTDBSIZE); | |
402 | |
401 // Initialize header | 403 // Initialize header |
402 dbH->magic = O2_MAGIC; | 404 dbH->magic = O2_MAGIC; |
403 dbH->version = O2_FORMAT_VERSION; | 405 dbH->version = O2_FORMAT_VERSION; |
404 dbH->numFiles = 0; | 406 dbH->numFiles = 0; |
405 dbH->dim = 0; | 407 dbH->dim = 0; |
406 dbH->flags = 0; | 408 dbH->flags = 0; |
407 dbH->length = 0; | 409 dbH->length = 0; |
408 dbH->fileTableOffset = ALIGN_UP(O2_HEADERSIZE, 8); | 410 dbH->fileTableOffset = ALIGN_UP(O2_HEADERSIZE, 8); |
409 dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*O2_MAXFILES, 8); | 411 dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*maxfiles, 8); |
410 dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*O2_MAXFILES, 8); | 412 dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*maxfiles, 8); |
411 dbH->l2normTableOffset = ALIGN_DOWN(size - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); | 413 dbH->l2normTableOffset = ALIGN_DOWN(size - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); |
412 dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); | 414 dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); |
413 dbH->dbSize = size; | 415 dbH->dbSize = size; |
414 | 416 |
415 memcpy (db, dbH, O2_HEADERSIZE); | 417 memcpy (db, dbH, O2_HEADERSIZE); |
416 if(verbosity) { | 418 if(verbosity) { |
417 cerr << COM_CREATE << " " << dbName << endl; | 419 cerr << COM_CREATE << " " << dbName << endl; |