Work on truncation.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 23 Dec 1996 15:30:44 +0000 (15:30 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 23 Dec 1996 15:30:44 +0000 (15:30 +0000)
Bug fix: result sets weren't deleted after server shut down.

index/index.h
index/kcompare.c
index/trunc.c
index/zrpn.c
index/zserver.c
index/zserver.h
index/zsets.c

index 164df5d..fc62511 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: index.h,v $
- * Revision 1.46  1996-11-08 11:10:19  adam
+ * Revision 1.47  1996-12-23 15:30:44  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.46  1996/11/08 11:10:19  adam
  * Buffers used during file match got bigger.
  * Compressed ISAM support everywhere.
  * Bug fixes regarding masking characters in queries.
@@ -233,6 +237,7 @@ void repositoryShow (struct recordGroup *rGroup);
 void key_open (int mem);
 int key_close (void);
 int key_compare (const void *p1, const void *p2);
+int key_compare_it (const void *p1, const void *p2);
 int key_qsort_compare (const void *p1, const void *p2);
 void key_logdump (int mask, const void *p);
 void inv_prstat (void);
index d592e1d..388d473 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: kcompare.c,v $
- * Revision 1.19  1996-12-11 12:08:00  adam
+ * Revision 1.20  1996-12-23 15:30:44  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.19  1996/12/11 12:08:00  adam
  * Added better compression.
  *
  * Revision 1.18  1996/10/29 14:09:44  adam
@@ -85,6 +89,25 @@ void key_logdump (int logmask, const void *p)
     logf (logmask, "%7d s=%-4d", key.sysno, key.seqno);
 }
 
+int key_compare_it (const void *p1, const void *p2)
+{
+    if (((struct it_key *) p1)->sysno != ((struct it_key *) p2)->sysno)
+    {
+        if (((struct it_key *) p1)->sysno > ((struct it_key *) p2)->sysno)
+            return 2;
+        else
+            return -2;
+    }
+    if (((struct it_key *) p1)->seqno != ((struct it_key *) p2)->seqno)
+    {
+        if (((struct it_key *) p1)->seqno > ((struct it_key *) p2)->seqno)
+            return 1;
+        else
+            return -1;
+    }
+    return 0;
+}
+
 int key_compare (const void *p1, const void *p2)
 {
     struct it_key i1, i2;
@@ -97,7 +120,6 @@ int key_compare (const void *p1, const void *p2)
         else
             return -2;
     }
-#if IT_KEY_HAVE_SEQNO
     if (i1.seqno != i2.seqno)
     {
         if (i1.seqno > i2.seqno)
@@ -105,15 +127,6 @@ int key_compare (const void *p1, const void *p2)
         else
             return -1;
     }
-#else
-    if (i1.freq != i2.freq)
-    {
-        if (i1.freq > i2.freq)
-            return 1;
-        else
-            return -1;
-    }
-#endif
     return 0;
 }
 
@@ -195,7 +208,7 @@ int iscz1_decode_int (unsigned char **src)
     c = (c << 8) + *(*src)++;
     return c;
 }
-#if 1
+
 static void iscz1_code_item (int mode, void *vp, char **dst, char **src)
 {
     struct iscz1_code_info *p = vp;
@@ -234,42 +247,6 @@ static void iscz1_code_item (int mode, void *vp, char **dst, char **src)
         (*dst) += sizeof(struct it_key);
     }
 }
