Save ord(inal) indexes IDs so we can make snippets properly.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 Jun 2005 21:31:08 +0000 (21:31 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 Jun 2005 21:31:08 +0000 (21:31 +0000)
include/rset.h
index/index.h
index/trunc.c
index/zrpn.c
index/zsets.c
rset/rsbetween.c
rset/rset.c

index 593d666..7fc3c95 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rset.h,v 1.53 2005-06-02 11:59:53 adam Exp $
+/* $Id: rset.h,v 1.54 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -35,6 +35,11 @@ YAZ_BEGIN_CDECL
 typedef struct rsfd *RSFD;
 typedef struct rset *RSET;
 
+struct ord_list {
+    int ord;
+    struct ord_list *next;
+};
+
 /** 
  * rset_term is all we need to know of a term to do ranking etc. 
  * As far as the rsets are concerned, it is just a dummy pointer to
@@ -51,11 +56,12 @@ struct rset_term {
                   */
     RSET rset;     /** the rset corresponding to this term */
     void *rankpriv;/** private stuff for the ranking algorithm */
+    struct ord_list *ol;
 };
 
 typedef struct rset_term *TERMID; 
 TERMID rset_term_create (const char *name, int length, const char *flags,
-                        int type, NMEM nmem);
+                        int type, NMEM nmem, struct ord_list *ol);
 
 /** rsfd is a "file descriptor" for reading from a rset */
 struct rsfd {  /* the stuff common to all rsfd's. */
index 33ab460..7a921ef 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.139 2005-05-31 13:01:37 adam Exp $
+/* $Id: index.h,v 1.140 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -364,10 +364,11 @@ ZEBRA_RES rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                    int *position, int *num_entries, ZebraScanEntry **list,
                    int *is_partial, RSET limit_set, int return_zero);
 
-RSET rset_trunc (ZebraHandle zh, ISAM_P *isam_p, int no,
-                const char *term, int length_term, const char *flags,
-                 int preserve_position, int term_type, NMEM rset_nmem,
-                 struct rset_key_control *kctrl, int scope);
+RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no,
+               const char *term, int length_term, const char *flags,
+               int preserve_position, int term_type, NMEM rset_nmem,
+               struct rset_key_control *kctrl, int scope,
+               struct ord_list *ol);
 
 void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type,
                       const char *db, int set,
index e432a32..63b27e8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: trunc.c,v 1.58 2005-05-24 11:35:42 adam Exp $
+/* $Id: trunc.c,v 1.59 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -399,13 +399,14 @@ static int isamc_trunc_cmp(const void *p1, const void *p2)
 RSET rset_trunc(ZebraHandle zi, ISAM_P *isam_p, int no,
                const char *term, int length, const char *flags,
                int preserve_position, int term_type, NMEM rset_nmem,
-               struct rset_key_control *kctrl, int scope)
+               struct rset_key_control *kctrl, int scope,
+               struct ord_list *ol)
 {
     TERMID termid;
     RSET result;
     int trunc_chunk;
     
-    termid = rset_term_create(term, length, flags, term_type, rset_nmem);
+    termid = rset_term_create(term, length, flags, term_type, rset_nmem, ol);
     if (no < 1)
        return rsnull_create(rset_nmem, kctrl, termid);
     
index 9f3fbec..ce55c6e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zrpn.c,v 1.194 2005-06-02 11:59:54 adam Exp $
+/* $Id: zrpn.c,v 1.195 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -50,6 +50,19 @@ typedef struct
     Z_AttributesPlusTerm *zapt;
 } AttrType;
 
+static struct ord_list *ord_list_create(NMEM nmem)
+{
+    return 0;
+}
+
+static struct ord_list *ord_list_append(NMEM nmem, struct ord_list *list,
+                                       int ord)
+{
+    struct ord_list *n = nmem_malloc(nmem, sizeof(*n));
+    n->ord = ord;
+    n->next = list;
+    return n;
+}
 
 static int log_level_set = 0;
 static int log_level_rpn = 0;
@@ -987,7 +1000,8 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
-                            char *term_dst, int xpath_use);
+                            char *term_dst, int xpath_use,
+                            struct ord_list **ol);
 
 static ZEBRA_RES term_trunc(ZebraHandle zh,
                            Z_AttributesPlusTerm *zapt,
@@ -1003,11 +1017,12 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
                            struct rset_key_control *kc)
 {
     ZEBRA_RES res;
+    struct ord_list *ol;
     *rset = 0;
     grep_info->isam_p_indx = 0;
     res = string_term(zh, zapt, term_sub, attributeSet, stream, grep_info,
                      reg_type, complete_flag, num_bases, basenames,
-                     term_dst, xpath_use);
+                     term_dst, xpath_use, &ol);
     if (res != ZEBRA_OK)
         return res;
     if (!*term_sub)  /* no more terms ? */
@@ -1017,7 +1032,7 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
                       grep_info->isam_p_indx, term_dst,
                       strlen(term_dst), rank_type, 1 /* preserve pos */,
                       zapt->term->which, rset_nmem,
-                      kc, kc->scope);
+                      kc, kc->scope, ol);
     if (!*rset)
        return ZEBRA_FAIL;
     return ZEBRA_OK;
