log number of records processed, etc
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 15 Apr 2002 14:05:43 +0000 (14:05 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 15 Apr 2002 14:05:43 +0000 (14:05 +0000)
index/extract.c
index/index.h
index/zebraapi.c

index 09e9009..ce51945 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: extract.c,v 1.116 2002-04-13 18:16:43 adam Exp $
+ * $Id: extract.c,v 1.117 2002-04-15 14:05:43 adam Exp $
  */
 #include <stdio.h>
 #include <assert.h>
 #define PRINTF_OFF_T "%ld"
 #endif
 
-static int records_inserted = 0;
-static int records_updated = 0;
-static int records_deleted = 0;
-static int records_processed = 0;
-
-static void logRecord (int showFlag)
+static void logRecord (ZebraHandle zh)
 {
-    if (!showFlag)
-        ++records_processed;
-    if (showFlag || !(records_processed % 1000))
+    ++zh->records_processed;
+    if (!(zh->records_processed % 1000))
     {
         logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d", 
-              records_processed, records_inserted, records_updated,
-              records_deleted);
+              zh->records_processed, zh->records_inserted, zh->records_updated,
+              zh->records_deleted);
     }
 }
 
@@ -458,7 +452,7 @@ static int recordExtract (ZebraHandle zh,
        {
             /* error occured during extraction ... */
             if (rGroup->flagRw &&
-               records_processed < rGroup->fileVerboseLimit)
+               zh->records_processed < rGroup->fileVerboseLimit)
             {
                 logf (LOG_WARN, "fail %s %s " PRINTF_OFF_T, rGroup->recordType,
                       fname, recordOffset);
@@ -515,7 +509,7 @@ static int recordExtract (ZebraHandle zh,
             logf (LOG_WARN, "cannot delete record above (seems new)");
             return 1;
         }
-        if (records_processed < rGroup->fileVerboseLimit)
+        if (zh->records_processed < rGroup->fileVerboseLimit)
             logf (LOG_LOG, "add %s %s " PRINTF_OFF_T, rGroup->recordType,
                   fname, recordOffset);
         rec = rec_new (zh->reg->records);
@@ -531,7 +525,7 @@ static int recordExtract (ZebraHandle zh,
         extract_flushRecordKeys (zh, *sysno, 1, &zh->reg->keys);
        extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
 
-        records_inserted++;
+        zh->records_inserted++;
     }
     else
     {
@@ -550,7 +544,7 @@ static int recordExtract (ZebraHandle zh,
                  fname, recordOffset);
            extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
            rec_rm (&rec);
-           logRecord (0);
+           logRecord (zh);
            return 1;
        }
         delkeys.buf_used = rec->size[recInfo_delKeys];
@@ -568,16 +562,16 @@ static int recordExtract (ZebraHandle zh,
             }
             else
             {
-                if (records_processed < rGroup->fileVerboseLimit)
+                if (zh->records_processed < rGroup->fileVerboseLimit)
                     logf (LOG_LOG, "delete %s %s " PRINTF_OFF_T,
                          rGroup->recordType, fname, recordOffset);
-                records_deleted++;
+                zh->records_deleted++;
                 if (matchStr)
                     dict_delete (zh->reg->matchDict, matchStr);
                 rec_del (zh->reg->records, &rec);
             }
            rec_rm (&rec);
-            logRecord (0);
+            logRecord (zh);
             return 1;
         }
         else
@@ -591,11 +585,11 @@ static int recordExtract (ZebraHandle zh,
             }
             else
             {
-                if (records_processed < rGroup->fileVerboseLimit)
+                if (zh->records_processed < rGroup->fileVerboseLimit)
                     logf (LOG_LOG, "update %s %s " PRINTF_OFF_T,
                         rGroup->recordType, fname, recordOffset);
                 extract_flushRecordKeys (zh, *sysno, 1, &zh->reg->keys);
-                records_updated++;
+                zh->records_updated++;
             }
         }
     }
@@ -680,7 +674,7 @@ static int recordExtract (ZebraHandle zh,
     
     /* commit this record */
     rec_put (zh->reg->records, &rec);
-    logRecord (0);
+    logRecord (zh);
     return 1;
 }
 
@@ -729,7 +723,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
     }
     if (!rGroup->recordType)
     {
-        if (records_processed < rGroup->fileVerboseLimit)
+        if (zh->records_processed < rGroup->fileVerboseLimit)
             logf (LOG_LOG, "? %s", fname);
         return 0;
     }
@@ -927,7 +921,7 @@ int extract_rec_in_mem (ZebraHandle zh, const char *recordType,
        yaz_log (LOG_WARN, "extract error");
 #else
        if (rGroup->flagRw &&
-           records_processed < rGroup->fileVerboseLimit)
+           zh->records_processed < rGroup->fileVerboseLimit)
        {
            logf (LOG_WARN, "fail %s %s %ld", rGroup->recordType,
                  fname, (long) recordOffset);
index d00d58d..12703d2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2002, Index Data
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto
- * $Id: index.h,v 1.80 2002-04-15 13:48:10 adam Exp $
+ * $Id: index.h,v 1.81 2002-04-15 14:05:43 adam Exp $
  */
 
 #ifndef INDEX_H
@@ -274,6 +274,12 @@ struct zebra_session {
 #endif
     struct recordGroup rGroup;
     int  shadow_enable;
+
+    int records_inserted;
+    int records_updated;
+    int records_deleted;
+    int records_processed;
+
 };
 
 struct rank_control {
index 7d1eac2..ecc2b32 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2002, Index Data
  * All rights reserved.
  *
- * $Id: zebraapi.c,v 1.55 2002-04-15 13:48:11 adam Exp $
+ * $Id: zebraapi.c,v 1.56 2002-04-15 14:05:43 adam Exp $
  */
 
 #include <assert.h>
@@ -384,7 +384,7 @@ void zebra_close (ZebraHandle zh)
     zebra_mutex_cond_unlock (&zs->session_lock);
     xfree (zh->reg_name);
     xfree (zh);
-    yaz_log (LOG_LOG, "zebra_close zh=%p end", zh);}
+}
 
 struct map_baseinfo {
     ZebraHandle zh;
@@ -998,6 +998,12 @@ void zebra_begin_trans (ZebraHandle zh)
     }
     
     yaz_log (LOG_LOG, "zebra_begin_trans");
+
+    zh->records_inserted = 0;
+    zh->records_updated = 0;
+    zh->records_deleted = 0;
+    zh->records_processed = 0;
+
 #if HAVE_SYS_TIMES_H
     times (&zh->tms1);
 #endif
@@ -1078,6 +1084,11 @@ void zebra_end_trans (ZebraHandle zh)
     zebra_register_close (zh->service, zh->reg);
     zh->reg = 0;
 
+    
+    yaz_log (LOG_LOG, "Records: %7d i/u/d %d/%d/%d", 
+             zh->records_processed, zh->records_inserted,
+             zh->records_updated, zh->records_deleted);
+
     zebra_get_state (zh, &val, &seqno);
     if (val != 'd')
     {