-#else
-static void iscz1_code_item (int mode, void *vp, char **dst, char **src)
-{
-    struct iscz1_code_info *p = vp;
-    struct it_key tkey;
-    int d;
-
-    if (mode == ISAMC_ENCODE)
-    {
-        memcpy (&tkey, *src, sizeof(struct it_key));
-        d = tkey.sysno - p->key.sysno;
-        iscz1_encode_int (d, dst);
-        if (d)
-        {
-            p->key.sysno = tkey.sysno;
-            p->key.seqno = 0;
-        }
-        iscz1_encode_int (tkey.seqno - p->key.seqno, dst);
-        p->key.seqno = tkey.seqno;
-        (*src) += sizeof(struct it_key);
-    }
-    else
-    {
-        d = iscz1_decode_int ((unsigned char **) src);
-        if (d)
-        {
-            p->key.sysno += d;
-            p->key.seqno = 0;
-        }
-        d = iscz1_decode_int ((unsigned char **) src);
-        p->key.seqno += d;
-        memcpy (*dst, &p->key, sizeof(struct it_key));
-        (*dst) += sizeof(struct it_key);
-    }
-}
-#endif
 
 ISAMC_M key_isamc_m (void)
 {
index 41ab4aa..d1deaa1 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: trunc.c,v $
- * Revision 1.3  1996-12-20 11:07:14  adam
+ * Revision 1.4  1996-12-23 15:30:44  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.3  1996/12/20 11:07:14  adam
  * Multi-or result set.
  *
  * Revision 1.2  1996/11/08 11:10:28  adam
@@ -26,7 +30,7 @@
 #include <rsisamc.h>
 #include <rsnull.h>
 
-#define NEW_TRUNC 0
+#define NEW_TRUNC 1
 
 #if NEW_TRUNC
 #include <rsm_or.h>
@@ -160,7 +164,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to,
                                             merge_chunk);
             rscur++;
         }
-        ti = heap_init (rscur, sizeof(struct it_key), key_compare);
+        ti = heap_init (rscur, sizeof(struct it_key), key_compare_it);
         for (i = rscur; --i >= 0; )
         {
             rsfd[i] = rset_open (rset[i], RSETF_READ|RSETF_SORT_SYSNO);
@@ -208,7 +212,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to,
         ispt = xmalloc (sizeof(*ispt) * (to-from));
 
         ti = heap_init (to-from, sizeof(struct it_key),
-                        key_compare);
+                        key_compare_it);
         for (i = to-from; --i >= 0; )
         {
             ispt[i] = is_position (zi->isam, isam_p[from+i]);
@@ -260,7 +264,7 @@ static RSET rset_trunc_r (ZServerInfo *zi, ISAM_P *isam_p, int from, int to,
         ispt = xmalloc (sizeof(*ispt) * (to-from));
 
         ti = heap_init (to-from, sizeof(struct it_key),
-                        key_compare);
+                        key_compare_it);
         for (i = to-from; --i >= 0; )
         {
             ispt[i] = isc_pp_open (zi->isamc, isam_p[from+i]);
@@ -361,16 +365,17 @@ RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no)
             return rset_create (rset_kind_isamc, &parms);
         }
 #if NEW_TRUNC
-        else if (no < 2000)
+        else if (no < 200)
         {
             rset_m_or_parms parms;
 
             logf (LOG_LOG, "new_trunc");
             parms.key_size = sizeof(struct it_key);
-            parms.cmp = key_compare;
+            parms.cmp = key_compare_it;
             parms.isc = zi->isamc;
             parms.isam_positions = isam_p;
             parms.no_isam_positions = no;
+            parms.no_save_positions = 100;
             return rset_create (rset_kind_m_or, &parms);
         }
 #endif
index fe9a6bf..03bb798 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zrpn.c,v $
- * Revision 1.57  1996-11-11 13:38:02  adam
+ * Revision 1.58  1996-12-23 15:30:45  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.57  1996/11/11 13:38:02  adam
  * Added proximity support in search.
  *
  * Revision 1.56  1996/11/08 11:10:32  adam
