Mercurial > hg > audiodb
comparison audioDB.cpp @ 191:b7400fabbb94 no-big-mmap
mmap dataBuf for the remaining cases
* -L after insertion;
* pointQuery;
We'll fix these later.
author | mas01cr |
---|---|
date | Mon, 19 Nov 2007 17:19:46 +0000 |
parents | f56c530750da |
children | 5f3d260ba71d |
comparison
equal
deleted
inserted
replaced
190:f56c530750da | 191:b7400fabbb94 |
---|---|
491 timesTableLength = ALIGN_PAGE_UP(dbH->length / dbH->dim); | 491 timesTableLength = ALIGN_PAGE_UP(dbH->length / dbH->dim); |
492 l2normTableLength = ALIGN_PAGE_UP(dbH->length / dbH->dim); | 492 l2normTableLength = ALIGN_PAGE_UP(dbH->length / dbH->dim); |
493 } | 493 } |
494 CHECKED_MMAP(char *, fileTable, dbH->fileTableOffset, fileTableLength); | 494 CHECKED_MMAP(char *, fileTable, dbH->fileTableOffset, fileTableLength); |
495 CHECKED_MMAP(unsigned *, trackTable, dbH->trackTableOffset, trackTableLength); | 495 CHECKED_MMAP(unsigned *, trackTable, dbH->trackTableOffset, trackTableLength); |
496 CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); | 496 /* |
497 * No more mmap() for dataBuf | |
498 * | |
499 * FIXME: Actually we do do the mmap() in the two cases where it's | |
500 * still "needed": in pointQuery and in l2norm if dbH->length is | |
501 * non-zero. Removing those cases too (and deleting the dataBuf | |
502 * variable completely) would be cool. -- CSR, 2007-11-19 | |
503 * | |
504 * CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); | |
505 */ | |
497 CHECKED_MMAP(double *, timesTable, dbH->timesTableOffset, timesTableLength); | 506 CHECKED_MMAP(double *, timesTable, dbH->timesTableOffset, timesTableLength); |
498 CHECKED_MMAP(double *, l2normTable, dbH->l2normTableOffset, l2normTableLength); | 507 CHECKED_MMAP(double *, l2normTable, dbH->l2normTableOffset, l2normTableLength); |
499 } | 508 } |
500 } | 509 } |
501 | 510 |
1039 void audioDB::l2norm(const char* dbName) { | 1048 void audioDB::l2norm(const char* dbName) { |
1040 forWrite = true; | 1049 forWrite = true; |
1041 initTables(dbName, 0); | 1050 initTables(dbName, 0); |
1042 if(dbH->length>0){ | 1051 if(dbH->length>0){ |
1043 unsigned numVectors = dbH->length/(sizeof(double)*dbH->dim); | 1052 unsigned numVectors = dbH->length/(sizeof(double)*dbH->dim); |
1053 CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); | |
1044 unitNormAndInsertL2(dataBuf, dbH->dim, numVectors, 0); // No append | 1054 unitNormAndInsertL2(dataBuf, dbH->dim, numVectors, 0); // No append |
1045 } | 1055 } |
1046 // Update database flags | 1056 // Update database flags |
1047 dbH->flags = dbH->flags|O2_FLAG_L2NORM; | 1057 dbH->flags = dbH->flags|O2_FLAG_L2NORM; |
1048 memcpy (db, dbH, O2_HEADERSIZE); | 1058 memcpy (db, dbH, O2_HEADERSIZE); |
1085 // For each input vector, find the closest pointNN matching output vectors and report | 1095 // For each input vector, find the closest pointNN matching output vectors and report |
1086 // we use stdout in this stub version | 1096 // we use stdout in this stub version |
1087 unsigned numVectors = (statbuf.st_size-sizeof(int))/(sizeof(double)*dbH->dim); | 1097 unsigned numVectors = (statbuf.st_size-sizeof(int))/(sizeof(double)*dbH->dim); |
1088 | 1098 |
1089 double* query = (double*)(indata+sizeof(int)); | 1099 double* query = (double*)(indata+sizeof(int)); |
1100 CHECKED_MMAP(double *, dataBuf, dbH->dataOffset, dataBufLength); | |
1090 double* data = dataBuf; | 1101 double* data = dataBuf; |
1091 double* queryCopy = 0; | 1102 double* queryCopy = 0; |
1092 | 1103 |
1093 if( dbH->flags & O2_FLAG_L2NORM ){ | 1104 if( dbH->flags & O2_FLAG_L2NORM ){ |
1094 // Make a copy of the query | 1105 // Make a copy of the query |