-/* $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
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;
/* == 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);
/*
* $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
/*
* 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
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;
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;
}
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){
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))
{
}
/*!*/ /*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
* 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
*
* - 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,
#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];
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 */
} /* while read */
- firstpp->diffs=0;
+// firstpp->diffs=0;
isamd_reduceblock(pp); /* reduce size if possible */
/*
* $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