@@ -827,7 +831,7 @@ static RSET rpn_search_APT_relevance (ZServerInfo *zi,
 
     parms.key_size = sizeof(struct it_key);
     parms.max_rec = 100;
-    parms.cmp = key_compare;
+    parms.cmp = key_compare_it;
     parms.is = zi->isam;
     parms.isc = zi->isamc;
     parms.no_terms = 0;
@@ -931,7 +935,7 @@ static RSET rpn_proximity (RSET rset1, RSET rset2, int ordered,
           exclusion, ordered, relation, distance);
     while (more1 && more2)
     {
-        int cmp = key_compare (&buf1, &buf2);
+        int cmp = key_compare_it (&buf1, &buf2);
         if (cmp < -1)
             more1 = rset_read (rset1, rsfd1, &buf1);
         else if (cmp > 1)
@@ -1046,7 +1050,7 @@ static RSET rpn_prox (RSET *rset, int rset_no)
                 *more = 0;
                 break;
             }
-            cmp = key_compare (buf[i], buf[i-1]);
+            cmp = key_compare_it (buf[i], buf[i-1]);
             if (cmp > 1)
             {
                 more[i-1] = rset_read (rset[i-1], rsfd[i-1], buf[i-1]);
@@ -1286,7 +1290,7 @@ static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs,
         if (rset_is_ranked(bool_parms.rset_r))
             soft = 1;
         bool_parms.key_size = sizeof(struct it_key);
-        bool_parms.cmp = key_compare;
+        bool_parms.cmp = key_compare_it;
 
         switch (zop->which)
         {
@@ -1369,12 +1373,12 @@ void count_set_save (RSET *r, int *count)
     rfd = rset_open (*r, RSETF_READ|RSETF_SORT_SYSNO);
     while (rset_read (*r, rfd, &key))
     {
-        logf (LOG_DEBUG, "sysno=%-7d seqno=%d", key.sysno, key.seqno);
         if (key.sysno != psysno)
         {
-            rset_write (w, wfd, &key);
-            psysno = key.sysno;
+            if (*count < 400)
+                rset_write (w, wfd, &key);
             (*count)++;
+            psysno = key.sysno;
         }
         kno++;
     }
@@ -1622,7 +1626,7 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
                    rset_trunc (zi, &scan_info_array[j].list[ptr[j]].isam_p, 1);
 
                 bool_parms.key_size = sizeof(struct it_key);
-                bool_parms.cmp = key_compare;
+                bool_parms.cmp = key_compare_it;
                 bool_parms.rset_l = rset;
                 bool_parms.rset_r = rset2;
               
@@ -1683,7 +1687,7 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
                          &scan_info_array[j].list[before-1-ptr[j]].isam_p, 1);
 
                 bool_parms.key_size = sizeof(struct it_key);
-                bool_parms.cmp = key_compare;
+                bool_parms.cmp = key_compare_it;
                 bool_parms.rset_l = rset;
                 bool_parms.rset_r = rset2;
               
index 61df429..acaf62c 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.44  1996-12-11 12:08:01  adam
+ * Revision 1.45  1996-12-23 15:30:45  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.44  1996/12/11 12:08:01  adam
  * Added better compression.
  *
  * Revision 1.43  1996/11/15 15:03:58  adam
 #include <recctrl.h>
 #include <dmalloc.h>
 
+#define USE_TIMES 1
 #ifdef __linux__
 #define USE_TIMES 1
 #endif
@@ -528,6 +533,7 @@ void bend_close (void *handle)
 {
     if (server_info.records)
     {
+        resultSetDestroy (&server_info);
         dict_close (server_info.dict);
         if (server_info.isam)
             is_close (server_info.isam);
index 4871c88..d2874a4 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.h,v $
- * Revision 1.22  1996-11-04 14:07:49  adam
+ * Revision 1.23  1996-12-23 15:30:46  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.22  1996/11/04 14:07:49  adam
  * Moved truncation code to trunc.c.
  *
  * Revision 1.21  1996/10/29 14:09:58  adam
@@ -123,6 +127,8 @@ RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no);
 ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name,
                           int ov, RSET rset);
 ZServerSet *resultSetGet (ZServerInfo *zi, const char *name);
+void resultSetDestroy (ZServerInfo *zi);
+
 ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
                                     int num, int *positions);
 void resultSetSysnoDel (ZServerInfo *zi, ZServerSetSysno *records, int num);
index 9cb1ca6..0c71974 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zsets.c,v $
- * Revision 1.10  1995-10-30 15:08:08  adam
+ * Revision 1.11  1996-12-23 15:30:46  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.10  1995/10/30 15:08:08  adam
  * Bug fixes.
  *
  * Revision 1.9  1995/10/17  18:02:14  adam
@@ -79,6 +83,20 @@ ZServerSet *resultSetGet (ZServerInfo *zi, const char *name)
     return NULL;
 }
 
+void resultSetDestroy (ZServerInfo *zi)
+{
+    ZServerSet *s, *s1;
+
+    for (s = zi->sets; s; s = s1)
+    {
+        s1 = s->next;
+        rset_delete (s->rset);
+        xfree (s->name);
+        xfree (s);
+    }
+    zi->sets = NULL;
+}
+
 ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name, 
                                     int num, int *positions)
 {