Changed limit set parameter for rpn_scan
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Nov 2007 11:20:39 +0000 (11:20 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Nov 2007 11:20:39 +0000 (11:20 +0000)
index/index.h
index/rpnfacet.c
index/rpnscan.c
index/zebraapi.c

index 2024239..80ba909 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.207 2007-11-01 16:01:33 adam Exp $
+/* $Id: index.h,v 1.208 2007-11-05 11:20:39 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -275,7 +275,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                    const Odr_oid *attributeset,
                    int num_bases, char **basenames,
                    int *position, int *num_entries, ZebraScanEntry **list,
-                   int *is_partial, RSET limit_set);
+                   int *is_partial, const char *set_name);
 
 RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no,
                const char *term, int length_term, const char *flags,
@@ -441,7 +441,7 @@ ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream,
                     const Odr_oid *attributeset,
                     int *position, int *num_entries, 
                     ZebraScanEntry **list,
-                    int *is_partial, RSET limit_set);
+                    int *is_partial, const char *set_name);
 YAZ_END_CDECL
 
 #endif
index b928f2a..2bebbfd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnfacet.c,v 1.2 2007-11-01 16:01:33 adam Exp $
+/* $Id: rpnfacet.c,v 1.3 2007-11-05 11:20:39 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -39,9 +39,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                     const Odr_oid *attributeset,
                     int *position, int *num_entries, 
-                    ZebraScanEntry **list, int *is_partial, RSET rset)
+                    ZebraScanEntry **list, int *is_partial, 
+                    const char *set_name)
 {
     int ord;
+    int use_sort_idx = 1;
     ZEBRA_RES res = zebra_attr_list_get_ord(zh,
                                             zapt->attributes,
                                             zinfo_index_category_sort,
@@ -49,7 +51,7 @@ ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                                             attributeset, &ord);
     if (res != ZEBRA_OK)
         return res;
-    else
+    else if (use_sort_idx)
     {
         const char *index_type = 0;
         const char *db = 0;
@@ -60,7 +62,7 @@ ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         char *this_entry_buf = xmalloc(SORT_IDX_ENTRYSIZE);
         char *dst_buf = xmalloc(SORT_IDX_ENTRYSIZE);
         size_t sysno_mem_index = 0;
-        
+        RSET rset = resultSetRef(zh, set_name);
         zint p_this_sys = 0;
         RSFD rfd;
         TERMID termid;
@@ -93,7 +95,36 @@ ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         rset_close(rfd);
         xfree(this_entry_buf);
         xfree(dst_buf);
-        zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, "facet not done");
+        zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, "facet not done1");
+        return ZEBRA_FAIL;
+    }
+    else
+    {
+        int num = 100; /* to be customizable */
+        int i;
+
+        ZebraMetaRecord *meta = zebra_meta_records_create_range(
+            zh, set_name, 0, num);
+
+        for (i = 0; i < num; i++)
+        {
+            zint sysno = meta[i].sysno;
+            Record rec = rec_get(zh->reg->records, sysno);
+            if (!rec)
+            {
+                yaz_log(YLOG_WARN, "rec_get fail on sysno=" ZINT_FORMAT,
+                        sysno);
+                break;
+            }
+            else
+            {
+                
+
+                rec_free(&rec);
+            }
+        }
+        zebra_meta_records_destroy(zh, meta, num);
+        zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, "facet not done2");
         return ZEBRA_FAIL;
     }
 }
index 79b12aa..3402e77 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnscan.c,v 1.20 2007-11-01 16:01:33 adam Exp $
+/* $Id: rpnscan.c,v 1.21 2007-11-05 11:20:39 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -471,7 +471,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                   const Odr_oid *attributeset,
                   int num_bases, char **basenames,
                   int *position, int *num_entries, ZebraScanEntry **list,
-                  int *is_partial, RSET limit_set)
+                  int *is_partial, const char *set_name)
 {
     int base_no;
     int ords[RPN_MAX_ORDS], ord_no = 0;
@@ -484,6 +484,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     NMEM nmem;
     ZEBRA_RES res;
     struct rset_key_control *kc = 0;
+    RSET limit_set = 0;
 
     *list = 0;
     *is_partial = 0;
@@ -491,37 +492,38 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     if (!attributeset)
         attributeset = yaz_oid_attset_bib_1;
 
-    if (!limit_set) /* no limit set given already */
+    if (!set_name)
     {
         /* see if there is a @attr 8=set */
         AttrType termset;
         int termset_value_numeric;
-        const char *termset_value_string;
+        const char *termset_value_string = 0;
         attr_init_APT(&termset, zapt, 8);
         termset_value_numeric =
             attr_find_ex(&termset, NULL, &termset_value_string);
         if (termset_value_numeric != -1)
         {
-            char resname[32];
-            const char *termset_name = 0;
-            
             if (termset_value_numeric != -2)
             {
+                char resname[32];
                 sprintf(resname, "%d", termset_value_numeric);
-                termset_name = resname;
+                set_name = odr_strdup(stream, resname); 
             }
             else
-                termset_name = termset_value_string;
-            
-            limit_set = resultSetRef(zh, termset_name);
+                set_name = odr_strdup(stream, termset_value_string);
+        }
+    }
 
-            if (!limit_set)
-            {
-                zebra_setError(zh, 
-                               YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
-                               termset_name);
-                return ZEBRA_FAIL;
-            }
+    if (set_name)
+    {
+        limit_set = resultSetRef(zh, set_name);
+        
+        if (!limit_set)
+        {
+            zebra_setError(zh, 
+                           YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
+                           set_name);
+            return ZEBRA_FAIL;
         }
     }
 
@@ -543,7 +545,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     if (sort_flag)
     {
         return rpn_facet(zh, stream, zapt, attributeset, position, num_entries,
-                         list, is_partial, limit_set);
+                         list, is_partial, set_name);
     }
     for (base_no = 0; base_no < num_bases; base_no++)
     {
@@ -575,8 +577,8 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     kc = zebra_key_control_create(zh);
 
     res = rpn_scan_norm(zh, stream, nmem, kc, zapt, position, num_entries,
-                        list,
-                        is_partial, limit_set, index_type, ord_no, ords);
+                        list, is_partial, limit_set,
+                        index_type, ord_no, ords);
     nmem_destroy(nmem);
     (*kc->dec)(kc);
     return res;
index 66e9f87..7ebb47a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.262 2007-10-31 16:56:14 adam Exp $
+/* $Id: zebraapi.c,v 1.263 2007-11-05 11:20:39 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -1251,7 +1251,6 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                     const char *setname)
 {
     ZEBRA_RES res;
-    RSET limit_rset = 0;
 
     ZEBRA_CHECK_HANDLE(zh);
 
@@ -1269,21 +1268,10 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
        *num_entries = 0;
        return ZEBRA_FAIL;
     }
-    if (setname)
-    {
-       limit_rset = resultSetRef(zh, setname);
-       if (!limit_rset)
-       {
-           zebra_setError(zh, 
-                          YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST,
-                          setname);
-           zebra_end_read (zh);
-           return ZEBRA_FAIL;
-       }
-    }
+
     res = rpn_scan(zh, stream, zapt, attributeset,
                    zh->num_basenames, zh->basenames, position,
-                   num_entries, entries, is_partial, limit_rset);
+                   num_entries, entries, is_partial, setname);
     zebra_end_read(zh);
     return res;
 }