Minor changes in search API.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 22 Sep 1998 10:48:18 +0000 (10:48 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 22 Sep 1998 10:48:18 +0000 (10:48 +0000)
index/apitest.c
index/zebraapi.h
index/zrpn.c
index/zserver.c
index/zsets.c

index 7af42a5..57c2f74 100644 (file)
@@ -98,7 +98,7 @@ int main (int argc, char **argv)
 {
     /* odr is a handle to memory assocated with RETURNED data from
        various functions */
 {
     /* odr is a handle to memory assocated with RETURNED data from
        various functions */
-    ODR odr;
+    ODR odr_input, odr_output;
     
     /* zh is our Zebra Handle - describes the server as a whole */
     ZebraHandle zh;
     
     /* zh is our Zebra Handle - describes the server as a whole */
     ZebraHandle zh;
@@ -109,7 +109,8 @@ int main (int argc, char **argv)
 
     nmem_init ();
 
 
     nmem_init ();
 
-    odr = odr_createmem (ODR_ENCODE);    
+    odr_input = odr_createmem (ODR_DECODE);    
+    odr_output = odr_createmem (ODR_ENCODE);    
     
    /* open Zebra */
     zh = zebra_open ("zebra.cfg");
     
    /* open Zebra */
     zh = zebra_open ("zebra.cfg");
@@ -128,7 +129,7 @@ int main (int argc, char **argv)
     for (argno = 1; argno < argc; argno++)
     {
        /* parse the query and generate an RPN structure */
     for (argno = 1; argno < argc; argno++)
     {
        /* parse the query and generate an RPN structure */
-       Z_RPNQuery *query = p_query_rpn (odr, PROTO_Z3950, argv[argno]);
+       Z_RPNQuery *query = p_query_rpn (odr_input, PROTO_Z3950, argv[argno]);
        char setname[64];
        int errCode;
        int i;
        char setname[64];
        int errCode;
        int i;
@@ -141,7 +142,7 @@ int main (int argc, char **argv)
        if (!query)
        {
            logf (LOG_WARN, "bad query %s\n", argv[argno]);
        if (!query)
        {
            logf (LOG_WARN, "bad query %s\n", argv[argno]);
-           odr_reset (odr);
+           odr_reset (odr_input);
            continue;
        }
 
            continue;
        }
 
@@ -149,7 +150,7 @@ int main (int argc, char **argv)
        sprintf (setname, "%d", i);
 
        /* fire up the search */
        sprintf (setname, "%d", i);
 
        /* fire up the search */
-       zebra_search_rpn (zh, odr, query, 1, &base, setname);
+       zebra_search_rpn (zh, odr_input, odr_output, query, 1, &base, setname);
        
        /* status ... */
        errCode = zebra_errCode (zh);
        
        /* status ... */
        errCode = zebra_errCode (zh);
@@ -173,16 +174,17 @@ int main (int argc, char **argv)
            noOfRecordsToFetch = zebra_hits(zh);
 
        /* reset our memory - we've finished dealing with search */
            noOfRecordsToFetch = zebra_hits(zh);
 
        /* reset our memory - we've finished dealing with search */
-       odr_reset (odr);
+       odr_reset (odr_input);
+       odr_reset (odr_output);
 
        /* prepare to fetch ... */
 
        /* prepare to fetch ... */
-       records = malloc (sizeof(*records) * noOfRecordsToFetch);
+       records = odr_malloc (odr_input, sizeof(*records) * noOfRecordsToFetch);
        /* specify position of each record to fetch */
        /* first one is numbered 1 and NOT 0 */
        for (i = 0; i<noOfRecordsToFetch; i++)
            records[i].position = i+1;
        /* fetch them and request for GRS-1 records */
        /* specify position of each record to fetch */
        /* first one is numbered 1 and NOT 0 */
        for (i = 0; i<noOfRecordsToFetch; i++)
            records[i].position = i+1;
        /* fetch them and request for GRS-1 records */
-       zebra_records_retrieve (zh, odr, setname, NULL, VAL_GRS1,
+       zebra_records_retrieve (zh, odr_input, setname, NULL, VAL_GRS1,
                                noOfRecordsToFetch, records);
 
        /* status ... */
                                noOfRecordsToFetch, records);
 
        /* status ... */
@@ -223,8 +225,12 @@ int main (int argc, char **argv)
                }
            }
        }
                }
            }
        }
-       free (records);
-       odr_reset (odr);  /* reset memory */
+       /* reset our memory - we've finished dealing with present */
+       odr_reset (odr_input); 
+       odr_reset (odr_output);
     }
     }
+    odr_destroy (odr_input);
+    odr_destroy (odr_output);
+    zebra_close (zh);
     return 0;
 }
     return 0;
 }
