X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=isamc%2Fmerge-d.c;h=ba10b9efb1a84a505c83c953658299c774bc2558;hb=6feeb67bdd353384cc16289c7db4fcb2e62cb74f;hp=ed553df638b4cd7686023758c7e97a73801a8bdb;hpb=72ca1631366b5196106ac777e492b6a70c273651;p=idzebra-moved-to-github.git diff --git a/isamc/merge-d.c b/isamc/merge-d.c index ed553df..ba10b9e 100644 --- a/isamc/merge-d.c +++ b/isamc/merge-d.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Heikki Levanto * - * $Id: merge-d.c,v 1.24 1999-10-05 09:57:40 heikki Exp $ + * $Id: merge-d.c,v 1.26 2002-07-11 16:16:00 heikki Exp $ * * bugs * sinleton-bit has to be in the high end, not low, so as not to confuse @@ -100,7 +100,7 @@ #include #include #include -#include +#include #include "../index/index.h" #include "isamd-p.h" @@ -232,7 +232,18 @@ static int filter_only_one(FILTER F) return ( (0 != F->r1) && (0 == F->r2)); } - +/* We may need backfilling, if we read a lonely key to make */ +/* a singleton, but its bitw will not fit in. Then we need to */ +/* process it normally, which means reading it again. So we */ +/* need to unread it first. Luckily the filter is empty at that */ +/* point */ +static void filter_backfill(FILTER F, struct it_key *k, int mode) +{ + assert(F->r1 == FILTER_NOTYET ); /* not overwriting data! */ + F->k1=*k; + F->m1=mode; + F->r1=1; /* ok read */ +} /*************************************************************** @@ -1091,6 +1102,12 @@ ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data) filter_read(F,&k,&mode); assert(mode); rc = singleton_encode(&k); + if (!rc) + { + if (is->method->debug >9) + logf(LOG_LOG,"isamd_appd: singleton didn't fit, backfilling"); + filter_backfill(F,&k, mode); + } if (is->method->debug >9) logf(LOG_LOG,"isamd_appd: singleton %d (%x)", rc,rc); @@ -1122,7 +1139,14 @@ ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data) /* * $Log: merge-d.c,v $ - * Revision 1.24 1999-10-05 09:57:40 heikki + * Revision 1.26 2002-07-11 16:16:00 heikki + * Fixed a bug in isamd, failed to store a single key when its bits + * did not fit into a singleton. + * + * Revision 1.25 1999/11/30 13:48:04 adam + * Improved installation. Updated for inclusion of YAZ header files. + * + * Revision 1.24 1999/10/05 09:57:40 heikki * Tuning the isam-d (and fixed a small "detail") * * Revision 1.23 1999/09/27 14:36:36 heikki