From: Sebastian Hammer Date: Sat, 10 Feb 1996 12:20:54 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: ZEBRA.1.0~539 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=288e50e499479a436edb71358c51fb8317c26da3;p=idzebra-moved-to-github.git *** empty log message *** --- diff --git a/isam/Makefile b/isam/Makefile index 1ae4b23..4e60aef 100644 --- a/isam/Makefile +++ b/isam/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1994, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.17 1995-11-27 10:16:12 quinn Exp $ +# $Id: Makefile,v 1.18 1996-02-10 12:20:54 quinn Exp $ SHELL=/bin/sh RANLIB=ranlib @@ -29,7 +29,7 @@ isam-test: isam-test.c $(LIB) ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB) issh: issh.c $(LIB) - $(CC) -g -o issh -I../include issh.c \ + $(CC) -g -o issh $(INCLUDE) issh.c \ ../lib/isam.a ../lib/bfile.a ../lib/alexutil.a $(YAZLIB) #$(TPROG): $(TPROG).o $(LIB) diff --git a/isam/isam.c b/isam/isam.c index 4a160a8..d2edbbe 100644 --- a/isam/isam.c +++ b/isam/isam.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isam.c,v $ - * Revision 1.18 1996-02-06 10:19:56 quinn + * Revision 1.19 1996-02-10 12:20:56 quinn + * *** empty log message *** + * + * Revision 1.18 1996/02/06 10:19:56 quinn * Attempt at fixing bug. Not all blocks were read before they were unlinked * prior to a remap operation. * @@ -72,9 +75,25 @@ #include "rootblk.h" #include "keyops.h" -static int (*extcmp)(const void *p1, const void *p2); static ispt_struct *ispt_freelist = 0; +static struct +{ + int total_merge_operations; + int total_items; + int dub_items_removed; + int new_items; + int failed_deletes; + int skipped_inserts; + int delete_insert_noop; + int delete_replace; + int delete; + int remaps; + int block_jumps; + int tab_deletes; + int new_tables; +} statistics; + static ISPT ispt_alloc() { ISPT p; @@ -130,6 +149,23 @@ ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2), is_type_header th; logf (LOG_DEBUG, "is_open(%s, %s)", name, writeflag ? "RW" : "RDONLY"); + if (writeflag) + { + statistics.total_merge_operations = 0; + statistics.total_items = 0; + statistics.dub_items_removed = 0; + statistics.new_items = 0; + statistics.failed_deletes = 0; + statistics.skipped_inserts = 0; + statistics.delete_insert_noop = 0; + statistics.delete_replace = 0; + statistics.delete = 0; + statistics.remaps = 0; + statistics.new_tables = 0; + statistics.block_jumps = 0; + statistics.tab_deletes = 0; + } + new = xmalloc(sizeof(*new)); new->writeflag = writeflag; for (i = 0; i < IS_MAX_BLOCKTYPES; i++) @@ -325,6 +361,28 @@ int is_close(ISAM is) } } xfree(is); + if (is->writeflag) + { + logf(LOG_LOG, "ISAM statistics:"); + logf(LOG_LOG, "total_merge_operations %d", + statistics.total_merge_operations); + logf(LOG_LOG, "total_items %d", statistics.total_items); + logf(LOG_LOG, "dub_items_removed %d", + statistics.dub_items_removed); + logf(LOG_LOG, "new_items %d", statistics.new_items); + logf(LOG_LOG, "failed_deletes %d", + statistics.failed_deletes); + logf(LOG_LOG, "skipped_inserts %d", + statistics.skipped_inserts); + logf(LOG_LOG, "delete_insert_noop %d", + statistics.delete_insert_noop); + logf(LOG_LOG, "delete_replace %d", + statistics.delete_replace); + logf(LOG_LOG, "delete %d", statistics.delete); + logf(LOG_LOG, "remaps %d", statistics.remaps); + logf(LOG_LOG, "block_jumps %d", statistics.block_jumps); + logf(LOG_LOG, "tab_deletes %d", statistics.tab_deletes); + } return 0; } @@ -337,15 +395,6 @@ static ISAM_P is_address(int type, int pos) return r; } -int sort_input(const void *p1, const void *p2) -{ - int rs; - - if ((rs = (*extcmp)(((char *)p1) + 1, ((char *)p2) + 1))) - return rs; - return *((char *)p1) - *((char*)p2); -} - ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) { is_mtable tab; @@ -354,10 +403,11 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) int oldnum, oldtype, i; char operation, *record; - extcmp = is->cmp; -#if 0 - qsort(data, num, is_keysize(is) + 1, sort_input); -#endif + statistics.total_merge_operations++; + statistics.total_items += num; + if (!pos) + statistics.new_tables++; + is_m_establish_tab(is, &tab, pos); if (pos) if (is_m_read_full(&tab, tab.data) < 0) @@ -377,6 +427,7 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) { data += 1 + is_keysize(is); num--; + statistics.dub_items_removed++; } if ((res = is_m_seek_record(&tab, record)) > 0) /* no match */ { @@ -384,15 +435,20 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) { logf (LOG_DEBUG, "XXInserting new record."); is_m_write_record(&tab, record); + statistics.new_items++; } else + { logf (LOG_DEBUG, "XXDeletion failed to find match."); + statistics.failed_deletes++; + } } else /* match found */ { if (operation == KEYOP_INSERT) { logf (LOG_DEBUG, "XXSkipping insertion - match found."); + statistics.skipped_inserts++; continue; } else if (operation == KEYOP_DELETE) @@ -406,6 +462,14 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) logf (LOG_DEBUG, "XXNoop delete. skipping."); data += 1 + is_keysize(is); num--; + while (num && !memcmp(data, data + is_keysize(tab.is) + + 1, is_keysize(tab.is) + 1)) + { + data += 1 + is_keysize(is); + num--; + statistics.dub_items_removed++; + } + statistics.delete_insert_noop++; continue; } /* else check if next key can fit in this position */ @@ -417,11 +481,20 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) is_m_replace_record(&tab, data + 1); data += 1 + is_keysize(is); num--; + while (num && !memcmp(data, data + is_keysize(tab.is) + + 1, is_keysize(tab.is) + 1)) + { + data += 1 + is_keysize(is); + num--; + statistics.dub_items_removed++; + } + statistics.delete_replace++; continue; } } logf (LOG_DEBUG, "Deleting record."); is_m_delete_record(&tab); + statistics.delete++; } } } @@ -437,10 +510,15 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) is_m_read_full(&tab, tab.cur_mblock); is_p_unmap(&tab); tab.pos_type = i; + if (pos) + statistics.block_jumps++; } if (!oldnum || tab.pos_type != oldtype || (abs(oldnum - tab.num_records) * 100) / oldnum > tab.is->repack) + { is_p_remap(&tab); + statistics.remaps++; + } else is_p_align(&tab); if (tab.data) @@ -449,7 +527,10 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) pos = is_address(tab.pos_type, tab.data->diskpos); } else + { pos = 0; + statistics.tab_deletes++; + } is_m_release_tab(&tab); return pos; } diff --git a/isam/memory.c b/isam/memory.c index d7a327c..b5dcdfa 100644 --- a/isam/memory.c +++ b/isam/memory.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: memory.c,v $ - * Revision 1.10 1995-12-12 14:12:47 quinn + * Revision 1.11 1996-02-10 12:20:58 quinn + * *** empty log message *** + * + * Revision 1.10 1995/12/12 14:12:47 quinn * *** empty log message *** * * Revision 1.9 1995/12/06 15:48:46 quinn @@ -233,18 +236,28 @@ void is_m_delete_record(is_mtable *tab) mbuf->num--; mbuf->cur_record--; } - else /* middle of a block */ + else if (mbuf->cur_record == 1) /* beginning of mbuf */ { + mbuf->num--; + mbuf->offset +=is_keysize(tab->is); + mbuf->cur_record = 0; + } + else /* middle of mbuf */ + { + /* insert block after current one */ new = xmalloc_mbuf(IS_MBUF_TYPE_SMALL); new->next = mbuf->next; mbuf->next = new; + + /* virtually transfer everything after current record to new one. */ new->data = mbuf->data; mbuf->refcount++; new->offset = mbuf->offset + mbuf->cur_record * is_keysize(tab->is); new->num = mbuf->num - mbuf->cur_record; + + /* old buf now only contains stuff before current record */ mbuf->num = mbuf->cur_record -1; - mbuf = mbuf->next; - mbuf->cur_record = 0; + tab->cur_mblock->cur_mbuf = new; } tab->num_records--; tab->cur_mblock->num_records--;