From 38f321eafd606e8ac91da5c1450393fed73d37f5 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Thu, 11 Jul 2002 13:03:01 +0000 Subject: [PATCH] Added dumpdict command line option to dump the dictionary before doing the usual stats --- index/invstat.c | 34 ++++++++++++++++++++++++++++++++-- index/main.c | 8 ++++++-- index/zebraapi.h | 4 ++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/index/invstat.c b/index/invstat.c index dd808da..f5bc6aa 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -24,11 +24,33 @@ struct inv_stat_info { int isamb_sizes[10]; int isamb_blocks[10]; unsigned long cksum; + int dumpwords; }; #define SINGLETON_TYPE 8 /* the type to use for singletons that */ /* have no block and no block type */ +static void print_dict_item (ZebraMaps zm, const char *s, int count ) +{ + int reg_type = s[1]; + char keybuf[IT_MAX_WORD+1]; + char *to = keybuf; + const char *from = s + 2; + + while (*from) + { + const char *res = zebra_maps_output (zm, reg_type, &from); + if (!res) + *to++ = *from++; + else + while (*res) + *to++ = *res++; + } + *to = '\0'; + /* yaz_log (LOG_LOG, "%s", keybuf); */ + printf("%10d %s\n",count, keybuf); +} + static int inv_stat_handle (char *name, const char *info, int pos, void *client) { @@ -43,6 +65,7 @@ static int inv_stat_handle (char *name, const char *info, int pos, assert (*info == sizeof(ISAMS_P)); memcpy (&isam_p, info+1, sizeof(ISAMS_P)); + if (stat_info->zh->reg->isams) { ISAMS_PP pp; @@ -150,10 +173,12 @@ static int inv_stat_handle (char *name, const char *info, int pos, while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i]) i++; ++(stat_info->isam_occurrences[i]); + if (stat_info->dumpwords) + print_dict_item(stat_info->zh->reg->zebra_maps, name, occur); return 0; } -void zebra_register_statistics (ZebraHandle zh) +void zebra_register_statistics (ZebraHandle zh, int dumpdict) { int blocks; int size; @@ -169,6 +194,7 @@ void zebra_register_statistics (ZebraHandle zh) return; stat_info.zh = zh; + stat_info.dumpwords=dumpdict; term_dict[0] = 1; term_dict[1] = 0; @@ -315,7 +341,11 @@ void zebra_register_statistics (ZebraHandle zh) /* * * $Log: invstat.c,v $ - * Revision 1.29 2002-06-19 10:29:17 adam + * Revision 1.30 2002-07-11 13:03:01 heikki + * Added dumpdict command line option to dump the + * dictionary before doing the usual stats + * + * Revision 1.29 2002/06/19 10:29:17 adam * align block sizes for isam sys. Better plot for test * * Revision 1.28 2002/04/30 19:31:09 adam diff --git a/index/main.c b/index/main.c index edf5212..c32c419 100644 --- a/index/main.c +++ b/index/main.c @@ -2,7 +2,7 @@ * Copyright (C) 1994-2002, Index Data * All rights reserved. * - * $Id: main.c,v 1.91 2002-06-19 13:19:43 adam Exp $ + * $Id: main.c,v 1.92 2002-07-11 13:03:01 heikki Exp $ */ #include #include @@ -151,7 +151,11 @@ int main (int argc, char **argv) } else if (!strcmp (arg, "stat") || !strcmp (arg, "status")) { - zebra_register_statistics (zh); + zebra_register_statistics (zh,0); + } + else if (!strcmp (arg, "dump") || !strcmp (arg, "dumpdict")) + { + zebra_register_statistics (zh,1); } else if (!strcmp (arg, "compact")) { diff --git a/index/zebraapi.h b/index/zebraapi.h index 1b822b3..2551093 100644 --- a/index/zebraapi.h +++ b/index/zebraapi.h @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: zebraapi.h,v 1.16 2002-04-26 08:44:47 adam Exp $ + * $Id: zebraapi.h,v 1.17 2002-07-11 13:03:01 heikki Exp $ */ #ifndef ZEBRAAPI_H @@ -153,7 +153,7 @@ YAZ_EXPORT void zebra_shadow_enable (ZebraHandle zh, int value); YAZ_EXPORT -void zebra_register_statistics (ZebraHandle zh); +void zebra_register_statistics (ZebraHandle zh, int dumpdict); YAZ_END_CDECL #endif -- 1.7.10.4