Mercurial > hg > audiodb
comparison audioDB.cpp @ 192:5f3d260ba71d no-big-mmap
Create and status of huge databases works.
dump also works, but is as yet untested beyond the 4GB limit.
author | mas01cr |
---|---|
date | Mon, 19 Nov 2007 18:37:12 +0000 |
parents | b7400fabbb94 |
children |
comparison
equal
deleted
inserted
replaced
191:b7400fabbb94 | 192:5f3d260ba71d |
---|---|
162 verbosity=1; | 162 verbosity=1; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 if(args_info.size_given) { | 166 if(args_info.size_given) { |
167 if (args_info.size_arg < 50 || args_info.size_arg > 4000) { | 167 if (args_info.size_arg < 50 || args_info.size_arg > 32000) { |
168 error("Size out of range", ""); | 168 error("Size out of range", ""); |
169 } | 169 } |
170 size = args_info.size_arg * 1000000; | 170 size = (off_t) args_info.size_arg * 1000000; |
171 } | 171 } |
172 | 172 |
173 if(args_info.radius_given){ | 173 if(args_info.radius_given){ |
174 radius=args_info.radius_arg; | 174 radius=args_info.radius_arg; |
175 if(radius<=0 || radius>1000000000){ | 175 if(radius<=0 || radius>1000000000){ |
601 return; | 601 return; |
602 } | 602 } |
603 | 603 |
604 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, key, strlen(key)); | 604 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, key, strlen(key)); |
605 | 605 |
606 unsigned insertoffset = dbH->length;// Store current state | 606 off_t insertoffset = dbH->length;// Store current state |
607 | 607 |
608 // Check times status and insert times from file | 608 // Check times status and insert times from file |
609 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); | 609 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); |
610 double* timesdata=timesTable+timesoffset; | 610 double* timesdata=timesTable+timesoffset; |
611 | 611 |
769 if(timesFile->eof()) | 769 if(timesFile->eof()) |
770 error("not enough timestamp files in timesList"); | 770 error("not enough timestamp files in timesList"); |
771 thisTimesFile=new ifstream(thisTimesFileName,ios::in); | 771 thisTimesFile=new ifstream(thisTimesFileName,ios::in); |
772 if(!thisTimesFile->is_open()) | 772 if(!thisTimesFile->is_open()) |
773 error("Cannot open timestamp file",thisTimesFileName); | 773 error("Cannot open timestamp file",thisTimesFileName); |
774 unsigned insertoffset=dbH->length; | 774 off_t insertoffset=dbH->length; |
775 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); | 775 unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double)); |
776 double* timesdata=timesTable+timesoffset; | 776 double* timesdata=timesTable+timesoffset; |
777 if(timesoffset + numVectors > timesTableLength) { | 777 if(timesoffset + numVectors > timesTableLength) { |
778 error("out of space for times", key); | 778 error("out of space for times", key); |
779 } | 779 } |
782 delete thisTimesFile; | 782 delete thisTimesFile; |
783 } | 783 } |
784 | 784 |
785 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, thisKey, strlen(thisKey)); | 785 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, thisKey, strlen(thisKey)); |
786 | 786 |
787 unsigned insertoffset = dbH->length;// Store current state | 787 off_t insertoffset = dbH->length;// Store current state |
788 | 788 |
789 // Increment file count | 789 // Increment file count |
790 dbH->numFiles++; | 790 dbH->numFiles++; |
791 | 791 |
792 // Update Header information | 792 // Update Header information |
1018 #\n\ | 1018 #\n\ |
1019 # usage: AUDIODB=/path/to/audioDB sh ./restore.sh <newdb>\n\ | 1019 # usage: AUDIODB=/path/to/audioDB sh ./restore.sh <newdb>\n\ |
1020 \n\ | 1020 \n\ |
1021 if [ -z \"${AUDIODB}\" ]; then echo set AUDIODB variable; exit 1; fi\n\ | 1021 if [ -z \"${AUDIODB}\" ]; then echo set AUDIODB variable; exit 1; fi\n\ |
1022 if [ -z \"$1\" ]; then echo usage: $0 newdb; exit 1; fi\n\n\ | 1022 if [ -z \"$1\" ]; then echo usage: $0 newdb; exit 1; fi\n\n\ |
1023 \"${AUDIODB}\" -d \"$1\" -N --size=%d\n", dbH->dbSize / 1000000); | 1023 \"${AUDIODB}\" -d \"$1\" -N --size=%d\n", (int) (dbH->dbSize / 1000000)); |
1024 if(dbH->flags & O2_FLAG_L2NORM) { | 1024 if(dbH->flags & O2_FLAG_L2NORM) { |
1025 fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -L\n"); | 1025 fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -L\n"); |
1026 } | 1026 } |
1027 fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -B -F featureList.txt -K keyList.txt"); | 1027 fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -B -F featureList.txt -K keyList.txt"); |
1028 if(times) { | 1028 if(times) { |
1047 | 1047 |
1048 void audioDB::l2norm(const char* dbName) { | 1048 void audioDB::l2norm(const char* dbName) { |
1049 forWrite = true; | 1049 forWrite = true; |
1050 initTables(dbName, 0); | 1050 initTables(dbName, 0); |
1051 if(dbH->length>0){ | 1051 if(dbH->length>0){ |
1052 /* FIXME: should probably be uint64_t */ | |
1052 unsigned numVectors = dbH->length/(sizeof(double)*dbH->dim); | 1053 unsigned numVectors = dbH->length/(sizeof(double)*dbH->dim); |
1053 CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); | 1054 CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); |
1054 unitNormAndInsertL2(dataBuf, dbH->dim, numVectors, 0); // No append | 1055 unitNormAndInsertL2(dataBuf, dbH->dim, numVectors, 0); // No append |
1055 } | 1056 } |
1056 // Update database flags | 1057 // Update database flags |