Using zebra_rec_keys for per-record key store
[idzebra-moved-to-github.git] / index / zserver.c
index 4456e8e..f1c92c4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zserver.c,v 1.133 2005-05-12 10:17:07 adam Exp $
+/* $Id: zserver.c,v 1.140 2005-09-13 11:51:06 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <io.h>
 #include <process.h>
 #include <sys/locking.h>
-#else
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
@@ -75,7 +76,7 @@ bend_initresult *bend_init (bend_initrequest *q)
     yaz_log (YLOG_DEBUG, "bend_init");
 
     sob = statserv_getcontrol ();
-    if (!(zh = zebra_open (sob->handle)))
+    if (!(zh = zebra_open (sob->handle, 0)))
     {
        yaz_log (YLOG_WARN, "Failed to read config `%s'", sob->configname);
        r->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
@@ -171,18 +172,15 @@ bend_initresult *bend_init (bend_initrequest *q)
     return r;
 }
 
-static void search_terms (ZebraHandle zh, bend_search_rr *r)
+static void search_terms(ZebraHandle zh, bend_search_rr *r)
 {
-    zint count = 0;
     int no_terms;
     int i;
     int type = Z_Term_general;
     struct Z_External *ext;
     Z_SearchInfoReport *sr;
 
-    /* get no of terms for result set */
-    no_terms = 0; /* zebra_resultSetTerms (zh, r->setname, 0, 0, 0, 0, 0); */
-      /* FIXME - Rsets don't know number of terms no more ??? */
+    zebra_result_set_term_no(zh, r->setname, &no_terms);
     if (!no_terms)
         return;
 
@@ -210,13 +208,15 @@ static void search_terms (ZebraHandle zh, bend_search_rr *r)
     for (i = 0; i<no_terms; i++)
     {
         Z_Term *term;
+       zint count;
+       int approx;
         char outbuf[1024];
         size_t len = sizeof(outbuf);
-        /* FIXME - Can we just skip this ??? */
-        /*
-        zebra_resultSetTerms (zh, r->setname, i,
-                              &count, &type, outbuf, &len);
-        */
+
+       zebra_result_set_term_info(zh, r->setname, i,
+                                  &count, &approx, outbuf, &len,
+                                  0 /* term_ref_id */ );
+
         sr->elements[i] = odr_malloc (r->stream, sizeof(**sr->elements));
         sr->elements[i]->subqueryId = 0;
         sr->elements[i]->fullQuery = odr_malloc (r->stream, 
@@ -311,7 +311,7 @@ int bend_fetch (void *handle, bend_fetch_rr *r)
     
     r->last_in_set = 0;
     res = zebra_records_retrieve (zh, r->stream, r->setname, r->comp,
-                           r->request_format, 1, &retrievalRecord);
+                                 r->request_format, 1, &retrievalRecord);
     if (res != ZEBRA_OK)
     {
        /* non-surrogate diagnostic */
@@ -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,
-                    &r->num_entries, &entries, &is_partial);
+                    &r->num_entries, &entries, &is_partial, 
+                    0 /* setname */);
     if (res == ZEBRA_OK)
     {
        if (is_partial)
@@ -649,9 +650,10 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr)
                        {
                             int r = zebra_admin_exchange_record (
                                 zh,
-                                rec->u.octet_aligned->buf,
+                                (const char *) rec->u.octet_aligned->buf,
                                 rec->u.octet_aligned->len,
-                                opaque_recid->buf, opaque_recid->len,
+                                (const char *) opaque_recid->buf,
+                               opaque_recid->len,
                                 action);
                             if (r)
                             {
@@ -672,7 +674,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr)
                                    &sysno,
                                    0, /* match */
                                    0, /* fname */
-                                   rec->u.octet_aligned->buf,
+                                   (const char *) rec->u.octet_aligned->buf,
                                    rec->u.octet_aligned->len,
                                    0);
                                if (r == ZEBRA_FAIL)
@@ -690,7 +692,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr)
                                    &sysno,
                                    0, /* match */
                                    0, /* fname */
-                                   rec->u.octet_aligned->buf,
+                                   (const char *) rec->u.octet_aligned->buf,
                                    rec->u.octet_aligned->len,
                                    1);
                                if (r == ZEBRA_FAIL)
@@ -707,7 +709,7 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr)
                                    &sysno,
                                    0, /* match */
                                    0, /* fname */
-                                   rec->u.octet_aligned->buf,
+                                   (const char *) rec->u.octet_aligned->buf,
                                    rec->u.octet_aligned->len,
                                    0);
                                if (r == ZEBRA_FAIL)