Honor approximative limits for scan (type 12).
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 1 Nov 2007 14:10:03 +0000 (14:10 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 1 Nov 2007 14:10:03 +0000 (14:10 +0000)
The documentation mentions attribute 9/11. However, that's not
found anywhere in the code. Attribute 12 is chosen (same as a
search global approximative limit).

index/index.h
index/rpnscan.c
index/rpnsearch.c

index 514a700..4511e4a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.204 2007-10-31 16:56:14 adam Exp $
+/* $Id: index.h,v 1.205 2007-11-01 14:10:03 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -430,6 +430,12 @@ int zebra_check_res(Res res);
 #define FIRST_IN_FIELD_CHAR 1
 #define FIRST_IN_FIELD_LEN 2
 
+ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh,
+                                Z_AttributesPlusTerm *zapt,
+                                zint *hits_limit_value,
+                                const char **term_ref_id_str,
+                                NMEM nmem);
+
 YAZ_END_CDECL
 
 #endif
index 9349565..b4e9fa8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnscan.c,v 1.17 2007-10-31 16:56:14 adam Exp $
+/* $Id: rpnscan.c,v 1.18 2007-11-01 14:10:03 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -81,7 +81,7 @@ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     return ZEBRA_OK;
 }
 
-static void count_set(ZebraHandle zh, RSET rset, zint *count)
+static void count_set(ZebraHandle zh, RSET rset, zint *count, zint approx_limit)
 {
     zint psysno = 0;
     struct it_key key;
@@ -89,7 +89,7 @@ static void count_set(ZebraHandle zh, RSET rset, zint *count)
 
     yaz_log(YLOG_DEBUG, "count_set");
 
-    rset->hits_limit = zh->approx_limit;
+    rset->hits_limit = approx_limit;
 
     *count = 0;
     rfd = rset_open(rset, RSETF_READ);
@@ -187,6 +187,15 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
 {
     int i;
     RSET rset = 0;
+    zint approx_limit = zh->approx_limit;
+    AttrType global_hits_limit_attr;
+    int l;
+    attr_init_APT(&global_hits_limit_attr, zapt, 12);
+            
+    l = attr_find(&global_hits_limit_attr, NULL);
+    if (l != -1)
+        approx_limit = l;
+    
     for (i = 0; i < ord_no; i++)
     {
         if (ar[i].isam_p && strcmp(wrbuf_cstr(ar[i].term), term) == 0)
@@ -202,7 +211,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
                     wrbuf_buf(ar[i].term), wrbuf_len(ar[i].term),
                     NULL, 1, zapt->term->which, nmem, 
                     kc, kc->scope, ol, index_type, 
-                    0 /* hits_limit */,
+                    0 /* hits_limit_value */,
                     0 /* term_ref_id_str */);
             if (!rset)
                 rset = rset_t;
@@ -231,7 +240,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem,
             rset = rset_create_and(nmem, kc, kc->scope, 2, rsets);
         }
         /* count it */
-        count_set(zh, rset, &count);
+        count_set(zh, rset, &count, approx_limit);
 
         if (pos != -1)
         {
index b399a49..2698c58 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rpnsearch.c,v 1.19 2007-10-31 16:56:14 adam Exp $
+/* $Id: rpnsearch.c,v 1.20 2007-11-01 14:10:03 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -835,11 +835,11 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                              const char *xpath_use,
                             struct ord_list **ol);
 
-static ZEBRA_RES term_limits_APT(ZebraHandle zh,
-                                Z_AttributesPlusTerm *zapt,
-                                zint *hits_limit_value,
-                                const char **term_ref_id_str,
-                                NMEM nmem)
+ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh,
+                                Z_AttributesPlusTerm *zapt,
+                                zint *hits_limit_value,
+                                const char **term_ref_id_str,
+                                NMEM nmem)
 {
     AttrType term_ref_id_attr;
     AttrType hits_limit_attr;
@@ -902,7 +902,8 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
     WRBUF term_dict = wrbuf_alloc();
 
     *rset = 0;
-    term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, stream);
+    zebra_term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str,
+                          stream);
     grep_info->isam_p_indx = 0;
     res = string_term(zh, zapt, term_sub, term_dict,
                       attributeSet, stream, grep_info,
@@ -1703,7 +1704,8 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
     zint hits_limit_value;
     const char *term_ref_id_str = 0;
 
-    term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, stream);
+    zebra_term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str,
+                          stream);
 
     yaz_log(log_level_rpn, "APT_numeric t='%s'", termz);
     if (grep_info_prepare(zh, zapt, &grep_info, index_type) == ZEBRA_FAIL)