Removed unused function rpn_scan_ver1
authorAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Oct 2006 17:18:05 +0000 (17:18 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Oct 2006 17:18:05 +0000 (17:18 +0000)
index/rpnscan.c

index 02bf5da..846c979 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnscan.c,v 1.3 2006-09-21 20:22:34 adam Exp $
+/* $Id: rpnscan.c,v 1.4 2006-10-29 17:18:05 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -375,283 +375,6 @@ struct scan_info {
     char prefix[20];
 };
 
-static int scan_handle1(char *name, const char *info, int pos, void *client)
-{
-    int len_prefix, idx;
-    struct scan_info *scan_info = (struct scan_info *) client;
-
-    len_prefix = strlen(scan_info->prefix);
-    if (memcmp (name, scan_info->prefix, len_prefix))
-        return 1;
-    if (pos > 0)
-       idx = scan_info->after - pos + scan_info->before;
-    else
-        idx = - pos - 1;
-
-    /* skip special terms such as first-in-field specials */
-    if (name[len_prefix] < CHR_BASE_CHAR)
-        return 1;
-
-    if (idx < 0)
-       return 0;
-    scan_info->list[idx].term = (char *)
-        odr_malloc(scan_info->odr, strlen(name + len_prefix)+1);
-    strcpy(scan_info->list[idx].term, name + len_prefix);
-    assert (*info == sizeof(ISAM_P));
-    memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAM_P));
-    return 0;
-}
-
-static ZEBRA_RES rpn_scan_ver1(ZebraHandle zh, ODR stream, NMEM rset_nmem,
-                               struct rset_key_control *kc,
-                               Z_AttributesPlusTerm *zapt,
-                               int *position, int *num_entries, 
-                               ZebraScanEntry **list,
-                               int *is_partial, RSET limit_set,
-                               int index_type, int ord_no, int *ords)
-{
-    int pos = *position;
-    int num = *num_entries;
-    int before;
-    int after;
-    int i;
-    struct scan_info *scan_info_array;
-    char termz[IT_MAX_WORD+20];
-    ZebraScanEntry *glist;
-    int ptr[RPN_MAX_ORDS];
-
-    before = pos-1;
-    if (before < 0)
-       before = 0;
-    after = 1+num-pos;
-    if (after < 0)
-       after = 0;
-    yaz_log(YLOG_DEBUG, "rpn_scan pos=%d num=%d before=%d "
-           "after=%d before+after=%d",
-           pos, num, before, after, before+after);
-    scan_info_array = (struct scan_info *)
-        odr_malloc(stream, ord_no * sizeof(*scan_info_array));
-    for (i = 0; i < ord_no; i++)
-    {
-        int j, prefix_len = 0;
-        int before_tmp = before, after_tmp = after;
-        struct scan_info *scan_info = scan_info_array + i;
-        struct rpn_char_map_info rcmi;
-
-        rpn_char_map_prepare (zh->reg, index_type, &rcmi);
-
-        scan_info->before = before;
-        scan_info->after = after;
-        scan_info->odr = stream;
-
-        scan_info->list = (struct scan1_info_entry *)
-            odr_malloc(stream, (before+after) * sizeof(*scan_info->list));
-        for (j = 0; j<before+after; j++)
-            scan_info->list[j].term = NULL;
-
-        prefix_len += key_SU_encode (ords[i], termz + prefix_len);
-        termz[prefix_len] = 0;
-        strcpy(scan_info->prefix, termz);
-
-        if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) == 
-            ZEBRA_FAIL)
-            return ZEBRA_FAIL;
-       
-        dict_scan(zh->reg->dict, termz, &before_tmp, &after_tmp,
-                 scan_info, scan_handle1);
-    }
-    glist = (ZebraScanEntry *)
-        odr_malloc(stream, (before+after)*sizeof(*glist));
-
-    /* consider terms after main term */
-    for (i = 0; i < ord_no; i++)
-        ptr[i] = before;
-    
-    *is_partial = 0;
-    for (i = 0; i<after; i++)
-    {
-        int j, j0 = -1;
-        const char *mterm = NULL;
-        const char *tst;
-        RSET rset = 0;
-       int lo = i + pos-1; /* offset in result list */
-
-       /* find: j0 is the first of the minimal values */
-        for (j = 0; j < ord_no; j++)
-        {
-            if (ptr[j] < before+after && ptr[j] >= 0 &&
-                (tst = scan_info_array[j].list[ptr[j]].term) &&
-                (!mterm || strcmp (tst, mterm) < 0))
-            {
-                j0 = j;
-                mterm = tst;
-            }
-        }
-        if (j0 == -1)
-            break;  /* no value found, stop */
-
-       /* get result set for first one , but only if it's within bounds */
-       if (lo >= 0)
-       {
-           /* get result set for first term */
-           zebra_term_untrans_iconv(zh, stream->mem, index_type,
-                                    &glist[lo].term, mterm);
-           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, 0, index_type, 0 /* hits_limit */,
-                             0 /* term_ref_id_str */);
-       }
-       ptr[j0]++; /* move index for this set .. */
-       /* get result set for remaining scan terms */
-        for (j = j0+1; j<ord_no; j++)
-        {
-            if (ptr[j] < before+after && ptr[j] >= 0 &&
-                (tst = scan_info_array[j].list[ptr[j]].term) &&
-                !strcmp (tst, mterm))
-            {
-               if (lo >= 0)
-               {
-                   RSET rsets[2];
-                   
-                   rsets[0] = rset;
-                   rsets[1] =
-                       rset_trunc(
-                           zh, &scan_info_array[j].list[ptr[j]].isam_p, 1,
-                           glist[lo].term,
-                           strlen(glist[lo].term), NULL, 0,
-                           zapt->term->which,rset_nmem,
-                           kc, kc->scope, 0, index_type, 0 /* hits_limit */,
-                           0 /* term_ref_id_str */ );
-                   rset = rset_create_or(rset_nmem, kc,
-                                          kc->scope, 0 /* termid */,
-                                          2, rsets);
-               }
-                ptr[j]++;
-            }
-        }
-       if (lo >= 0)
-       {
-           zint count;
-           /* merge with limit_set if given */
-           if (limit_set)
-           {
-               RSET rsets[2];
-               rsets[0] = rset;
-               rsets[1] = rset_dup(limit_set);
-               
-               rset = rset_create_and(rset_nmem, kc, kc->scope, 2, rsets);
-           }
-           /* count it */
-           count_set(zh, rset, &count);
-           glist[lo].occurrences = count;
-           rset_delete(rset);
-       }
-    }
-    if (i < after)
-    {
-       *num_entries -= (after-i);
-       *is_partial = 1;
-       if (*num_entries < 0)
-       {
-           *num_entries = 0;
-           return ZEBRA_OK;
-       }
-    }
-    /* consider terms before main term */
-    for (i = 0; i<ord_no; i++)
-       ptr[i] = 0;
-    
-    for (i = 0; i<before; i++)
-    {
-       int j, j0 = -1;
-       const char *mterm = NULL;
-       const char *tst;
-       RSET rset;
-       int lo = before-1-i; /* offset in result list */
-       zint count;
-       
-       for (j = 0; j <ord_no; j++)
-       {
-           if (ptr[j] < before && ptr[j] >= 0 &&
-               (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
-               (!mterm || strcmp (tst, mterm) > 0))
-           {
-               j0 = j;
-                   mterm = tst;
-           }
-       }
-       if (j0 == -1)
-           break;
-       
-       zebra_term_untrans_iconv(zh, stream->mem, index_type,
-                                &glist[lo].term, mterm);
-       
-       rset = rset_trunc
-           (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, 0, index_type, 0 /* hits_limit */,
-            0 /* term_ref_id_str */);
-       
-       ptr[j0]++;
-       
-       for (j = j0+1; j<ord_no; j++)
-       {
-           if (ptr[j] < before && ptr[j] >= 0 &&
-               (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
-               !strcmp (tst, mterm))
-           {
-               RSET rsets[2];
-               
-               rsets[0] = rset;
-               rsets[1] = rset_trunc(
-                   zh,
-                   &scan_info_array[j].list[before-1-ptr[j]].isam_p, 1,
-                   glist[lo].term,
-                   strlen(glist[lo].term), NULL, 0,
-                   zapt->term->which, rset_nmem,
-                   kc, kc->scope, 0, index_type, 0 /* hits_limit */,
-                   0 /* term_ref_id_str */);
-               rset = rset_create_or(rset_nmem, kc,
-                                      kc->scope, 0 /* termid */, 2, rsets);
-               
-               ptr[j]++;
-           }
-       }
-        if (limit_set)
-       {
-           RSET rsets[2];
-           rsets[0] = rset;
-           rsets[1] = rset_dup(limit_set);
-           
-           rset = rset_create_and(rset_nmem, kc, kc->scope, 2, rsets);
-       }
-       count_set(zh, rset, &count);
-       glist[lo].occurrences = count;
-       rset_delete (rset);
-    }
-    i = before-i;
-    if (i)
-    {
-        *is_partial = 1;
-        *position -= i;
-        *num_entries -= i;
-       if (*num_entries <= 0)
-       {
-           *num_entries = 0;
-           return ZEBRA_OK;
-       }
-    }
-    
-    *list = glist + i;               /* list is set to first 'real' entry */
-    
-    yaz_log(YLOG_DEBUG, "position = %d, num_entries = %d",
-           *position, *num_entries);
-    return ZEBRA_OK;
-}
-
-
 ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                   oid_value attributeset,
                   int num_bases, char **basenames,