New feature: databases. Implemented as prefix to words in dictionary.
[idzebra-moved-to-github.git] / index / zserver.c
index b036efe..07f5961 100644 (file)
@@ -4,7 +4,22 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.14  1995-10-09 16:18:37  adam
+ * Revision 1.19  1995-10-17 18:02:11  adam
+ * New feature: databases. Implemented as prefix to words in dictionary.
+ *
+ * Revision 1.18  1995/10/16  14:03:09  quinn
+ * Changes to support element set names and espec1
+ *
+ * Revision 1.17  1995/10/16  09:32:40  adam
+ * More work on relational op.
+ *
+ * Revision 1.16  1995/10/13  12:26:44  adam
+ * Optimization of truncation.
+ *
+ * Revision 1.15  1995/10/12  12:40:55  adam
+ * Bug fixes in rpn_prox.
+ *
+ * Revision 1.14  1995/10/09  16:18:37  adam
  * Function dict_lookup_grep got extra client data parameter.
  *
  * Revision 1.13  1995/10/06  14:38:00  adam
@@ -71,33 +86,38 @@ bend_initresult *bend_init (bend_initrequest *q)
     r.errstring = 0;
     r.handle = name;
 
+    logf (LOG_DEBUG, "bend_init");
     server_info.sets = NULL;
     if (!(server_info.sys_idx_fd = open (FNAME_SYS_IDX, O_RDONLY)))
     {
+        logf (LOG_WARN|LOG_ERRNO, "sys_idx open fail");
         r.errcode = 1;
-        r.errstring = "dict_open fail: filedict";
+        r.errstring = "sys_idx open fail";
         return &r;
     }
     if (!(server_info.fileDict = dict_open (FNAME_FILE_DICT, 10, 0)))
     {
+        logf (LOG_WARN, "dict_open fail: fname dict");
         r.errcode = 1;
-        r.errstring = "dict_open fail: filedict";
+        r.errstring = "dict_open fail: fname dict";
         return &r;
     }    
     if (!(server_info.wordDict = dict_open (FNAME_WORD_DICT, 40, 0)))
     {
+        logf (LOG_WARN, "dict_open fail: word dict");
         dict_close (server_info.fileDict);
         r.errcode = 1;
-        r.errstring = "dict_open fail: worddict";
+        r.errstring = "dict_open fail: word dict";
         return &r;
     }    
     if (!(server_info.wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0,
                                           sizeof (struct it_key))))
     {
+        logf (LOG_WARN, "is_open fail: word isam");
         dict_close (server_info.wordDict);
         dict_close (server_info.fileDict);
         r.errcode = 1;
-        r.errstring = "is_open fail: wordisam";
+        r.errstring = "is_open fail: word isam";
         return &r;
     }
     server_info.odr = odr_createmem (ODR_ENCODE);
@@ -133,8 +153,9 @@ static int record_read (int fd, char *buf, size_t count)
 }
 
 static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
-                          oid_value input_format, oid_value *output_format,
-                          char **rec_bufp, int *rec_lenp)
+                          oid_value input_format, Z_RecordComposition *comp,
+                         oid_value *output_format, char **rec_bufp,
+                         int *rec_lenp)
 {
     char record_info[SYS_IDX_ENTRY_LEN];
     char *fname, *file_type;
@@ -160,17 +181,22 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
               file_type);
         exit (1);
     }
+    logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score);
     if ((retrieveCtrl.fd = open (fname, O_RDONLY)) == -1)
     {
-        logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Open record file %s", fname);
-        exit (1);
+        char *msg = "Record doesn't exist";
+        logf (LOG_WARN|LOG_ERRNO, "Retrieve: Open record file %s", fname);
+        *output_format = VAL_SUTRS;
+        *rec_bufp = msg;
+        *rec_lenp = strlen (msg);
+        return 0;     /* or 14: System error in presenting records */
     }
-    logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score);
     retrieveCtrl.localno = sysno;
     retrieveCtrl.score = score;
     retrieveCtrl.odr = stream;
     retrieveCtrl.readf = record_read;
     retrieveCtrl.input_format = retrieveCtrl.output_format = input_format;
+    retrieveCtrl.comp = comp;
     retrieveCtrl.diagnostic = 0;
     (*rt->retrieve)(&retrieveCtrl);
     *output_format = retrieveCtrl.output_format;
@@ -208,8 +234,9 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num)
         return &r;
     }
     r.errcode = record_fetch (&server_info, records[0].sysno,
-                              records[0].score, q->stream,
-                              q->format, &r.format, &r.record, &r.len);
+                              records[0].score, q->stream, q->format,
+                              q->comp, &r.format, &r.record, &r.len);
+    resultSetSysnoDel (&server_info, records, 1);
     return &r;
 }
 
@@ -230,6 +257,7 @@ bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num)
     r.term_position = q->term_position;
     r.num_entries = q->num_entries;
     r.errcode = rpn_scan (&server_info, server_info.odr, q->term,
+                          q->num_bases, q->basenames,
                           &r.term_position,
                           &r.num_entries, &r.entries, &status);
     r.status = status;