Use zint for numbers in update statistics.
[idzebra-moved-to-github.git] / index / kinput.c
index 8f0a52b..44c44ea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kinput.c,v 1.78 2006-11-21 14:32:38 adam Exp $
+/* $Id: kinput.c,v 1.80 2006-12-06 22:52:38 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -55,7 +55,7 @@ struct key_file {
     Res res;
 };
 
-#if 0
+#if 1
 static void pkey(const char *b, int mode)
 {
     key_logdump_txt(YLOG_LOG, b, mode ? "i" : "d");
@@ -225,11 +225,11 @@ struct heap_info {
     struct zebra_register *reg;
     ZebraHandle zh;
     int raw_reading; /* 1=raw /mem read. 0=file reading */
-    int no_diffs;
-    int no_updates;
-    int no_deletions;
-    int no_insertions;
-    int no_iterations;
+    zint no_diffs;
+    zint no_updates;
+    zint no_deletions;
+    zint no_insertions;
+    zint no_iterations;
 };
 
 static struct heap_info *key_heap_malloc(void)
@@ -372,29 +372,29 @@ static int heap_read_one (struct heap_info *hi, char *name, char *key)
 #define PR_KEY_LOW 0
 #define PR_KEY_TOP 0
 
-#if 0
 /* for debugging only */
-static void print_dict_item(ZebraHandle zh, const char *s)
+void zebra_log_dict_entry(ZebraHandle zh, const char *s)
 {
     char dst[IT_MAX_WORD+1];
     int ord;
     int len = key_SU_decode(&ord, (const unsigned char *) s);
     int index_type;
-    const char *db = 0;
 
     if (!zh)
         yaz_log(YLOG_LOG, "ord=%d", ord);
     else
     {
-        zebraExplain_lookup_ord (zh->reg->zei,
-                            ord, &index_type, &db, 0, 0, 0);
+        const char *string_index;
+        const char *db = 0;
+        zebraExplain_lookup_ord(zh->reg->zei,
+                                ord, &index_type, &db, &string_index);
 
         zebra_term_untrans(zh, index_type, dst, s + len);
 
-        yaz_log(YLOG_LOG, "ord=%d term=%s", ord, dst);
+        yaz_log(YLOG_LOG, "ord=%d index_type=%c index=%s term=%s",
+                ord, index_type, string_index, dst);
     }
 }
-#endif
 
 struct heap_cread_info {
     char prev_name[INP_NAME_MAX];
@@ -522,6 +522,7 @@ int heap_cread_item (void *vp, char **dst, int *insertMode)
         *insertMode = p->key[0];
         memcpy (*dst, p->key+1, sizeof(struct it_key));
 #if PR_KEY_LOW
+        zebra_log_dict_entry(hi->zh, p->cur_name);
         pkey(*dst, *insertMode);
 #endif
         (*dst) += sizeof(struct it_key);
@@ -539,6 +540,7 @@ int heap_cread_item (void *vp, char **dst, int *insertMode)
     *insertMode = p->key[0];
     memcpy (*dst, p->key+1, sizeof(struct it_key));
 #if PR_KEY_LOW
+    zebra_log_dict_entry(hi->zh, p->cur_name);
     pkey(*dst, *insertMode);
 #endif
     (*dst) += sizeof(struct it_key);
@@ -633,7 +635,7 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi)
 
 #if 0
        assert(hi->zh);
-        print_dict_item(hi->zh, hci->cur_name);
+        zebra_log_dict_entry(hi->zh, hci->cur_name);
 #endif
         if ((dict_info = dict_lookup (hi->reg->dict, hci->cur_name)))
         {
@@ -816,11 +818,11 @@ void zebra_index_merge (ZebraHandle zh)
     xfree (kf);
     if (hi->no_iterations)
     { /* do not log if nothing happened */
-        yaz_log(YLOG_LOG, "Iterations . . .%7d", hi->no_iterations);
-        yaz_log(YLOG_LOG, "Distinct words .%7d", hi->no_diffs);
-        yaz_log(YLOG_LOG, "Updates. . . . .%7d", hi->no_updates);
-        yaz_log(YLOG_LOG, "Deletions. . . .%7d", hi->no_deletions);
-        yaz_log(YLOG_LOG, "Insertions . . .%7d", hi->no_insertions);
+        yaz_log(YLOG_LOG, "Iterations     %9" ZINT_FORMAT0, hi->no_iterations);
+        yaz_log(YLOG_LOG, "Distinct words %9" ZINT_FORMAT0, hi->no_diffs);
+        yaz_log(YLOG_LOG, "Updates        %9" ZINT_FORMAT0, hi->no_updates);
+        yaz_log(YLOG_LOG, "Deletions      %9" ZINT_FORMAT0, hi->no_deletions);
+        yaz_log(YLOG_LOG, "Insertions     %9" ZINT_FORMAT0, hi->no_insertions);
     }
     key_block_destroy(&zh->reg->key_block);
     key_heap_destroy(hi, nkeys);