From 1b62315f3ba83b91a8580f72943124ba9cb09249 Mon Sep 17 00:00:00 2001 From: pop Date: Thu, 27 Feb 2003 23:08:10 +0000 Subject: [PATCH] zebra_end_trans is just calling zebra_end_transaction now: this second one is re turning transaction status (for debug/test purposes in the API) --- index/extract.c | 20 +++++++++++++------- index/zebraapi.c | 27 ++++++++++++++++++++++++--- index/zebraapi.h | 12 +++++++++++- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/index/extract.c b/index/extract.c index bf94e3f..4fb41d9 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.138 2003-02-27 22:55:40 adam Exp $ +/* $Id: extract.c,v 1.139 2003-02-27 23:08:10 pop Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -961,19 +961,25 @@ int bufferExtractRecord (ZebraHandle zh, extractCtrl.endf = zebra_record_int_end; extractCtrl.fh = &fc; + zh->reg->keys.buf_used = 0; + zh->reg->keys.prevAttrUse = -1; + zh->reg->keys.prevAttrSet = -1; + zh->reg->keys.prevSeqNo = 0; + zh->reg->sortKeys.buf_used = 0; + /* announce database */ + + if (!(rGroup->databaseName)) { + logf (LOG_WARN, "Invalid record group, no database name given"); + return 0; + } + if (zebraExplain_curDatabase (zh->reg->zei, rGroup->databaseName)) { if (zebraExplain_newDatabase (zh->reg->zei, rGroup->databaseName, 0)) return 0; } - zh->reg->keys.buf_used = 0; - zh->reg->keys.prevAttrUse = -1; - zh->reg->keys.prevAttrSet = -1; - zh->reg->keys.prevSeqNo = 0; - zh->reg->sortKeys.buf_used = 0; - if (*recordType) { logf (LOG_DEBUG, "Record type explicitly specified: %s", recordType); recType = recType_byName (zh->reg->recTypes, recordType, subType, diff --git a/index/zebraapi.c b/index/zebraapi.c index 97ac2d7..abc9124 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.85 2003-02-27 22:55:40 adam Exp $ +/* $Id: zebraapi.c,v 1.86 2003-02-27 23:08:10 pop Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -407,7 +407,6 @@ static void zebra_register_close (ZebraService zs, struct zebra_register *reg) xfree (reg->key_buf); xfree (reg->name); xfree (reg); - yaz_log(LOG_DEBUG, "zebra_register_close 2"); } void zebra_stop(ZebraService zs) @@ -1288,13 +1287,26 @@ void zebra_begin_trans (ZebraHandle zh) zh->reg->seqno = seqno; } -void zebra_end_trans (ZebraHandle zh) +void zebra_end_trans (ZebraHandle zh) { + ZebraTransactionStatus dummy; + zebra_end_transaction(zh, &dummy); +} + +void zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status) { char val; int seqno; const char *rval; + ASSERTZH; + status->processed = 0; + status->inserted = 0; + status->updated = 0; + status->deleted = 0; + status->utime = 0; + status->stime = 0; + zh->trans_no--; if (zh->trans_no != 0) return; @@ -1312,6 +1324,11 @@ void zebra_end_trans (ZebraHandle zh) zh->records_processed, zh->records_inserted, zh->records_updated, zh->records_deleted); + status->processed = zh->records_processed; + status->inserted = zh->records_inserted; + status->updated = zh->records_updated; + status->deleted = zh->records_deleted; + zebra_get_state (zh, &val, &seqno); if (val != 'd') { @@ -1333,7 +1350,11 @@ void zebra_end_trans (ZebraHandle zh) (long) (zh->tms2.tms_utime - zh->tms1.tms_utime), (long) (zh->tms2.tms_stime - zh->tms1.tms_stime)); + status->utime = (long) (zh->tms2.tms_utime - zh->tms1.tms_utime); + status->stime = (long) (zh->tms2.tms_stime - zh->tms1.tms_stime); #endif + + return; } void zebra_repository_update (ZebraHandle zh) diff --git a/index/zebraapi.h b/index/zebraapi.h index 8197db7..383d50b 100644 --- a/index/zebraapi.h +++ b/index/zebraapi.h @@ -1,4 +1,4 @@ -/* $Id: zebraapi.h,v 1.25 2003-02-11 17:28:10 heikki Exp $ +/* $Id: zebraapi.h,v 1.26 2003-02-27 23:08:10 pop Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -54,6 +54,15 @@ struct recordGroup { int followLinks; }; +typedef struct { + int processed; + int inserted; + int updated; + int deleted; + long utime; + long stime; +} ZebraTransactionStatus; + /* Retrieval Record Descriptor */ typedef struct { int errCode; /* non-zero if error when fetching this */ @@ -188,6 +197,7 @@ int zebra_admin_exchange_record (ZebraHandle zh, void zebra_begin_trans (ZebraHandle zh); void zebra_end_trans (ZebraHandle zh); +void zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat); int zebra_commit (ZebraHandle zh); -- 1.7.10.4