Mercurial > hg > audiodb
comparison insert.cpp @ 401:a8a5f2ca5380 api-inversion
Invert audioDB::l2norm / audiodb_l2norm()
We now have some functions that shouldn't be exported to the user of the
library, but are used in more than one source file; case in point:
audiodb_sync_header(). Make a new audioDB-internals.h file for them,
and while we're at it put the scary mmap()-related macros in there too.
We can't delete audioDB::unitNormAndInsertL2() quite yet, because it's
used in insertion too, but we can delete the non-append branches.
That's not very much code to lose, but every little helps.
author | mas01cr |
---|---|
date | Wed, 03 Dec 2008 14:53:20 +0000 |
parents | 7d6dd067d12e |
children | 1fb8bee777e5 |
comparison
equal
deleted
inserted
replaced
400:8c7453fb5bd9 | 401:a8a5f2ca5380 |
---|---|
100 | 100 |
101 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); | 101 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); |
102 | 102 |
103 // Norm the vectors on input if the database is already L2 normed | 103 // Norm the vectors on input if the database is already L2 normed |
104 if(dbH->flags & O2_FLAG_L2NORM) | 104 if(dbH->flags & O2_FLAG_L2NORM) |
105 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors, 1); // append | 105 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors); |
106 | 106 |
107 // Report status | 107 // Report status |
108 status(dbName); | 108 status(dbName); |
109 VERB_LOG(0, "%s %s %u vectors %jd bytes.\n", COM_INSERT, dbName, numVectors, (intmax_t) (statbuf.st_size - sizeof(int))); | 109 VERB_LOG(0, "%s %s %u vectors %jd bytes.\n", COM_INSERT, dbName, numVectors, (intmax_t) (statbuf.st_size - sizeof(int))); |
110 | 110 |
317 | 317 |
318 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); | 318 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); |
319 | 319 |
320 // Norm the vectors on input if the database is already L2 normed | 320 // Norm the vectors on input if the database is already L2 normed |
321 if(dbH->flags & O2_FLAG_L2NORM) | 321 if(dbH->flags & O2_FLAG_L2NORM) |
322 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors, 1); // append | 322 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors); |
323 | 323 |
324 totalVectors+=numVectors; | 324 totalVectors+=numVectors; |
325 | 325 |
326 // Copy the header back to the database | 326 // Copy the header back to the database |
327 memcpy (db, dbH, sizeof(dbTableHeaderT)); | 327 memcpy (db, dbH, sizeof(dbTableHeaderT)); |