# HG changeset patch # User mas01cr # Date 1193658462 0 # Node ID ddd83d773d6c955d42be92e50cc80f37b90eeff0 # Parent 7c7072a8626ac3e00d171ab78c177a0a0b7e8f7f 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... diff -r 7c7072a8626a -r ddd83d773d6c audioDB.cpp --- a/audioDB.cpp Mon Oct 29 11:45:50 2007 +0000 +++ b/audioDB.cpp Mon Oct 29 11:47:42 2007 +0000 @@ -153,7 +153,7 @@ } if(args_info.size_given) { - if (args_info.size_arg < 250 || args_info.size_arg > 4000) { + if (args_info.size_arg < 50 || args_info.size_arg > 4000) { error("Size out of range", ""); } size = args_info.size_arg * 1000000; @@ -398,6 +398,8 @@ dbH = new dbTableHeaderT(); assert(dbH); + unsigned int maxfiles = (unsigned int) rint((double) O2_MAXFILES * (double) size / (double) O2_DEFAULTDBSIZE); + // Initialize header dbH->magic = O2_MAGIC; dbH->version = O2_FORMAT_VERSION; @@ -406,10 +408,10 @@ dbH->flags = 0; dbH->length = 0; dbH->fileTableOffset = ALIGN_UP(O2_HEADERSIZE, 8); - dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*O2_MAXFILES, 8); - dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*O2_MAXFILES, 8); - dbH->l2normTableOffset = ALIGN_DOWN(size - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); - dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); + dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*maxfiles, 8); + dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*maxfiles, 8); + dbH->l2normTableOffset = ALIGN_DOWN(size - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); + dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); dbH->dbSize = size; memcpy (db, dbH, O2_HEADERSIZE);