From f6fb80f1dfd9b1a486595496a0f43aaeb16f7b40 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Mon, 20 Sep 1999 15:48:06 +0000 Subject: [PATCH] Small changes --- isamc/isamd-p.h | 15 +++++---- isamc/isamd.c | 47 +++++++++++++++------------ isamc/merge-d.c | 95 +++++++++++++++++++++++++++++++------------------------ 3 files changed, 89 insertions(+), 68 deletions(-) diff --git a/isamc/isamd-p.h b/isamc/isamd-p.h index c27a78e..843a183 100644 --- a/isamc/isamd-p.h +++ b/isamc/isamd-p.h @@ -1,4 +1,4 @@ -/* $Id: isamd-p.h,v 1.6 1999-08-25 18:09:23 heikki Exp $ +/* $Id: isamd-p.h,v 1.7 1999-09-20 15:48:06 heikki Exp $ * Copyright (c) 1995-1996, Index Data. * See the file LICENSE for details. * Heikki Levanto @@ -72,8 +72,8 @@ struct ISAMD_PP_s { int cat; /* category of this block */ int pos; /* block number of this block */ int next; /* number of the next block */ - int diffs; /* either block or offset (in head) of start of diffs */ - /* will not be used in the improved version! */ + int diffs; /* not used in the modern isam-d, but kept for stats compatibility */ + /* never stored on disk, though */ ISAMD is; void *decodeClientData; /* delta-encoder's own data */ ISAMD_DIFF diffinfo; @@ -86,9 +86,9 @@ struct ISAMD_PP_s { /* == 8 */ #define ISAMD_BLOCK_OFFSET_1 (sizeof(int) + \ sizeof(ISAMD_BLOCK_SIZE) + \ - sizeof(int) + \ sizeof(ISAMD_BLOCK_SIZE)) -/* == 16 */ +/* == 12 (was 16) */ +// sizeof(int) + int isamd_alloc_block (ISAMD is, int cat); @@ -105,7 +105,10 @@ void isamd_free_diffs(ISAMD_PP pp); /* * $Log: isamd-p.h,v $ - * Revision 1.6 1999-08-25 18:09:23 heikki + * Revision 1.7 1999-09-20 15:48:06 heikki + * Small changes + * + * Revision 1.6 1999/08/25 18:09:23 heikki * Starting to optimize * * Revision 1.5 1999/08/20 12:25:58 heikki diff --git a/isamc/isamd.c b/isamc/isamd.c index 8e711ae..c15d7c7 100644 --- a/isamc/isamd.c +++ b/isamc/isamd.c @@ -1,7 +1,7 @@ /* * Copyright (c) 1995-1998, Index Data. * See the file LICENSE for details. - * $Id: isamd.c,v 1.12 1999-09-13 13:28:28 heikki Exp $ + * $Id: isamd.c,v 1.13 1999-09-20 15:48:06 heikki Exp $ * * Isamd - isam with diffs * Programmed by: Heikki Levanto @@ -493,7 +493,7 @@ ISAMD_PP isamd_pp_open (ISAMD is, ISAMD_P ipos) pp->is = is; pp->decodeClientData = (*is->method->code_start)(ISAMD_DECODE); pp->numKeys = 0; - pp->diffs=0; +// pp->diffs=0; pp->diffbuf=0; pp->diffinfo=0; @@ -507,18 +507,18 @@ ISAMD_PP isamd_pp_open (ISAMD is, ISAMD_P ipos) src += sizeof(pp->size); memcpy (&pp->numKeys, src, sizeof(pp->numKeys)); src += sizeof(pp->numKeys); - memcpy (&pp->diffs, src, sizeof(pp->diffs)); - src += sizeof(pp->diffs); +// memcpy (&pp->diffs, src, sizeof(pp->diffs)); +// src += sizeof(pp->diffs); assert (pp->next != pp->pos); pp->offset = src - pp->buf; assert (pp->offset == ISAMD_BLOCK_OFFSET_1); - if (0==pp->diffs) - ++(is->files[pp->cat].no_op_nodiff); - else - if(pp->diffs&1) - ++(is->files[pp->cat].no_op_extdiff); - else - ++(is->files[pp->cat].no_op_intdiff); +// if (0==pp->diffs) +// ++(is->files[pp->cat].no_op_nodiff); +// else +// if(pp->diffs&1) +// ++(is->files[pp->cat].no_op_extdiff); +// else +// ++(is->files[pp->cat].no_op_intdiff); // if (!pp->diffbuf) // pp->diffbuf=pp->buf; } @@ -543,15 +543,14 @@ void isamd_buildfirstblock(ISAMD_PP pp){ dst += sizeof(pp->size); memcpy(dst, &pp->numKeys, sizeof(pp->numKeys)); dst += sizeof(pp->numKeys); - memcpy(dst, &pp->diffs, sizeof(pp->diffs)); - dst += sizeof(pp->diffs); +// memcpy(dst, &pp->diffs, sizeof(pp->diffs)); +// dst += sizeof(pp->diffs); assert (dst - pp->buf == ISAMD_BLOCK_OFFSET_1); if (pp->is->method->debug > 5) - logf (LOG_LOG, "isamd: first: sz=%d p=%d/%d>%d/%d nk=%d d=%d", - pp->size, - pp->cat, pp->pos, - isamd_type(pp->next), isamd_block(pp->next), - pp->numKeys, pp->diffs); + logf (LOG_LOG, "isamd: bldfirst: p=%d=%d:%d n=%d:%d:%d sz=%d nk=%d ", + isamd_addr(pp->pos,pp->cat),pp->cat, pp->pos, + pp->next, isamd_type(pp->next), isamd_block(pp->next), + pp->size, pp->numKeys); } void isamd_buildlaterblock(ISAMD_PP pp){ @@ -685,12 +684,14 @@ void isamd_pp_dump (ISAMD is, ISAMD_P ipos) int diffmax=1; int diffidx; char hexbuff[64]; + int olddebug= is->method->debug; + is->method->debug=0; /* no debug logs while reading for dump */ logf(LOG_LOG,"dumping isamd block %d (%d:%d)", (int)ipos, isamd_type(ipos), isamd_block(ipos) ); pp=isamd_pp_open(is,ipos); - logf(LOG_LOG,"numKeys=%d, ofs=%d sz=%d d=%d", - pp->numKeys, pp->offset, pp->size, pp->diffs); + logf(LOG_LOG,"numKeys=%d, ofs=%d sz=%d", + pp->numKeys, pp->offset, pp->size ); diffidx=oldoffs= pp->offset; while ((diffidx < is->method->filecat[pp->cat].bsize) && (diffmax>0)) { @@ -731,11 +732,15 @@ void isamd_pp_dump (ISAMD is, ISAMD_P ipos) } /*!*/ /*TODO: dump diffs too!!! */ isamd_pp_close(pp); + is->method->debug=olddebug; } /* dump */ /* * $Log: isamd.c,v $ - * Revision 1.12 1999-09-13 13:28:28 heikki + * Revision 1.13 1999-09-20 15:48:06 heikki + * Small changes + * + * Revision 1.12 1999/09/13 13:28:28 heikki * isam-d optimizing: merging input data in the same go * * Revision 1.11 1999/08/25 18:09:24 heikki diff --git a/isamc/merge-d.c b/isamc/merge-d.c index e31adaa..317818f 100644 --- a/isamc/merge-d.c +++ b/isamc/merge-d.c @@ -3,7 +3,10 @@ * See the file LICENSE for details. * Heikki Levanto * - * $Id: merge-d.c,v 1.19 1999-09-13 13:28:28 heikki Exp $ + * $Id: merge-d.c,v 1.20 1999-09-20 15:48:06 heikki Exp $ + * + * bugs + * (none) * * missing * @@ -11,25 +14,12 @@ * - Input filter: Eliminate del-ins pairs, tell if only one entry (or none) * - single-entry optimizing (keep the one entry in the dict, no block) * - study and optimize block sizes (later) - * - Clean up the different ways diffs are handled in writing and reading - * - Keep a merge-count in the firstpp, and if the block has already been - * merged, reduce it to a larger size even if it could fit in a small one! - * - Keep minimum freespace in the category table, and use that in reduce! - * - pass a space-needed for separateDiffBlock and reduce to be able to - * reserve more room for diffs, or to force a separate (larger?) block - * - Idea: Simplify the structure, so that the first block is always diffs. - * On small blocks, that is all we have. Once a block has been merged, we - * allocate the first main block and a (new) firstblock ffor diffs. From - * that point on the word has two blocks for it. - * - On allocating more blocks (in append), check the order of blocks, and - * if needed, swap them. - * - In merge, merge also with the input data. + * - find a way to decide the size of an empty diffblock (after merge) + * - On allocating more blocks (in append and merge), check the order of + * blocks, and if needed, swap them. * - Write a routine to save/load indexes into a block, save only as many * bytes as needed (size, diff, diffindexes) * - * bugs - * - Some confusion about opening pp's, how to set offset etc. Maybe it'd be - * best to load both diffs and first main block? * * caveat * There is a confusion about the block addresses. cat or type is the category, @@ -131,6 +121,48 @@ struct ISAMD_DIFF_s { #define DT_INPU 3 // input data to be merged #define DT_DONE 4 // done with all input here + + +/*************************************************************** + * Input preprocess filter + ***************************************************************/ + +struct ISAMD_FILTER_s { + ISAMD_I data; /* where the data comes from */ + struct it_key k1; /* the next item to be returned */ + struct it_key k2; /* the one after that */ +}; + +static void init_filter( ISAMD_I data ) +{ +} + +static void close_filter () +{ +} + +static int filter_read( struct it_key *k) +{ + return 0; +} + +static int filter_empty() +{ + return 0; +} + +static int filter_only_one() +{ + return 0; +} + + +/*************************************************************** + * General support routines + ***************************************************************/ + + + static char *hexdump(unsigned char *p, int len, char *buff) { static char localbuff[128]; char bytebuff[8]; @@ -145,30 +177,8 @@ static char *hexdump(unsigned char *p, int len, char *buff) { return buff; } -/*************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - *************************************************************** - ***************************************************************/ -/*************************************************************** - * General support routines - ***************************************************************/ - 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 */ @@ -762,7 +772,7 @@ static int merge ( ISAMD_PP firstpp, /* first pp (with diffs) */ } /* while read */ - firstpp->diffs=0; +// firstpp->diffs=0; isamd_reduceblock(pp); /* reduce size if possible */ @@ -962,7 +972,10 @@ ISAMD_P isamd_append (ISAMD is, ISAMD_P ipos, ISAMD_I data) /* * $Log: merge-d.c,v $ - * Revision 1.19 1999-09-13 13:28:28 heikki + * Revision 1.20 1999-09-20 15:48:06 heikki + * Small changes + * + * Revision 1.19 1999/09/13 13:28:28 heikki * isam-d optimizing: merging input data in the same go * * Revision 1.18 1999/08/25 18:09:24 heikki -- 1.7.10.4