X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=include%2Fidzebra%2Fdict.h;h=c7dd8effaee30efd88f90faab4446cee9fb51978;hb=4f71537a478fc551989245f0dde38997714eedc1;hp=54c9c80a003bb74cb4c054c99110d2eb9757737a;hpb=1f61b7e564e0ed44176f4c26302c828c45dd121c;p=idzebra-moved-to-github.git diff --git a/include/idzebra/dict.h b/include/idzebra/dict.h index 54c9c80..c7dd8ef 100644 --- a/include/idzebra/dict.h +++ b/include/idzebra/dict.h @@ -1,8 +1,5 @@ -/* $Id: dict.h,v 1.8 2006-08-29 11:28:44 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -22,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** \file dict.h \brief Zebra dictionary - + The dictionary is a hash that maps a string to a value. The value is opaque and is defined as a sequence of bytes with a length in the range 0 to 255. @@ -52,7 +49,7 @@ typedef struct Dict_struct *Dict; \param page_size page size of disc block \returns dictionary handle */ -YAZ_EXPORT +YAZ_EXPORT Dict dict_open(BFiles bfs, const char *name, int cache, int rw, int compact_flag, int page_size); @@ -101,9 +98,11 @@ char *dict_lookup(Dict dict, const char *p); \param p string-z with prefix \param client client data to be supplied to function f \param f function which gets called for each item in tree - \retval 0 OK (0 or more entries deleted) + \retval 0 OK (0 or more entries deleted) \retval 1 OK (1 or more entries delete) \retval -1 ERROR + + Function f is called for each item to be deleted. */ YAZ_EXPORT int dict_delete_subtree(Dict dict, const char *p, void *client, @@ -114,9 +113,11 @@ int dict_delete_subtree(Dict dict, const char *p, void *client, \param dict dictionary handle \param p string-z with lookup string \param range number of allowed errors(extra/substituted/missing char) - \param f function be called for each match + \param f function be called for each match (NULL for no call of f) \retval 0 OK \retval -1 error + + Function f is called for each item matched. */ YAZ_EXPORT int dict_lookup_ec(Dict dict, char *p, int range, int (*f)(char *name)); @@ -129,9 +130,13 @@ int dict_lookup_ec(Dict dict, char *p, int range, int (*f)(char *name)); \param max_pos on return holds maximum number of chars that match (prefix) \param init_pos number of leading non-error corrected chars. \param f function be called for each match - \retval 0 OK - \retval 1 OK + \retval 0 Operation complete. Function f returned zero value always + \retval >0 Operation incomplete. Function f returned a non-zero value \retval -1 error (such as bad regular expression) + + The function f is called for each match. If function f returns + non-zero value the grep operation is stopped and the returned + non-zero value is also returned by dict_lookup_ec. */ YAZ_EXPORT int dict_lookup_grep(Dict dict, const char *p, int range, void *client, @@ -145,12 +150,15 @@ int dict_lookup_grep(Dict dict, const char *p, int range, void *client, \param after number of terms to be visited following str \param client client data pointer to be passed to match function f \param f function be called for each matching term - \retval 0 OK, and no terms visited - \retval 1 OK, and some terms have been visited + \retval 0 Successful \retval -1 error + + If the callback function f returns 0 the scan operation visits + all terms in range (before to after); if the function returns non-zero + the scan operation is cancelled. */ YAZ_EXPORT -int dict_scan(Dict dict, char *str, +int dict_scan(Dict dict, char *str, int *before, int *after, void *client, int (*f)(char *name, const char *info, int pos, void *client)); @@ -159,25 +167,59 @@ int dict_scan(Dict dict, char *str, \param dict dictionary handle \param vp client data to be passed to cmap function handler \param cmap function be called for each character - + This function must be called prior to using dict_grep_lookup. If vp is NULL, no character mapping takes place for dict_lookup_grep. */ -YAZ_EXPORT +YAZ_EXPORT void dict_grep_cmap(Dict dict, void *vp, const char **(*cmap)(void *vp, const char **from, int len)); +/** \brief copies one dictionary to another + \param bfs block file handle + \param from source dictionary file + \param to destination dictionary file +*/ YAZ_EXPORT int dict_copy_compact(BFiles bfs, const char *from, const char *to); +/** \brief reset Dictionary (makes it empty) + \param dict dictionary handle +*/ +YAZ_EXPORT +void dict_clean(Dict dict); + +/** \brief get number of lookup operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_lookup(Dict dict); + +/** \brief get number of insert operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_insert(Dict dict); + +/** \brief get number of page split operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_split(Dict dict); + YAZ_END_CDECL - + #endif /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +