a3
[idzebra-moved-to-github.git] / isam / isam.c
index 42d7acd..248a944 100644 (file)
@@ -4,7 +4,26 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: isam.c,v $
- * Revision 1.11  1995-09-04 12:33:46  adam
+ * Revision 1.17  1995-12-06 15:48:44  quinn
+ * Fixed update-problem.
+ *
+ * Revision 1.16  1995/12/06  14:48:26  quinn
+ * Fixed some strange bugs.
+ *
+ * Revision 1.15  1995/12/06  09:59:45  quinn
+ * Fixed memory-consumption bug in memory.c
+ * Added more blocksizes to the default ISAM configuration.
+ *
+ * Revision 1.14  1995/11/24  17:26:19  quinn
+ * Mostly about making some ISAM stuff in the config file optional.
+ *
+ * Revision 1.13  1995/10/17  18:03:15  adam
+ * Commented out qsort in is_merge.
+ *
+ * Revision 1.12  1995/09/06  16:11:41  adam
+ * Keysize parameter to is_open (if non-zero).
+ *
+ * Revision 1.11  1995/09/04  12:33:46  adam
  * Various cleanup. YAZ util used instead.
  *
  * Revision 1.10  1994/09/28  16:58:32  quinn
@@ -99,7 +118,7 @@ static int splitargs(const char *s, char *bf[], int max)
  * Process resources.
  */
 ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
-    int writeflag)
+    int writeflag, int keysize)
 {
     ISAM new;
     char *nm, *r, *pp[IS_MAX_BLOCKTYPES+1], m[2];
@@ -113,8 +132,9 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
        new->types[i].index = 0;                        /* dummy */
 
     /* determine number and size of blocktypes */
-    if (!(r = res_get(common_resource, nm = strconcat(name, ".",
-       "blocktypes", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
+    if (!(r = res_get_def(common_resource, nm = strconcat(name, ".",
+       "blocktypes", 0), "64 512 4K 32K")) ||
+       !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
     {
        logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
@@ -172,16 +192,22 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
        }
        /* ELSE: this is an empty file opened in read-only mode. */
     }
-    if (!(r = res_get_def(common_resource, nm = strconcat(name, ".", "keysize",
-       0), "4")))
-    {
-       logf (LOG_FATAL, "Failed to locate resource %s", nm);
-       return 0;
-    }
-    if ((new->keysize = atoi(r)) <= 0)
+    if (keysize > 0)
+        new->keysize = keysize;
+    else
     {
-       logf (LOG_FATAL, "Must specify positive keysize.");
-       return 0;
+        if (!(r = res_get_def(common_resource, nm = strconcat(name, ".",
+                                                              "keysize",
+                                                              0), "4")))
+        {
+            logf (LOG_FATAL, "Failed to locate resource %s", nm);
+            return 0;
+        }
+        if ((new->keysize = atoi(r)) <= 0)
+        {
+            logf (LOG_FATAL, "Must specify positive keysize.");
+            return 0;
+        }
     }
 
     /* determine repack percent */
@@ -194,8 +220,9 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     new->repack = atoi(r);
 
     /* determine max keys/blocksize */
-    if (!(r = res_get(common_resource, nm = strconcat(name, ".",
-       "maxkeys", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
+    if (!(r = res_get_def(common_resource, nm = strconcat(name, ".",
+       "maxkeys", 0), "50 640 10000")) || !(num = splitargs(r, pp,
+       IS_MAX_BLOCKTYPES)))
     {
        logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
@@ -236,8 +263,9 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
     }
 
     /* determine nice fill rates */
-    if (!(r = res_get(common_resource, nm = strconcat(name, ".",
-       "nicefill", 0))) || !(num = splitargs(r, pp, IS_MAX_BLOCKTYPES)))
+    if (!(r = res_get_def(common_resource, nm = strconcat(name, ".",
+       "nicefill", 0), "90 90 90 95")) || !(num = splitargs(r, pp,
+       IS_MAX_BLOCKTYPES)))
     {
        logf (LOG_FATAL, "Failed to locate resource %s", nm);
        return 0;
@@ -323,7 +351,9 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data)
     char operation, *record;
 
     extcmp = is->cmp;
+#if 0
     qsort(data, num, is_keysize(is) + 1, sort_input);
+#endif
     is_m_establish_tab(is, &tab, pos);
     if (pos)
        if (is_m_read_full(&tab, tab.data) < 0)
@@ -443,7 +473,7 @@ void is_pt_free(ISPT ip)
  */
 int is_readkey(ISPT ip, void *buf)
 {
-    return is_m_read_record(&ip->tab, buf);
+    return is_m_read_record(&ip->tab, buf, 0);
 }    
 
 int is_numkeys(ISPT ip)