Added extra parameter setname for zebra scan functions. This allows
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Aug 2005 09:35:25 +0000 (09:35 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Aug 2005 09:35:25 +0000 (09:35 +0000)
a scan to be limited by a result set (NULL for no limit). If no
result set is given for scan functions, attribute 8 is inspected.
If present, value of attribute 8 is used as limit.

examples/gils/zebra.cfg
include/idzebra/api.h
index/zebraapi.c
index/zserver.c
test/api/testlib.c

index ab98930..db4e49b 100644 (file)
@@ -1,5 +1,5 @@
 # Simple Zebra configuration file
 # Simple Zebra configuration file
-# $Id: zebra.cfg,v 1.7 2005-05-12 10:16:26 adam Exp $
+# $Id: zebra.cfg,v 1.8 2005-08-09 09:35:25 adam Exp $
 #
 # Where the schema files, attribute files, etc are located.
 profilePath: .:../../tab
 #
 # Where the schema files, attribute files, etc are located.
 profilePath: .:../../tab
@@ -16,7 +16,9 @@ isam: c
 perm.anonymous: rw
 
 #rank: zvrank
 perm.anonymous: rw
 
 #rank: zvrank
-#recordId: (bib-1,identifier-standard)
+recordId: (bib-1,title)
+
+database: adam
 
 modulePath: ../../recctrl/.libs
 #shadow: shadow:100M
 
 modulePath: ../../recctrl/.libs
 #shadow: shadow:100M
index e2bddc2..bb707cb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: api.h,v 1.27 2005-06-22 19:42:38 adam Exp $
+/* $Id: api.h,v 1.28 2005-08-09 09:35:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -267,13 +267,15 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname,
    \param num_entries number of terms requested / returned 
    \param entries list of resulting terms (ODR allocated)
    \param is_partial upon return 1=partial, 0=complete
    \param num_entries number of terms requested / returned 
    \param entries list of resulting terms (ODR allocated)
    \param is_partial upon return 1=partial, 0=complete
+   \param setname limit scan by this set (NULL means no limit)
 */
 YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream,
                                Z_AttributesPlusTerm *zapt,
                                oid_value attributeset,
                                int *position, int *num_entries,
                                ZebraScanEntry **entries,
 */
 YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream,
                                Z_AttributesPlusTerm *zapt,
                                oid_value attributeset,
                                int *position, int *num_entries,
                                ZebraScanEntry **entries,
-                               int *is_partial);
+                               int *is_partial,
+                               const char *setname);
 
 /**
    \brief performs Scan (taking PQF string)
 
 /**
    \brief performs Scan (taking PQF string)
@@ -284,11 +286,12 @@ YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream,
    \param num_entries number of terms requested / returned 
    \param entries list of resulting terms (ODR allocated)
    \param is_partial upon return 1=partial, 0=complete
    \param num_entries number of terms requested / returned 
    \param entries list of resulting terms (ODR allocated)
    \param is_partial upon return 1=partial, 0=complete
+   \param setname limit scan by this set (NULL means no limit)
 */
 YAZ_EXPORT
 ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
                    int *position, int *num_entries, ZebraScanEntry **entries,
 */
 YAZ_EXPORT
 ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
                    int *position, int *num_entries, ZebraScanEntry **entries,
-                   int *is_partial);
+                   int *is_partial, const char *setname);
 
 /**
    \brief authenticate user. Returns 0 if OK, != 0 on failure
 
 /**
    \brief authenticate user. Returns 0 if OK, != 0 on failure
index cbf4514..5995610 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.179 2005-06-23 06:45:46 adam Exp $
+/* $Id: zebraapi.c,v 1.180 2005-08-09 09:35:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -1015,7 +1015,8 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
 ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
                         int *position,
                         int *num_entries, ZebraScanEntry **entries,
 ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
                         int *position,
                         int *num_entries, ZebraScanEntry **entries,
-                        int *is_partial)
+                        int *is_partial,
+                        const char *setname)
 {
     YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
     Z_AttributesPlusTerm *zapt;
 {
     YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
     Z_AttributesPlusTerm *zapt;
@@ -1029,7 +1030,8 @@ ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
     }
     else
        res = zebra_scan(zh, stream, zapt, VAL_BIB1,
     }
     else
        res = zebra_scan(zh, stream, zapt, VAL_BIB1,
-                        position, num_entries, entries, is_partial);
+                        position, num_entries, entries, is_partial,
+                        setname);
     yaz_pqf_destroy (pqf_parser);
     return res;
 }
     yaz_pqf_destroy (pqf_parser);
     return res;
 }
@@ -1038,9 +1040,11 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                     oid_value attributeset,
                     int *position,
                     int *num_entries, ZebraScanEntry **entries,
                     oid_value attributeset,
                     int *position,
                     int *num_entries, ZebraScanEntry **entries,
-                    int *is_partial)
+                    int *is_partial,
+                    const char *setname)
 {
     ZEBRA_RES res;
 {
     ZEBRA_RES res;
+    RSET limit_rset = 0;
     ASSERTZH;
     assert(stream);
     assert(zapt);
     ASSERTZH;
     assert(stream);
     assert(zapt);
@@ -1056,9 +1060,21 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
        *num_entries = 0;
        return ZEBRA_FAIL;
     }
        *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,
     res = rpn_scan (zh, stream, zapt, attributeset,
                    zh->num_basenames, zh->basenames, position,
-                   num_entries, entries, is_partial, 0, 0);
+                   num_entries, entries, is_partial, limit_rset, 0);
     zebra_end_read (zh);
     return res;
 }
     zebra_end_read (zh);
     return res;
 }
index 7feac45..c0eacbe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zserver.c,v 1.137 2005-06-22 19:42:38 adam Exp $
+/* $Id: zserver.c,v 1.138 2005-08-09 09:35:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -359,7 +359,8 @@ static int bend_scan (void *handle, bend_scan_rr *r)
     res = zebra_scan(zh, r->stream, r->term,
                     r->attributeset,
                     &r->term_position,
     res = zebra_scan(zh, r->stream, r->term,
                     r->attributeset,
                     &r->term_position,
-                    &r->num_entries, &entries, &is_partial);
+                    &r->num_entries, &entries, &is_partial, 
+                    0 /* setname */);
     if (res == ZEBRA_OK)
     {
        if (is_partial)
     if (res == ZEBRA_OK)
     {
        if (is_partial)
index 3d1f743..8301cb6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: testlib.c,v 1.23 2005-06-14 20:28:54 adam Exp $
+/* $Id: testlib.c,v 1.24 2005-08-09 09:35:26 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -238,7 +238,8 @@ void do_scan(int lineno, ZebraHandle zh, const char *query,
     yaz_log(log_level, "======================================");
     yaz_log(log_level, "scan[%d]: pos=%d num=%d %s", lineno, pos, num, query);
 
     yaz_log(log_level, "======================================");
     yaz_log(log_level, "scan[%d]: pos=%d num=%d %s", lineno, pos, num, query);
 
-    res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial);
+    res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, 
+                        0 /* setname */);
     if (res != ZEBRA_OK)
     {
        printf("Error: scan returned %d (FAIL), but no error was expected\n"
     if (res != ZEBRA_OK)
     {
        printf("Error: scan returned %d (FAIL), but no error was expected\n"