X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=isamb%2Fisamb.c;h=3753fd9aa50bc2ff227635b75a687a589cb2f4de;hb=4da0cd2978c9a902be772e95302e6522175402fd;hp=ebf0bd23f5319f6786bf2d09b51ebf6d2ae3439a;hpb=2e4e9c6def27f1e1463dcb6f205fab6a98054f38;p=idzebra-moved-to-github.git diff --git a/isamb/isamb.c b/isamb/isamb.c index ebf0bd2..3753fd9 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.48 2004-08-04 08:35:24 adam Exp $ +/* $Id: isamb.c,v 1.50 2004-08-06 09:43:03 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -1152,10 +1152,6 @@ int isamb_pp_read (ISAMB_PP pp, void *buf) #if NEW_FORWARD == 1 -/* -#undef ISAMB_DEBUB -#define ISAMB_DEBUG 1 -*/ static int isamb_pp_on_right_node(ISAMB_PP pp, int level, const void *untilbuf) { /* looks one node higher to see if we should be on this node at all */ /* useful in backing off quickly, and in avoiding tail descends */ @@ -1804,34 +1800,41 @@ int isamb_pp_num (ISAMB_PP pp) } static void isamb_pp_leaf_pos( ISAMB_PP pp, - int *current, int *total, void *dummybuf ) + zint *current, zint *total, void *dummybuf ) { struct ISAMB_block *p = pp->block[pp->level]; const char *src=p->bytes; char *end=p->bytes+p->size; char *cur=p->bytes+p->offset; char *dst; + void *decodeClientData; assert(p->offset <= p->size); assert(cur <= end); assert(p->leaf); *current=0; *total=0; + decodeClientData = (pp->isamb->method->codec.start)(); + while(src < end) { dst=dummybuf; - (*pp->isamb->method->codec.decode)(p->decodeClientData,&dst, &src); + (*pp->isamb->method->codec.decode)(decodeClientData,&dst, &src); assert(dst<(char*) dummybuf+100); /*FIXME */ (*total)++; if (src<=cur) (*current)++; } - logf(LOG_DEBUG, "isamb_pp_leaf_pos: cur=%d tot=%d ofs=%d sz=%d lev=%d", +#if ISAMB_DEBUG + logf(LOG_DEBUG, "isamb_pp_leaf_pos: cur="ZINT_FORMAT" tot="ZINT_FORMAT + " ofs=%d sz=%d lev=%d", *current, *total, p->offset, p->size, pp->level); +#endif assert(src==end); + (pp->isamb->method->codec.stop)(decodeClientData); } -static void isamb_pp_upper_pos( ISAMB_PP pp, int *current, int *total, - int size, int level ) +static void isamb_pp_upper_pos( ISAMB_PP pp, zint *current, zint *total, + zint size, int level ) { /* estimates total/current occurrences from here up, excl leaf */ struct ISAMB_block *p = pp->block[level]; const char *src=p->bytes; @@ -1839,11 +1842,16 @@ static void isamb_pp_upper_pos( ISAMB_PP pp, int *current, int *total, char *cur=p->bytes+p->offset; zint item_size; ISAMB_P child; + assert(level>=0); assert(!p->leaf); + +#if ISAMB_DEBUG logf(LOG_DEBUG,"isamb_pp_upper_pos at beginning l=%d " - "cur=%d tot=%d ofs=%d sz=%d pos=" ZINT_FORMAT, + "cur="ZINT_FORMAT" tot="ZINT_FORMAT + " ofs=%d sz=%d pos=" ZINT_FORMAT, level, *current, *total, p->offset, p->size, p->pos); +#endif assert (p->offset <= p->size); decode_ptr (&src, &child ); /* first child */ while(src < end) { @@ -1861,7 +1869,7 @@ static void isamb_pp_upper_pos( ISAMB_PP pp, int *current, int *total, isamb_pp_upper_pos(pp, current, total, *total, level-1); } /* upper_pos */ -void isamb_pp_pos( ISAMB_PP pp, int *current, int *total ) +void isamb_pp_pos( ISAMB_PP pp, zint *current, zint *total ) { /* return an estimate of the current position and of the total number of */ /* occureences in the isam tree, based on the current leaf */ struct ISAMB_block *p = pp->block[pp->level]; @@ -1872,8 +1880,4 @@ void isamb_pp_pos( ISAMB_PP pp, int *current, int *total ) isamb_pp_leaf_pos(pp,current, total, dummy); if (pp->level>0) isamb_pp_upper_pos(pp, current, total, *total, pp->level-1); - /* - logf(LOG_DEBUG,"isamb_pp_pos: C=%d T=%d =%6.2f%%", - *current, *total, 100.0*(*current)/(*total)); - */ }