# HG changeset patch # User mas01mc # Date 1185444891 0 # Node ID 3d134836ea14486c5cbd43e7e9fb76f8b79dbc9b # Parent 3ab41608a474cee99a494798ff9faa356497a8aa munmap on batch insert, removed 'ignore' command line option -g diff -r 3ab41608a474 -r 3d134836ea14 audioDB.cpp --- a/audioDB.cpp Thu Jul 26 06:58:39 2007 +0000 +++ b/audioDB.cpp Thu Jul 26 10:14:51 2007 +0000 @@ -135,8 +135,7 @@ isClient(0), isServer(0), port(0), - timesTol(0.1), - ignoreCols(0){ + timesTol(0.1){ if(processArgs(argc, argv)<0){ printf("No command found.\n"); @@ -284,15 +283,6 @@ return 0; } - if(args_info.ignore_given){ - ignoreCols=args_info.ignore_arg; - if(ignoreCols<0 || ignoreCols>100){ - if(verbose) - cout << "warning: ignoring ignore which is out of range:" << ignoreCols << endl; - ignoreCols=0; - } - } - if(args_info.BATCHINSERT_given){ command=COM_BATCHINSERT; dbName=args_info.database_arg; @@ -700,18 +690,6 @@ } - // mmap the database file - if ((db = (char*) mmap(0, O2_DEFAULTDBSIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, dbfid, 0)) == (caddr_t) -1) - error("mmap error for creating database"); - - // Make some handy tables with correct types - fileTable= (char*)(db+fileTableOffset); - segTable = (unsigned*)(db+segTableOffset); - dataBuf = (double*)(db+dataoffset); - l2normTable = (double*)(db+l2normTableOffset); - timesTable = (double*)(db+timesTableOffset); - unsigned totalVectors=0; char *thisKey = new char[MAXSTR]; char *thisFile = new char[MAXSTR]; @@ -737,6 +715,18 @@ if (thisFile && fstat (infid,&statbuf) < 0) error("fstat error finding size of input"); + // mmap the database file + if ((db = (char*) mmap(0, O2_DEFAULTDBSIZE, PROT_READ | PROT_WRITE, + MAP_SHARED, dbfid, 0)) == (caddr_t) -1) + error("mmap error for creating database"); + + // Make some handy tables with correct types + fileTable= (char*)(db+fileTableOffset); + segTable = (unsigned*)(db+segTableOffset); + dataBuf = (double*)(db+dataoffset); + l2normTable = (double*)(db+l2normTableOffset); + timesTable = (double*)(db+timesTableOffset); + // Check that there is room for at least 1 more file if((char*)timesTable<((char*)dataBuf+(dbH->length+statbuf.st_size-sizeof(int)))) error("No more room in database","insert failed: reason database is full."); @@ -825,6 +815,7 @@ // CLEAN UP munmap(indata,statbuf.st_size); close(infid); + munmap(db,O2_DEFAULTDBSIZE); }while(!filesIn->eof()); if(verbosity) diff -r 3ab41608a474 -r 3d134836ea14 gengetopt.in --- a/gengetopt.in Thu Jul 26 06:58:39 2007 +0000 +++ b/gengetopt.in Thu Jul 26 10:14:51 2007 +0000 @@ -18,7 +18,6 @@ # -K --keyList keyList.txt # -T --timePointsList.txt # -B --BATCHINSERT dbName -# -g --ignore n feature columns # # -Q --QUERY {point|segment|sequence} # -p --qpoint - ordinal position of query vector in feature input file @@ -49,7 +48,6 @@ option "L2NORM" L "unit norm vectors and norm all future inserts." dependon="database" optional section "Database Insertion" sectiondesc="The following commands insert feature files, with optional keys and timestamps.\n" option "INSERT" I "add feature vectors to an existing database." dependon="features" optional -option "ignore" g "ignore n columns" int typestr="num columns" default="0" dependon="features" optional hidden option "UPDATE" U "replace inserted vectors associated with key with new input vectors." dependon="features" dependon="key" dependon="database" optional hidden option "features" f "binary series of vectors file {int sz:ieee double[][sz]:eof}." string typestr="filename" dependon="database" optional option "times" t "list of time points (ascii) for feature vectors." string typestr="filename" dependon="features" optional