From e7031475f0d0c08a4b994e32c9cf3258f3a7c427 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Wed, 21 Jul 1999 14:53:55 +0000 Subject: [PATCH] isamd read and write functions work, except when block full Merge missing still. Need to split some functions --- isamc/merge-d.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/isamc/merge-d.c b/isamc/merge-d.c index 13958ed..25f78ae 100644 --- a/isamc/merge-d.c +++ b/isamc/merge-d.c @@ -3,6 +3,7 @@ * See the file LICENSE for details. * Heikki Levanto * + * $Id: merge-d.c,v 1.4 1999-07-21 14:53:55 heikki Exp $ * merge-d.c: merge routines for isamd * * todo @@ -62,9 +63,15 @@ static char *hexdump(unsigned char *p, int len, char *buff) { static int separateDiffBlock(ISAMD_PP pp) { return ( 0 != pp->next); + /* Todo: This could be improved to check that there is a reasonable + amount of space in the block, or something... */ } +/************************************************************** + * Reading + **************************************************************/ + static void getDiffInfo(ISAMD_PP pp, int diffidx) { /* builds the diff info structures from a diffblock */ int maxinfos = pp->is->method->filecat[pp->cat].bsize / 5 +1; @@ -269,6 +276,11 @@ int isamd_read_item (ISAMD_PP pp, char **dst) } /* isamd_read_item */ + +/******************************************************************* + * Building main blocks (no diffs) + *******************************************************************/ + static void isamd_reduceblock(ISAMD_PP pp) /* takes a large block, and reduces its category if possible */ /* Presumably the first block in an isam-list */ @@ -290,7 +302,8 @@ static void isamd_reduceblock(ISAMD_PP pp) static int isamd_build_first_block(ISAMD is, ISAMD_I data) { - char i_item[128]; /* one input item */ + struct it_key i_key; /* input key */ + char *i_item= (char *) &i_key; /* same as char */ char *i_ptr=i_item; int i_more =1; int i_mode; /* 0 for delete, 1 for insert */ @@ -320,6 +333,8 @@ static int isamd_build_first_block(ISAMD is, ISAMD_I data) /* read first input */ i_ptr = i_item; i_more = (*data->read_item)(data->clientData, &i_ptr, &i_mode); + if (i_more) + assert( i_ptr-i_item == sizeof(i_key) ); if (is->method->debug >3) logf(LOG_LOG,"isamd: build_fi start: m=%d %s", @@ -425,6 +440,10 @@ static int isamd_build_first_block(ISAMD is, ISAMD_I data) } /* build_first_block */ +/*************************************************************** + * Appending diffs + ***************************************************************/ + static int append_diffs(ISAMD is, ISAMD_P ipos, ISAMD_I data) { @@ -571,6 +590,10 @@ static int append_diffs(ISAMD is, ISAMD_P ipos, ISAMD_I data) +/************************************************************* + * isamd_append itself, Sweet, isn't it + *************************************************************/ + ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data) { int retval=0; @@ -586,9 +609,9 @@ ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data) /* * $Log: merge-d.c,v $ - * Revision 1.3 1999-07-21 14:24:50 heikki - * isamd write and read functions ok, except when diff block full. - * (merge not yet done) + * Revision 1.4 1999-07-21 14:53:55 heikki + * isamd read and write functions work, except when block full + * Merge missing still. Need to split some functions * * Revision 1.1 1999/07/14 13:14:47 heikki * Created empty -- 1.7.10.4