comparison insert.cpp @ 256:4dcb09f5fe85

Commit patch deprecating the --size argument, replacing it with --ntracks, --datadims and --datasize. These names are not ideal, but will serve for now.
author mas01cr
date Wed, 16 Apr 2008 09:59:43 +0000
parents a6c9a1c68646
children 34ce7f7a177d
comparison
equal deleted inserted replaced
254:fe922b9d87f8 256:4dcb09f5fe85
2 2
3 bool audioDB::enough_per_file_space_free() { 3 bool audioDB::enough_per_file_space_free() {
4 unsigned int fmaxfiles, tmaxfiles; 4 unsigned int fmaxfiles, tmaxfiles;
5 unsigned int maxfiles; 5 unsigned int maxfiles;
6 6
7 fmaxfiles = fileTableLength / O2_FILETABLESIZE; 7 fmaxfiles = fileTableLength / O2_FILETABLE_ENTRY_SIZE;
8 tmaxfiles = trackTableLength / O2_TRACKTABLESIZE; 8 tmaxfiles = trackTableLength / O2_TRACKTABLE_ENTRY_SIZE;
9 maxfiles = fmaxfiles > tmaxfiles ? tmaxfiles : fmaxfiles; 9 maxfiles = fmaxfiles > tmaxfiles ? tmaxfiles : fmaxfiles;
10 return(dbH->numFiles < maxfiles); 10 return(dbH->numFiles < maxfiles);
11 } 11 }
12 12
13 bool audioDB::enough_data_space_free(off_t size) { 13 bool audioDB::enough_data_space_free(off_t size) {
40 if(!key) 40 if(!key)
41 key=inFile; 41 key=inFile;
42 // Linear scan of filenames check for pre-existing feature 42 // Linear scan of filenames check for pre-existing feature
43 unsigned alreadyInserted=0; 43 unsigned alreadyInserted=0;
44 for(unsigned k=0; k<dbH->numFiles; k++) 44 for(unsigned k=0; k<dbH->numFiles; k++)
45 if(strncmp(fileTable + k*O2_FILETABLESIZE, key, strlen(key)+1)==0){ 45 if(strncmp(fileTable + k*O2_FILETABLE_ENTRY_SIZE, key, strlen(key)+1)==0){
46 alreadyInserted=1; 46 alreadyInserted=1;
47 break; 47 break;
48 } 48 }
49 49
50 if(alreadyInserted) { 50 if(alreadyInserted) {
62 munmap(db,dbH->dbSize); 62 munmap(db,dbH->dbSize);
63 close(infid); 63 close(infid);
64 return; 64 return;
65 } 65 }
66 66
67 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, key, strlen(key)); 67 strncpy(fileTable + dbH->numFiles*O2_FILETABLE_ENTRY_SIZE, key, strlen(key));
68 68
69 off_t insertoffset = dbH->length;// Store current state 69 off_t insertoffset = dbH->length;// Store current state
70 70
71 // Check times status and insert times from file 71 // Check times status and insert times from file
72 unsigned indexoffset = insertoffset/(dbH->dim*sizeof(double)); 72 unsigned indexoffset = insertoffset/(dbH->dim*sizeof(double));
234 234
235 // Linear scan of filenames check for pre-existing feature 235 // Linear scan of filenames check for pre-existing feature
236 unsigned alreadyInserted=0; 236 unsigned alreadyInserted=0;
237 237
238 for(unsigned k=0; k<dbH->numFiles; k++) 238 for(unsigned k=0; k<dbH->numFiles; k++)
239 if(strncmp(fileTable + k*O2_FILETABLESIZE, thisKey, strlen(thisKey)+1)==0){ 239 if(strncmp(fileTable + k*O2_FILETABLE_ENTRY_SIZE, thisKey, strlen(thisKey)+1)==0){
240 alreadyInserted=1; 240 alreadyInserted=1;
241 break; 241 break;
242 } 242 }
243 243
244 if(alreadyInserted) { 244 if(alreadyInserted) {
283 insertPowerData(numVectors, thispowerfd, powerdata); 283 insertPowerData(numVectors, thispowerfd, powerdata);
284 if (0 < thispowerfd) { 284 if (0 < thispowerfd) {
285 close(thispowerfd); 285 close(thispowerfd);
286 } 286 }
287 } 287 }
288 strncpy(fileTable + dbH->numFiles*O2_FILETABLESIZE, thisKey, strlen(thisKey)); 288 strncpy(fileTable + dbH->numFiles*O2_FILETABLE_ENTRY_SIZE, thisKey, strlen(thisKey));
289 289
290 off_t insertoffset = dbH->length;// Store current state 290 off_t insertoffset = dbH->length;// Store current state
291 291
292 // Increment file count 292 // Increment file count
293 dbH->numFiles++; 293 dbH->numFiles++;