Fixed a bug in isamd, failed to store a single key when its bits
[idzebra-moved-to-github.git] / isamc / isamd.c
index 191a51c..f06cda0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 1995-1998, Index Data.
  * See the file LICENSE for details.
- * $Id: isamd.c,v 1.16 1999-10-05 09:57:40 heikki Exp $ 
+ * $Id: isamd.c,v 1.21 2002-07-11 16:16:00 heikki Exp $ 
  *
  * Isamd - isam with diffs 
  * Programmed by: Heikki Levanto
@@ -17,7 +17,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include <log.h>
+#include <yaz/log.h>
 #include "../index/index.h"  /* isamd uses the internal structure of it_key */
 #include "isamd-p.h"
 
@@ -38,12 +38,13 @@ ISAMD_M isamd_getmethod (ISAMD_M me)
        {    64,    0 },
 #else
         {    32,    1 },
-        {    64,    1 },
        {   128,    1 },
-        {   512,    1 },
+       {   256,    1 },
+       {   512,    1 },
+        {  1024,    1 },
         {  2048,    1 },
-        {  8192,    1 },
-        { 32768,    0 },
+        {  4096,    1 },
+        {  8192,    0 },
 
 #endif
 #ifdef SKIPTHIS
@@ -179,6 +180,8 @@ ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method)
 
 int isamd_block_used (ISAMD is, int type)
 {
+    if ( type==-1) /* singleton */
+      return 0; 
     if (type < 0 || type >= is->no_files)
        return -1;
     return is->files[type].head.lastblock-1;
@@ -187,6 +190,8 @@ int isamd_block_used (ISAMD is, int type)
 int isamd_block_size (ISAMD is, int type)
 {
     ISAMD_filecat filecat = is->method->filecat;
+    if ( type==-1) /* singleton */
+      return 0; /* no bytes used */ 
     if (type < 0 || type >= is->no_files)
        return -1;
     return filecat[type].bsize;
@@ -246,14 +251,14 @@ int isamd_close (ISAMD is)
                   is->files[i].no_op_main,
                   is->files[i].no_op_diffonly);
         }
-        logf(LOG_LOG,"single   %8d", is->no_op_single);
-        logf(LOG_LOG,"new      %8d", is->no_op_new);
+        logf(LOG_LOG,"open single  %8d", is->no_op_single);
+        logf(LOG_LOG,"open new     %8d", is->no_op_new);
 
         logf(LOG_LOG, "new build   %8d", is->no_fbuilds);
         logf(LOG_LOG, "append      %8d", is->no_appds);
         logf(LOG_LOG, "  merges    %8d", is->no_merges);
         logf(LOG_LOG, "  singles   %8d", is->no_singles);
-        logf(LOG_LOG, "  non       %8d", is->no_non);
+        logf(LOG_LOG, "  no-ops    %8d", is->no_non);
 
         logf(LOG_LOG, "read blocks %8d", is->no_read);
         logf(LOG_LOG, "read keys:  %8d %8.1f k/bl", 
@@ -542,12 +547,13 @@ void isamd_pp_close (ISAMD_PP pp)
 
     (*is->method->code_stop)(ISAMD_DECODE, pp->decodeClientData);
     isamd_free_diffs(pp);  /* see merge-d.h */
-    xfree (pp->buf);
-    xfree (pp);
     if (is->method->debug > 5)
-       logf (LOG_LOG, "isamd_pp_close %p %d=%d:%d  sz=%d n=%d=%d:%d",
+       logf (LOG_LOG, "isamd_pp_close %p %d=%d:%d  sz=%d n=%d=%d:%d nk=%d",
              pp, isamd_addr(pp->pos, pp->cat), pp->cat, pp->pos, pp->size, 
-             pp->next, isamd_type(pp->next), isamd_block(pp->next) );
+             pp->next, isamd_type(pp->next), isamd_block(pp->next), 
+             pp->numKeys );
+    xfree (pp->buf);
+    xfree (pp);
 }
 
 
@@ -845,7 +851,24 @@ void isamd_pp_dump (ISAMD is, ISAMD_P ipos)
 
 /*
  * $Log: isamd.c,v $
- * Revision 1.16  1999-10-05 09:57:40  heikki
+ * Revision 1.21  2002-07-11 16:16:00  heikki
+ * Fixed a bug in isamd, failed to store a single key when its bits
+ * did not fit into a singleton.
+ *
+ * Revision 1.20  2002/06/19 10:29:18  adam
+ * align block sizes for isam sys. Better plot for test
+ *
+ * Revision 1.19  1999/11/30 13:48:04  adam
+ * Improved installation. Updated for inclusion of YAZ header files.
+ *
+ * Revision 1.18  1999/10/06 15:18:13  heikki
+ *
+ * Improving block sizes again
+ *
+ * Revision 1.17  1999/10/06 11:46:36  heikki
+ * mproved statistics on isam-d
+ *
+ * Revision 1.16  1999/10/05 09:57:40  heikki
  * Tuning the isam-d (and fixed a small "detail")
  *
  * Revision 1.15  1999/09/27 14:36:36  heikki
@@ -886,4 +909,4 @@ void isamd_pp_dump (ISAMD is, ISAMD_P ipos)
  * Copied from isamh, starting to change things...
  *
  *
- */
\ No newline at end of file
+ */