Commit files use separate meta file area.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 1 Dec 1995 16:24:28 +0000 (16:24 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 1 Dec 1995 16:24:28 +0000 (16:24 +0000)
bfile/bfile.c
bfile/cfile.c
bfile/cfile.h
bfile/commit.c
include/bfile.h
index/main.c

index 256fe62..46c4d76 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: bfile.c,v $
- * Revision 1.14  1995-12-01 11:37:21  adam
+ * Revision 1.15  1995-12-01 16:24:28  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.14  1995/12/01  11:37:21  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.13  1995/11/30  17:00:49  adam
  */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
+#include <assert.h>
 
 #include <alexutil.h>
 #include <bfile.h>
@@ -60,7 +61,14 @@ static MFile_area commit_area = NULL;
 void bf_cache (void)
 {
     if (!commit_area)
-        commit_area = mf_init ("commit");
+        if (res_get (common_resource, "commit"))
+            commit_area = mf_init ("commit");
+        else
+        {
+            logf (LOG_FATAL, "Commit area must be defined if commit"
+                  "is to be enabled");
+            exit (1);
+        }
 }
 
 int bf_close (BFile bf)
@@ -82,8 +90,9 @@ BFile bf_open (const char *name, int block_size, int wflag)
         int first_time;
 
         logf (LOG_LOG, "cf,mf_open %s", name);
-        tmp->mf = mf_open (commit_area, name, block_size, 0);
-        tmp->cf = cf_open (tmp->mf, name, block_size, wflag, &first_time);
+        tmp->mf = mf_open (0, name, block_size, 0);
+        tmp->cf = cf_open (tmp->mf, commit_area, name, block_size,
+                           wflag, &first_time);
 
         if (first_time)
         {
@@ -131,8 +140,7 @@ void bf_commit (void)
     CFile cf;
     int first_time;
 
-    if (!commit_area)
-        commit_area = mf_init ("commit");
+    assert (commit_area);
     if (!(inf = fopen ("cache", "r")))
     {
         logf (LOG_FATAL|LOG_ERRNO, "cannot open commit %s", "cache");
@@ -140,8 +148,8 @@ void bf_commit (void)
     }
     while (fscanf (inf, "%s %d", path, &block_size) == 2)
     {
-        mf = mf_open (commit_area, path, block_size, 1);
-        cf = cf_open (mf, path, block_size, 0, &first_time);
+        mf = mf_open (0, path, block_size, 1);
+        cf = cf_open (mf, commit_area, path, block_size, 0, &first_time);
 
         cf_commit (cf);
 
index 3a69a58..cfcd6da 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: cfile.c,v $
- * Revision 1.3  1995-12-01 11:37:22  adam
+ * Revision 1.4  1995-12-01 16:24:28  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.3  1995/12/01  11:37:22  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.2  1995/11/30  17:00:49  adam
@@ -58,8 +61,8 @@ static int read_head (CFile cf)
 }
 
 
-CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
-               int *firstp)
+CFile cf_open (MFile mf, MFile_area area, const char *fname,
+               int block_size, int wflag, int *firstp)
 {
     char path[256];
     int i;
@@ -68,13 +71,13 @@ CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
    
     cf->rmf = mf; 
     sprintf (path, "%s.b", fname);
-    if (!(cf->block_mf = mf_open (0, path, block_size, wflag)))
+    if (!(cf->block_mf = mf_open (area, path, block_size, wflag)))
     {
         logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", path);
         exit (1);
     }
     sprintf (path, "%s.h", fname);
-    if (!(cf->hash_mf = mf_open (0, path, HASH_BSIZE, wflag)))
+    if (!(cf->hash_mf = mf_open (area, path, HASH_BSIZE, wflag)))
     {
         logf (LOG_FATAL|LOG_ERRNO, "Failed to open %s", path);
         exit (1);
@@ -111,7 +114,7 @@ CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
         cf->parray[i] = NULL;
     cf->bucket_lru_front = cf->bucket_lru_back = NULL;
     cf->bucket_in_memory = 0;
-    cf->max_bucket_in_memory = 200;
+    cf->max_bucket_in_memory = 400;
     cf->dirty = 0;
     cf->iobuf = xmalloc (cf->head.block_size);
     memset (cf->iobuf, 0, cf->head.block_size);
index 2f8c3bb..70ca0b3 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: cfile.h,v $
- * Revision 1.2  1995-12-01 11:37:23  adam
+ * Revision 1.3  1995-12-01 16:24:29  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.2  1995/12/01  11:37:23  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.1  1995/11/30  08:33:12  adam
@@ -52,8 +55,8 @@ typedef struct CFile_struct
 } *CFile;
 
 int cf_close (CFile cf);
-CFile cf_open (MFile mf, const char *fname, int block_size, int wflag,
-               int *firstp);
+CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
+               int wflag, int *firstp);
 int cf_read (CFile cf, int no, int offset, int num, void *buf);
 int cf_write (CFile cf, int no, int offset, int num, const void *buf);
 void cf_commit (CFile cf);
index cbebe0e..777b7ae 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: commit.c,v $
- * Revision 1.2  1995-12-01 11:37:24  adam
+ * Revision 1.3  1995-12-01 16:24:29  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.2  1995/12/01  11:37:24  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.1  1995/11/30  08:33:13  adam
@@ -21,7 +24,7 @@
 
 void cf_commit (CFile cf)
 {
-    int i, r, bucket_no;
+    int i, bucket_no;
     int hash_bytes;
     struct CFile_ph_bucket *p;
 
index ae8d2f4..f22d7fa 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: bfile.h,v $
- * Revision 1.9  1995-12-01 11:37:46  adam
+ * Revision 1.10  1995-12-01 16:24:33  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.9  1995/12/01  11:37:46  adam
  * Cached/commit files implemented as meta-files.
  *
  * Revision 1.8  1995/11/30  08:33:29  adam
@@ -45,7 +48,7 @@ int bf_close (BFile);
 BFile bf_open (const char *name, int block_size, int wflag);
 int bf_read (BFile bf, int no, int offset, int num, void *buf);
 int bf_write (BFile bf, int no, int offset, int num, const void *buf);
-void bf_cache ();
-void bf_commit ();
+void bf_cache (void);
+void bf_commit (void);
 
 #endif
index c81c149..17fdbb4 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: main.c,v $
- * Revision 1.24  1995-11-30 17:01:38  adam
+ * Revision 1.25  1995-12-01 16:24:39  adam
+ * Commit files use separate meta file area.
+ *
+ * Revision 1.24  1995/11/30  17:01:38  adam
  * New setting commitCache: points to commit directories/files.
  * New command commit: commits at the end of a zebraidx run.
  *
@@ -144,6 +147,7 @@ int main (int argc, char **argv)
             {
                 if (!common_resource)
                 {
+                    const char *rval;
                     common_resource = res_open (configName ?
                                                 configName : FNAME_CONFIG);
                     if (!common_resource)
@@ -153,7 +157,9 @@ int main (int argc, char **argv)
                         exit (1);
                     }
                     data1_tabpath = res_get (common_resource, "profilePath");
-                    bf_cache (res_get (common_resource, "commitCache"));
+                    rval = res_get (common_resource, "commitEnable");
+                    if (rval && atoi(rval))
+                        bf_cache ();
                 }
                 if (!strcmp (arg, "update"))
                     cmd = 'u';
@@ -223,7 +229,7 @@ int main (int argc, char **argv)
     if (commit_at_end)
     {
         logf (LOG_LOG, "commiting");
-        bf_commit (res_get (common_resource, "commitCache"));
+        bf_commit ();
     }
     exit (0);
 }