index 329c9cf..953a9f7 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zebraapi.h,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zebraapi.h,v $
- * Revision 1.4  1998-09-02 13:53:18  adam
+ * Revision 1.5  1998-09-22 10:48:19  adam
+ * Minor changes in search API.
+ *
+ * Revision 1.4  1998/09/02 13:53:18  adam
  * Extra parameter decode added to search routines to implement
  * persistent queries.
  *
  * Extra parameter decode added to search routines to implement
  * persistent queries.
  *
@@ -46,7 +49,7 @@ typedef struct zebra_info *ZebraHandle;
 YAZ_EXPORT ZebraHandle zebra_open (const char *configName);
 
 /* Search using RPN-Query */
 YAZ_EXPORT ZebraHandle zebra_open (const char *configName);
 
 /* Search using RPN-Query */
-YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR stream, ODR decode,
+YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
                        Z_RPNQuery *query, int num_bases, char **basenames, 
                       const char *setname);
 
                        Z_RPNQuery *query, int num_bases, char **basenames, 
                       const char *setname);
 
index 280b167..710a699 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zrpn.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zrpn.c,v $
- * Revision 1.85  1998-09-22 10:03:43  adam
+ * Revision 1.86  1998-09-22 10:48:20  adam
+ * Minor changes in search API.
+ *
+ * Revision 1.85  1998/09/22 10:03:43  adam
  * Changed result sets to be persistent in the sense that they can
  * be re-searched if needed.
  * Fixed memory leak in rsm_or.
  * Changed result sets to be persistent in the sense that they can
  * be re-searched if needed.
  * Fixed memory leak in rsm_or.
@@ -2037,8 +2040,6 @@ RSET rpn_search (ZebraHandle zh, NMEM nmem,
     Z_SortKeySpecList *sort_sequence;
     int sort_status, i;
 
     Z_SortKeySpecList *sort_sequence;
     int sort_status, i;
 
-    zlog_rpn (rpn);
-
     zh->errCode = 0;
     zh->errString = NULL;
     zh->hits = 0;
     zh->errCode = 0;
     zh->errString = NULL;
     zh->hits = 0;
index e3115d6..52ba4f5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.63  1998-09-02 13:53:21  adam
+ * Revision 1.64  1998-09-22 10:48:21  adam
+ * Minor changes in search API.
+ *
+ * Revision 1.63  1998/09/02 13:53:21  adam
  * Extra parameter decode added to search routines to implement
  * persistent queries.
  *
  * Extra parameter decode added to search routines to implement
  * persistent queries.
  *
@@ -307,7 +310,7 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd)
     switch (q->query->which)
     {
     case Z_Query_type_1: case Z_Query_type_101:
     switch (q->query->which)
     {
     case Z_Query_type_1: case Z_Query_type_101:
-       zebra_search_rpn (zh, q->stream, q->decode, q->query->u.type_1,
+       zebra_search_rpn (zh, q->decode, q->stream, q->query->u.type_1,
                          q->num_bases, q->basenames, q->setname);
        r->errcode = zh->errCode;
        r->errstring = zh->errString;
                          q->num_bases, q->basenames, q->setname);
        r->errcode = zh->errCode;
        r->errstring = zh->errString;
index 09d6d4e..0935fe1 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zsets.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zsets.c,v $
- * Revision 1.18  1998-09-22 10:03:45  adam
+ * Revision 1.19  1998-09-22 10:48:22  adam
+ * Minor changes in search API.
+ *
+ * Revision 1.18  1998/09/22 10:03:45  adam
  * Changed result sets to be persistent in the sense that they can
  * be re-searched if needed.
  * Fixed memory leak in rsm_or.
  * Changed result sets to be persistent in the sense that they can
  * be re-searched if needed.
  * Fixed memory leak in rsm_or.
@@ -109,7 +112,7 @@ struct zset_sort_info {
     struct zset_sort_entry **entries;
 };
 
     struct zset_sort_entry **entries;
 };
 
-ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
+ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output,
                          Z_RPNQuery *rpn, int num_bases, char **basenames, 
                          const char *setname)
 {
                          Z_RPNQuery *rpn, int num_bases, char **basenames, 
                          const char *setname)
 {
@@ -127,9 +130,9 @@ ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
     zebraSet->rpn = 0;
     zebraSet->num_bases = num_bases;
     zebraSet->basenames = basenames;
     zebraSet->rpn = 0;
     zebraSet->num_bases = num_bases;
     zebraSet->basenames = basenames;
-    zebraSet->nmem = odr_extract_mem (decode);
+    zebraSet->nmem = odr_extract_mem (input);
 
 
-    zebraSet->rset = rpn_search (zh, stream->mem, rpn,
+    zebraSet->rset = rpn_search (zh, output->mem, rpn,
                                  zebraSet->num_bases,
                                 zebraSet->basenames, zebraSet->name,
                                 zebraSet);
                                  zebraSet->num_bases,
                                 zebraSet->basenames, zebraSet->name,
                                 zebraSet);