|
IDZEBRA 2.2.8
|
Zebra dictionary. More...
Go to the source code of this file.
Typedefs | |
| typedef struct Dict_struct * | Dict |
| Dictionary handle. | |
Functions | |
| Dict | dict_open (BFiles bfs, const char *name, int cache, int rw, int compact_flag, int page_size) |
| open dictionary | |
| int | dict_close (Dict dict) |
| closes dictionary | |
| int | dict_insert (Dict dict, const char *p, int userlen, void *userinfo) |
| insert item into dictionary | |
| int | dict_delete (Dict dict, const char *p) |
| deletes item from dictionary | |
| char * | dict_lookup (Dict dict, const char *p) |
| lookup item in dictionary | |
| int | dict_delete_subtree (Dict dict, const char *p, void *client, int(*f)(const char *info, void *client)) |
| delete items with a given prefix from dictionary | |
| int | dict_lookup_ec (Dict dict, char *p, int range, int(*f)(char *name)) |
| lookup item(s) in dictionary with error correction | |
| int | dict_lookup_grep (Dict dict, const char *p, int range, void *client, int *max_pos, int init_pos, int(*f)(char *name, const char *info, void *client)) |
| regular expression search with error correction | |
| int | dict_scan (Dict dict, char *str, int *before, int *after, void *client, int(*f)(char *name, const char *info, int pos, void *client)) |
| dictionary scan | |
| void | dict_grep_cmap (Dict dict, void *vp, const char **(*cmap)(void *vp, const char **from, int len)) |
| install character mapping handler for dict_lookup_grep | |
| int | dict_copy_compact (BFiles bfs, const char *from, const char *to) |
| copies one dictionary to another | |
| void | dict_clean (Dict dict) |
| reset Dictionary (makes it empty) | |
| zint | dict_get_no_lookup (Dict dict) |
| get number of lookup operations, since dict_open | |
| zint | dict_get_no_insert (Dict dict) |
| get number of insert operations, since dict_open | |
| zint | dict_get_no_split (Dict dict) |
| get number of page split operations, since dict_open | |
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.
Definition in file dict.h.
| void dict_clean | ( | Dict | dict | ) |
reset Dictionary (makes it empty)
| dict | dictionary handle |
Definition at line 31 of file open.c.
References Dict_head::compact_flag, Dict_struct::dbf, dict, dict_bf_newp(), DICT_MAGIC, Dict_head::freelist, Dict_struct::head, Dict_head::last, Dict_head::magic_str, Dict_head::page_size, Dict_head::root, and Dict_struct::rw.
Referenced by dict_open(), and zebra_remove_file_match().
| int dict_close | ( | Dict | dict | ) |
closes dictionary
| dict | handle |
| 0 | OK |
| -1 | failure |
Definition at line 32 of file close.c.
References Dict_struct::dbf, dict, dict_bf_close(), dict_bf_readp(), dict_bf_touch(), Dict_struct::head, and Dict_struct::rw.
Referenced by dict_copy_compact(), main(), repositoryShow(), zebra_register_close(), zebra_remove_file_match(), and zebra_update_file_match().
| int dict_copy_compact | ( | BFiles | bfs, |
| const char * | from, | ||
| const char * | to | ||
| ) |
copies one dictionary to another
| bfs | block file handle |
| from | source dictionary file |
| to | destination dictionary file |
Definition at line 90 of file dcompact.c.
References Dict_struct::dbf, DICT_backptr, dict_bf_newp(), dict_bf_readp(), DICT_bsize, dict_close(), dict_copy_page(), DICT_nodir, dict_open(), DICT_size, DICT_type, Dict_struct::head, Dict_head::last, Dict_head::page_size, and Dict_head::root.
Referenced by inv_compact().
| int dict_delete | ( | Dict | dict, |
| const char * | p | ||
| ) |
deletes item from dictionary
| dict | dictionary handle |
| p | string-z with lookup string |
| 0 | p not found |
| 1 | p found and deleted |
| -1 | error |
Definition at line 260 of file delete.c.
References dict, dict_del_string(), Dict_struct::head, and Dict_head::root.
Referenced by dict_delete_ord(), dirs_del(), dirs_rmdir(), heap_inpb(), heap_inpc(), and main().
| int dict_delete_subtree | ( | Dict | dict, |
| const char * | p, | ||
| void * | client, | ||
| int(*)(const char *info, void *client) | f | ||
| ) |
delete items with a given prefix from dictionary
| dict | dictionary handle |
| p | string-z with prefix |
| client | client data to be supplied to function f |
| f | function which gets called for each item in tree |
| 0 | OK (0 or more entries deleted) |
| 1 | OK (1 or more entries delete) |
| -1 | ERROR |
Function f is called for each item to be deleted.
Definition at line 266 of file delete.c.
References dict, dict_del_string(), Dict_struct::head, and Dict_head::root.
Referenced by delete_SU_handle(), dict_delete_subtree_ord(), and main().
get number of insert operations, since dict_open
| dict | dictionary handle |
Definition at line 128 of file open.c.
References dict, and Dict_struct::no_insert.
get number of lookup operations, since dict_open
| dict | dictionary handle |
Definition at line 123 of file open.c.
References dict, and Dict_struct::no_lookup.
get number of page split operations, since dict_open
| dict | dictionary handle |
Definition at line 133 of file open.c.
References dict, and Dict_struct::no_split.
Referenced by index_block_flush().
| void dict_grep_cmap | ( | Dict | dict, |
| void * | vp, | ||
| const char **(*)(void *vp, const char **from, int len) | cmap | ||
| ) |
install character mapping handler for dict_lookup_grep
| dict | dictionary handle |
| vp | client data to be passed to cmap function handler |
| 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.
Definition at line 445 of file lookgrep.c.
References dict, Dict_struct::grep_cmap, and Dict_struct::grep_cmap_data.
Referenced by rpn_char_map_prepare(), and rpn_search_xpath().
| int dict_insert | ( | Dict | dict, |
| const char * | p, | ||
| int | userlen, | ||
| void * | userinfo | ||
| ) |
insert item into dictionary
| dict | dictionary handle |
| p | string-z with lookup string |
| userlen | length of user data (associated with p) |
| userinfo | userdata (of size userlen) |
| 0 | p is new and inserted OK |
| 1 | p is updated (already exists) and userinfo is modified |
| 2 | p already exists and userinfo is unmodified (same as before) |
| -1 | error |
Definition at line 439 of file insert.c.
References dict, dict_ins(), Dict_struct::head, new_page(), Dict_struct::no_insert, Dict_head::root, and Dict_struct::rw.
Referenced by dict_insert_ord(), dirs_add(), dirs_mkdir(), heap_inpb(), heap_inpc(), heap_inps(), index_block_flush(), main(), and tst().
| char * dict_lookup | ( | Dict | dict, |
| const char * | p | ||
| ) |
lookup item in dictionary
| dict | dictionary handle |
| p | string-z with lookup string |
| NULL | not found |
| value | where value[0]=userlen, value[1..userlen] is userinfo data |
Definition at line 100 of file lookup.c.
References dict, dict_look(), Dict_struct::head, Dict_struct::no_lookup, and Dict_head::root.
Referenced by dict_lookup_ord(), dirs_fopen(), freq_term(), heap_inpb(), heap_inpc(), heap_inps(), index_block_flush(), main(), search_group(), search_position(), zebra_recid_to_sysno(), and zebra_record_check().
| int dict_lookup_ec | ( | Dict | dict, |
| char * | p, | ||
| int | range, | ||
| int(*)(char *name) | f | ||
| ) |
lookup item(s) in dictionary with error correction
| dict | dictionary handle |
| p | string-z with lookup string |
| range | number of allowed errors(extra/substituted/missing char) |
| f | function be called for each match (NULL for no call of f) |
| 0 | OK |
| -1 | error |
Function f is called for each item matched.
Definition at line 149 of file lookupec.c.
References dict, dict_strlen(), Dict_struct::head, lookup_ec(), prepare_match(), and Dict_head::root.
| int dict_lookup_grep | ( | Dict | dict, |
| const char * | p, | ||
| int | range, | ||
| void * | client, | ||
| int * | max_pos, | ||
| int | init_pos, | ||
| int(*)(char *name, const char *info, void *client) | f | ||
| ) |
regular expression search with error correction
| dict | dictionary handle |
| p | regular expression string-z |
| range | number of allowed errors(extra/substituted/missing char) |
| client | client data pointer to be passed to match function f |
| max_pos | on return holds maximum number of chars that match (prefix) |
| init_pos | number of leading non-error corrected chars. |
| f | function be called for each match |
| 0 | Operation complete. Function f returned zero value always |
| >0 | Operation incomplete. Function f returned a non-zero value |
| -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.
Definition at line 374 of file lookgrep.c.
References debug_dfa_followpos, debug_dfa_tran, debug_dfa_trav, dfa_anyset_includes_nl(), dfa_delete(), dfa_init(), dfa_mkstate(), dfa_parse(), dfa_set_cmap(), dfa_verbose, dict, MatchContext::fact, get_bit(), grep(), Dict_struct::grep_cmap, Dict_struct::grep_cmap_data, Dict_struct::head, init_pos(), MAX_LENGTH, mk_MatchContext(), MatchContext::n, DFA::no_states, MatchContext::range, rm_MatchContext(), Dict_head::root, set_bit(), DFA::states, DFA_tran::to, DFA_state::tran_no, and DFA_state::trans.
Referenced by main(), numeric_relation(), string_term(), and xpath_trunc().
| Dict dict_open | ( | BFiles | bfs, |
| const char * | name, | ||
| int | cache, | ||
| int | rw, | ||
| int | compact_flag, | ||
| int | page_size | ||
| ) |
open dictionary
| bfs | block file storage |
| name | name of dictionary file |
| cache | number of pages to cache |
| rw | 0=read-only, 1=read&write |
| compact_flag | 1=write with compact, 0=normal paged operation |
| page_size | page size of disc block |
Definition at line 50 of file open.c.
References Dict_head::compact_flag, Dict_struct::dbf, dict, dict_bf_close(), dict_bf_compact(), dict_bf_open(), dict_bf_readp(), dict_clean(), DICT_DEFAULT_PAGESIZE, DICT_MAGIC, Dict_struct::grep_cmap, Dict_struct::head, Dict_head::magic_str, Dict_struct::no_insert, Dict_struct::no_lookup, Dict_struct::no_split, Dict_head::page_size, and Dict_struct::rw.
Referenced by dict_copy_compact(), dict_open_res(), and main().
| int dict_scan | ( | Dict | dict, |
| char * | str, | ||
| int * | before, | ||
| int * | after, | ||
| void * | client, | ||
| int(*)(char *name, const char *info, int pos, void *client) | f | ||
| ) |
dictionary scan
| dict | dictionary handle |
| str | start pint term (string-z) |
| before | number of terms to be visited preceding str |
| after | number of terms to be visited following str |
| client | client data pointer to be passed to match function f |
| f | function be called for each matching term |
| 0 | Successful |
| -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.
Definition at line 242 of file scan.c.
References dict, dict_scan_r(), Dict_struct::head, and Dict_head::root.
Referenced by dirs_open(), dirs_read(), do_scan(), main(), rpn_scan_norm(), and zebra_register_statistics().