@@ -1036,7 +1051,8 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
-                            char *term_dst, int xpath_use)
+                            char *term_dst, int xpath_use,
+                            struct ord_list **ol)
 {
     char term_dict[2*IT_MAX_WORD+4000];
     int j, r, base_no;
@@ -1054,6 +1070,9 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     int errCode = 0;      /* err code (if any is not OK) */
     char *errString = 0;  /* addinfo */
 
+
+    *ol = ord_list_create(stream);
+
     rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
     attr_init(&use, zapt, 1);
     use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
@@ -1122,6 +1141,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                 term_dict[prefix_len++] = ord_buf[i];
             }
             attp.local_attributes = 0;  /* no more attributes */
+           *ol = ord_list_append(stream, *ol, ord);
        }
         else 
         {
@@ -1167,6 +1187,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                                              local_attr->local);
            if (ord < 0)
                continue;
+           *ol = ord_list_append(stream, *ol, ord);
            if (prefix_len)
                term_dict[prefix_len++] = '|';
            else
@@ -1958,7 +1979,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
                       strlen(term_dst), rank_type,
                       0 /* preserve position */,
                       zapt->term->which, rset_nmem, 
-                      kc, kc->scope);
+                      kc, kc->scope, 0);
        if (!result_sets[num_result_sets])
            break;
        num_result_sets++;
@@ -2152,7 +2173,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
     rset = rset_trunc(zh, grep_info.isam_p_buf,
                      grep_info.isam_p_indx, term, strlen(term),
                      flags, 1, term_type,rset_nmem,
-                     kc, kc->scope);
+                     kc, kc->scope, 0);
     grep_info_delete(&grep_info);
     return rset;
 }
@@ -2956,7 +2977,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
            rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
                              glist[lo].term, strlen(glist[lo].term),
                              NULL, 0, zapt->term->which, rset_nmem, 
-                             kc, kc->scope);
+                             kc, kc->scope, 0);
        }
        ptr[j0]++; /* move index for this set .. */
        /* get result set for remaining scan terms */
@@ -2977,7 +2998,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                            glist[lo].term,
                            strlen(glist[lo].term), NULL, 0,
                            zapt->term->which,rset_nmem,
-                           kc, kc->scope);
+                           kc, kc->scope, 0);
                    rset = rsmulti_or_create(rset_nmem, kc,
                                             kc->scope, 0 /* termid */,
                                             2, rsets);
@@ -3047,7 +3068,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
            (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
             glist[lo].term, strlen(glist[lo].term),
             NULL, 0, zapt->term->which, rset_nmem,
-            kc, kc->scope);
+            kc, kc->scope, 0);
        
        ptr[j0]++;
        
@@ -3066,7 +3087,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                    glist[lo].term,
                    strlen(glist[lo].term), NULL, 0,
                    zapt->term->which, rset_nmem,
-                   kc, kc->scope);
+                   kc, kc->scope, 0);
                rset = rsmulti_or_create(rset_nmem, kc,
                                         kc->scope, 0 /* termid */, 2, rsets);
                
index 9726903..3ec27f7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zsets.c,v 1.85 2005-05-31 13:01:37 adam Exp $
+/* $Id: zsets.c,v 1.86 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -1072,8 +1072,11 @@ ZEBRA_RES zebra_get_hit_vector(ZebraHandle zh, const char *setname,
        {
            if (termid)
            {
+               struct ord_list *ol;
                key_logdump_txt(YLOG_LOG, &key, termid->name);
                yaz_log(YLOG_LOG, "   type=%d", termid->type);
+               for (ol = termid->ol; ol; ol = ol->next)
+                   yaz_log(YLOG_LOG, "   ord=%d", ol->ord);
            }
        }
        rset_close(rsfd);
index a03bea1..e2411fd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsbetween.c,v 1.39 2005-05-24 11:35:43 adam Exp $
+/* $Id: rsbetween.c,v 1.40 2005-06-06 21:31:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -92,11 +92,11 @@ static int log_level_initialized = 0;
 
 /* make sure that the rset has a term attached. If not, create one */
 /* we need these terms for the tags, to distinguish what we read */
-static void checkterm( RSET rs, char *tag, NMEM nmem)
+static void checkterm(RSET rs, char *tag, NMEM nmem)
 {
     if (!rs->term)
     {
-        rs->term = rset_term_create(tag, strlen(tag), "", 0, nmem);
+        rs->term = rset_term_create(tag, strlen(tag), "", 0, nmem, 0);
         rs->term->rset = rs;
     }
 }
index 38f02e8..c825bf0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rset.c,v 1.47 2005-06-02 11:59:54 adam Exp $
+/* $Id: rset.c,v 1.48 2005-06-06 21:31:09 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -284,9 +284,10 @@ void rset_get_one_term(RSET ct, TERMID *terms, int maxterms, int *curterm)
    \param flags for term
    \param type Term Type, Z_Term_general, Z_Term_characterString,..
    \param nmem memory for term.
+   \param ol ord list
 */
 TERMID rset_term_create(const char *name, int length, const char *flags,
-                       int type, NMEM nmem)
+                       int type, NMEM nmem, struct ord_list *ol)
 
 {
     TERMID t;
@@ -310,6 +311,7 @@ TERMID rset_term_create(const char *name, int length, const char *flags,
     t->type = type;
     t->rankpriv = 0;
     t->rset = 0;
+    t->ol = ol;
     return t;
 }