Optimized resultSetInsert{Rank,Sort}.
[idzebra-moved-to-github.git] / index / zebraapi.c
index de9b074..21784de 100644 (file)
@@ -3,7 +3,22 @@
  * All rights reserved.
  *
  * $Log: zebraapi.c,v $
- * Revision 1.30  2000-04-05 09:49:35  adam
+ * Revision 1.35  2000-07-07 12:49:20  adam
+ * Optimized resultSetInsert{Rank,Sort}.
+ *
+ * Revision 1.34  2000/06/09 13:56:38  ian
+ * Added some logging on Authentication and searches.
+ *
+ * Revision 1.33  2000/05/18 12:01:36  adam
+ * System call times(2) used again. More 64-bit fixes.
+ *
+ * Revision 1.32  2000/04/19 14:35:59  adam
+ * WIN32 update (this version is known not to work on Windows).
+ *
+ * Revision 1.31  2000/04/05 10:07:02  adam
+ * Minor zebra compile fix.
+ *
+ * Revision 1.30  2000/04/05 09:49:35  adam
  * On Unix, zebra/z'mbol uses automake.
  *
  * Revision 1.29  2000/03/20 19:08:36  adam
@@ -153,11 +168,21 @@ static int zebra_register_lock (ZebraHandle zh)
        zh->errCode = 1019;
        return 1;
     }
+#if HAVE_SYS_TIMES_H
+    times (&zh->tms1);
+#endif
     return 0;
 }
 
 static void zebra_register_unlock (ZebraHandle zh)
 {
+#if HAVE_SYS_TIMES_H
+    times (&zh->tms2);
+    logf (LOG_LOG, "user/system: %ld/%ld",
+                    (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
+                    (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
+
+#endif
 }
 
 ZebraHandle zebra_open (ZebraService zs)
@@ -166,10 +191,7 @@ ZebraHandle zebra_open (ZebraService zs)
 
     assert (zs);
     if (zs->stop_flag)
-    {
-       zh->errCode = 1019;
        return 0;
-    }
 
     zh = (ZebraHandle) xmalloc (sizeof(*zh));
 
@@ -188,6 +210,9 @@ ZebraHandle zebra_open (ZebraService zs)
     zs->sessions = zh;
 
     zebra_mutex_cond_unlock (&zs->session_lock);
+
+    logf(LOG_APP,"CONNECT:");
+
     return zh;
 }
 
@@ -244,9 +269,11 @@ static int zebra_register_activate (ZebraService zh)
     zh->dict = 0;
     zh->sortIdx = 0;
     zh->isams = 0;
+#if ZMBOL
     zh->isam = 0;
     zh->isamc = 0;
     zh->isamd = 0;
+#endif
     zh->zei = 0;
     
     zebraRankInstall (zh, rank1_class);
@@ -267,7 +294,7 @@ static int zebra_register_activate (ZebraService zh)
        logf (LOG_WARN, "rec_open");
        return -1;
     }
-    if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 40, 1, 0)))
+    if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 80, 1, 0)))
     {
        logf (LOG_WARN, "dict_open");
        return -1;
@@ -363,7 +390,7 @@ static int zebra_register_deactivate (ZebraService zh)
     zebra_chdir (zh);
     if (zh->records)
     {
-        zebraExplain_close (zh->zei, 1);
+        zebraExplain_close (zh->zei, 0);
         dict_close (zh->dict);
        sortIdx_close (zh->sortIdx);
        if (zh->isams)
@@ -517,6 +544,8 @@ void zebra_search_rpn (ZebraHandle zh, ODR stream, ODR decode,
     resultSetAddRPN (zh, stream, decode, query, num_bases, basenames, setname);
 
     zebra_register_unlock (zh);
+
+    logf(LOG_APP,"SEARCH:%d:",zh->hits);
 }
 
 void zebra_records_retrieve (ZebraHandle zh, ODR stream,
@@ -647,7 +676,12 @@ int zebra_hits (ZebraHandle zh)
 int zebra_auth (ZebraService zh, const char *user, const char *pass)
 {
     if (!zh->passwd_db || !passwd_db_auth (zh->passwd_db, user, pass))
+    {
+        logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS");
        return 0;
+    }
+
+    logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS");
     return 1;
 }