changeset 11:3d134836ea14

munmap on batch insert, removed 'ignore' command line option -g
author mas01mc
date Thu, 26 Jul 2007 10:14:51 +0000
parents 3ab41608a474
children a206d3e91f8b
files audioDB.cpp gengetopt.in
diffstat 2 files changed, 14 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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