From 05259bf944ff61befc9bee89b7377bf365b25099 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 1 Jun 2004 12:56:38 +0000 Subject: [PATCH] New method log_item for the various isams to print log an item (for debug) --- include/isamb.h | 4 ++-- include/isamc.h | 5 +++-- include/isamd.h | 5 ++--- include/isams.h | 5 +++-- index/kcompare.c | 5 ++++- isamb/isamb.c | 33 ++++++++++++++++++++++----------- isamc/isamc.c | 3 ++- isamc/isamd.c | 3 ++- isams/isams.c | 3 ++- 9 files changed, 42 insertions(+), 24 deletions(-) diff --git a/include/isamb.h b/include/isamb.h index 6853be8..849ed24 100644 --- a/include/isamb.h +++ b/include/isamb.h @@ -1,5 +1,5 @@ -/* $Id: isamb.h,v 1.7 2004-06-01 12:32:18 heikki Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 +/* $Id: isamb.h,v 1.8 2004-06-01 12:56:38 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. diff --git a/include/isamc.h b/include/isamc.h index a3ecb56..61ba2d2 100644 --- a/include/isamc.h +++ b/include/isamc.h @@ -1,5 +1,5 @@ -/* $Id: isamc.h,v 1.11 2003-06-23 15:36:11 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 +/* $Id: isamc.h,v 1.12 2004-06-01 12:56:38 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -46,6 +46,7 @@ typedef struct ISAMC_M_s { ISAMC_filecat filecat; int (*compare_item)(const void *a, const void *b); + void (*log_item)(int logmask, const void *p, const char *txt); #define ISAMC_DECODE 0 #define ISAMC_ENCODE 1 diff --git a/include/isamd.h b/include/isamd.h index 380916f..d252a2f 100644 --- a/include/isamd.h +++ b/include/isamd.h @@ -1,5 +1,5 @@ /* $Id$ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -20,8 +20,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #ifndef ISAMD_H #define ISAMD_H @@ -42,6 +40,7 @@ typedef struct ISAMD_M_s { ISAMD_filecat filecat; int (*compare_item)(const void *a, const void *b); + void (*log_item)(int logmask, const void *p, const char *txt); #define ISAMD_DECODE 0 #define ISAMD_ENCODE 1 diff --git a/include/isams.h b/include/isams.h index 925175b..92c3160 100644 --- a/include/isams.h +++ b/include/isams.h @@ -1,5 +1,5 @@ -/* $Id: isams.h,v 1.4 2003-06-23 15:36:11 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 +/* $Id: isams.h,v 1.5 2004-06-01 12:56:38 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -36,6 +36,7 @@ typedef struct ISAMS_PP_s *ISAMS_PP; typedef struct ISAMS_M_s { int (*compare_item)(const void *a, const void *b); + void (*log_item)(int logmask, const void *p, const char *txt); #define ISAMC_DECODE 0 #define ISAMC_ENCODE 1 diff --git a/index/kcompare.c b/index/kcompare.c index da5da65..82e9491 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -1,4 +1,4 @@ -/* $Id: kcompare.c,v 1.43 2004-06-01 12:32:18 heikki Exp $ +/* $Id: kcompare.c,v 1.44 2004-06-01 12:56:38 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -262,6 +262,7 @@ ISAMS_M *key_isams_m (Res res, ISAMS_M *me) isams_getmethod (me); me->compare_item = key_compare; + me->log_item = key_logdump_txt; me->code_start = iscz1_code_start; me->code_item = iscz1_code_item; @@ -277,6 +278,7 @@ ISAMC_M *key_isamc_m (Res res, ISAMC_M *me) isc_getmethod (me); me->compare_item = key_compare; + me->log_item = key_logdump_txt; me->code_start = iscz1_code_start; me->code_item = iscz1_code_item; @@ -293,6 +295,7 @@ ISAMD_M *key_isamd_m (Res res, ISAMD_M *me) me = isamd_getmethod (me); me->compare_item = key_compare; + me->log_item = key_logdump_txt; me->code_start = iscz1_code_start; me->code_item = iscz1_code_item; diff --git a/isamb/isamb.c b/isamb/isamb.c index 8e517e0..c732143 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.29 2004-06-01 12:32:19 heikki Exp $ +/* $Id: isamb.c,v 1.30 2004-06-01 12:56:38 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -25,7 +25,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include -#include <../index/index.h> /* for log_keydump. Debugging only */ struct ISAMB_head { int first_block; @@ -1103,8 +1102,10 @@ int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf) if (!p) return 0; logf(LOG_DEBUG,"isamb_pp_forward starting [%p] p=%d",pp,p->pos); - key_logdump_txt(LOG_DEBUG, untilbuf," until"); - key_logdump_txt(LOG_DEBUG, buf, " buf"); + + (*pp->isamb->method->log_item)(LOG_DEBUG, untilbuf, "until"); + (*pp->isamb->method->log_item)(LOG_DEBUG, buf, "buf"); + while (1) { while ( p->offset == p->size) @@ -1128,7 +1129,10 @@ int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf) { src = p->bytes + p->offset; decode_ptr(&src, &item_len); - key_logdump_txt(LOG_DEBUG, src, " isamb_pp_forward climb skipping old key"); + + (*pp->isamb->method->log_item)(LOG_DEBUG, src, + " isamb_pp_forward " + "climb skipping old key"); src += item_len; decode_ptr(&src,&pos); p->offset = src - (char*) p->bytes; @@ -1147,7 +1151,9 @@ int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf) decode_ptr(&src, &item_len); logf(LOG_DEBUG,"isamb_pp_forward (B) on a high node. ofs=%d sz=%d nxtpos=%d ", p->offset,p->size,pos); - key_logdump(LOG_DEBUG, src); + + + (*pp->isamb->method->log_item)(LOG_DEBUG, src, ""); if (untilbuf) cmp=(*pp->isamb->method->compare_item)(untilbuf,src); else @@ -1200,15 +1206,20 @@ int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf) cmp=-2; logf(LOG_DEBUG,"isamb_pp_forward on a leaf. cmp=%d", cmp); - key_logdump(LOG_DEBUG, buf); + (*pp->isamb->method->log_item)(LOG_DEBUG, buf, ""); + if (cmp <2) { if (untilbuf) - key_logdump_txt(LOG_DEBUG, buf, - "isamb_pp_forward returning 1"); + { + (*pp->isamb->method->log_item)(LOG_DEBUG, buf, + "isamb_pp_forward returning 1"); + } else - key_logdump_txt(LOG_DEBUG, buf, - "isamb_pp_read returning 1 (fwd)"); + { + (*pp->isamb->method->log_item)(LOG_DEBUG, buf, + "isamb_pp_read returning 1 (fwd)"); + } pp->returned_numbers++; return 1; } diff --git a/isamc/isamc.c b/isamc/isamc.c index 6f91fa9..9374da3 100644 --- a/isamc/isamc.c +++ b/isamc/isamc.c @@ -1,4 +1,4 @@ -/* $Id: isamc.c,v 1.23 2003-06-23 15:36:11 adam Exp $ +/* $Id: isamc.c,v 1.24 2004-06-01 12:56:39 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -66,6 +66,7 @@ void isc_getmethod (ISAMC_M *m) m->code_reset = NULL; m->compare_item = NULL; + m->log_item = NULL; m->debug = 1; diff --git a/isamc/isamd.c b/isamc/isamd.c index 37d40a3..f6d17dc 100644 --- a/isamc/isamd.c +++ b/isamc/isamd.c @@ -1,4 +1,4 @@ -/* $Id: isamd.c,v 1.26 2003-06-23 15:36:11 adam Exp $ +/* $Id: isamd.c,v 1.27 2004-06-01 12:56:39 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -87,6 +87,7 @@ ISAMD_M *isamd_getmethod (ISAMD_M *me) m->code_reset = NULL; m->compare_item = NULL; + m->log_item = NULL; m->debug = 0; /* default to no debug */ diff --git a/isams/isams.c b/isams/isams.c index a8c765c..7994294 100644 --- a/isams/isams.c +++ b/isams/isams.c @@ -1,4 +1,4 @@ -/* $Id: isams.c,v 1.4 2003-06-23 15:36:12 adam Exp $ +/* $Id: isams.c,v 1.5 2004-06-01 12:56:39 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -64,6 +64,7 @@ void isams_getmethod (ISAMS_M *m) m->code_stop = NULL; m->compare_item = NULL; + m->log_item = NULL; m->debug = 1; m->block_size = 128; -- 1.7.10.4