IDZEBRA
2.2.7
|
This module implements the rsmulti_or and rsmulti_and result sets. More...
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <idzebra/util.h>
#include <idzebra/isamc.h>
#include <rset.h>
Go to the source code of this file.
Data Structures | |
struct | heap_item |
struct | heap |
struct | rset_private |
struct | rfd_private |
Typedefs | |
typedef struct heap * | HEAP |
Functions | |
static RSFD | r_open_and (RSET ct, int flag) |
static RSFD | r_open_or (RSET ct, int flag) |
static void | r_close (RSFD rfd) |
static void | r_delete (RSET ct) |
static int | r_read_and (RSFD rfd, void *buf, TERMID *term) |
reads one item key from an 'and' set More... | |
static int | r_read_or (RSFD rfd, void *buf, TERMID *term) |
reads one item key from an 'or' set More... | |
static int | r_forward_and (RSFD rfd, void *buf, TERMID *term, const void *untilbuf) |
static int | r_forward_or (RSFD rfd, void *buf, TERMID *term, const void *untilbuf) |
static void | r_pos_and (RSFD rfd, double *current, double *total) |
static void | r_pos_or (RSFD rfd, double *current, double *total) |
static void | r_get_terms (RSET ct, TERMID *terms, int maxterms, int *curterm) |
static void | heap_swap (HEAP h, int x, int y) |
static int | heap_cmp (HEAP h, int x, int y) |
static int | heap_empty (HEAP h) |
static void | heap_delete (HEAP h) |
deletes the first item in the heap, and balances the rest More... | |
static void | heap_balance (HEAP h) |
puts item into heap. The heap root element has changed value (to bigger) Swap downwards until the heap is ordered again More... | |
static void | heap_insert (HEAP h, struct heap_item *hi) |
static HEAP | heap_create (NMEM nmem, int size, const struct rset_key_control *kctrl) |
static void | heap_clear (HEAP h) |
static void | heap_destroy (HEAP h) |
int | compare_ands (const void *x, const void *y) |
compare and items for quicksort used in qsort to get the multi-and args in optimal order that is, those with fewest occurrences first More... | |
static RSET | rsmulti_andor_create (NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID termid, int no_rsets, RSET *rsets, const struct rset_control *ctrl) |
RSET | rset_create_or (NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID termid, int no_rsets, RSET *rsets) |
RSET | rset_create_and (NMEM nmem, struct rset_key_control *kcontrol, int scope, int no_rsets, RSET *rsets) |
static RSFD | r_open_andor (RSET ct, int flag, int is_and) |
static void | r_pos_x (RSFD rfd, double *current, double *total, int and_op) |
Variables | |
static const struct rset_control | control_or |
static const struct rset_control | control_and |
static int | log_level = 0 |
static int | log_level_initialized = 0 |
This module implements the rsmulti_or and rsmulti_and result sets.
rsmultior is based on a heap, from which we find the next hit.
rsmultiand is based on a simple array of rsets, and a linear search to find the record that exists in all of those rsets. To speed things up, the array is sorted so that the smallest rsets come first, they are most likely to have the hits furthest away, and thus forwarding to them makes the most sense.
Definition in file rsmultiandor.c.
Definition at line 108 of file rsmultiandor.c.
int compare_ands | ( | const void * | x, |
const void * | y | ||
) |
compare and items for quicksort used in qsort to get the multi-and args in optimal order that is, those with fewest occurrences first
Definition at line 240 of file rsmultiandor.c.
References heap_item::fd, and rset_pos.
Referenced by r_open_andor().
|
static |
puts item into heap. The heap root element has changed value (to bigger) Swap downwards until the heap is ordered again
Definition at line 176 of file rsmultiandor.c.
References heap_cmp(), and heap_swap().
Referenced by r_forward_or(), and r_read_or().
|
static |
Definition at line 225 of file rsmultiandor.c.
References heap::heapnum.
Referenced by r_open_andor().
|
static |
Definition at line 140 of file rsmultiandor.c.
References heap_item::buf, rset_key_control::cmp, heap::heap, and heap::kctrl.
Referenced by heap_balance(), heap_delete(), and heap_insert().
|
static |
Definition at line 212 of file rsmultiandor.c.
References heap::heap, heap::heapmax, heap::heapnum, and heap::kctrl.
Referenced by r_open_andor().
|
static |
deletes the first item in the heap, and balances the rest
Definition at line 152 of file rsmultiandor.c.
References heap::heap, heap_cmp(), heap_swap(), and heap::heapnum.
Referenced by r_forward_or(), and r_read_or().
|
static |
Definition at line 231 of file rsmultiandor.c.
Referenced by r_close().
|
static |
Definition at line 145 of file rsmultiandor.c.
References heap::heapnum.
Referenced by r_forward_or(), and r_read_or().
Definition at line 194 of file rsmultiandor.c.
References heap::heap, heap_cmp(), heap_swap(), and heap::heapnum.
Referenced by r_open_andor().
|
static |
Definition at line 132 of file rsmultiandor.c.
References heap::heap.
Referenced by heap_balance(), heap_delete(), and heap_insert().
|
static |
Definition at line 367 of file rsmultiandor.c.
References heap_item::fd, rfd_private::h, heap_destroy(), rfd_private::items, rset::no_children, rsfd::priv, rsfd::rset, and rset_close().
|
static |
Definition at line 287 of file rsmultiandor.c.
Definition at line 559 of file rsmultiandor.c.
References heap_item::buf, rset_key_control::cmp, rfd_private::eof, heap_item::fd, rfd_private::items, rset::keycontrol, rset::no_children, rsfd::priv, r_read_and(), rsfd::rset, rset_forward, rset::scope, rfd_private::tailbits, rfd_private::tailcount, and heap_item::term.
Definition at line 379 of file rsmultiandor.c.
References heap_item::buf, rset_key_control::cmp, heap_item::fd, rfd_private::h, heap::heap, heap_balance(), heap_delete(), heap_empty(), rset::keycontrol, rsfd::priv, r_read_or(), rsfd::rset, rset_forward, rset::scope, and heap_item::term.
Definition at line 652 of file rsmultiandor.c.
References rset::children, rset::no_children, rset_get_one_term(), rset_getterms, and rset::term.
Definition at line 362 of file rsmultiandor.c.
References r_open_andor().
Definition at line 291 of file rsmultiandor.c.
References heap_item::buf, rset::children, compare_ands(), rfd_private::eof, heap_item::fd, rfd_private::flag, rfd_private::h, heap_clear(), heap_create(), heap_insert(), rfd_private::hits, rfd_private::items, rset_key_control::key_size, rset::keycontrol, rset::nmem, rset::no_children, rsfd::priv, rfd_create_base(), heap_item::rset, rset_open, rset_read, RSETF_READ, RSETF_WRITE, rfd_private::tailbits, rfd_private::tailcount, and heap_item::term.
Referenced by r_open_and(), and r_open_or().
Definition at line 357 of file rsmultiandor.c.
References r_open_andor().
|
static |
Definition at line 642 of file rsmultiandor.c.
References r_pos_x().
|
static |
Definition at line 647 of file rsmultiandor.c.
References r_pos_x().
|
static |
Definition at line 593 of file rsmultiandor.c.
References rfd_private::cur, heap_item::fd, rfd_private::hits, rfd_private::items, log_level, rset::no_children, rsfd::priv, rsfd::rset, and rset_pos.
Referenced by r_pos_and(), and r_pos_or().
reads one item key from an 'and' set
rfd | set handle |
buf | resulting item buffer |
term | resulting term |
0 | EOF |
1 | item could be read |
Has to return all hits where each item points to the same sysno (scope), in order. Keep an extra key (hitkey) as long as all records do not point to hitkey, forward them, and update hitkey to be the highest seen so far. (if any item eof's, mark eof, and return 0 thereafter) Once a hit has been found, scan all items for the smallest value. Mark all as being in the tail. Read next from that item, and if not in the same record, clear its tail bit
Definition at line 452 of file rsmultiandor.c.
References heap_item::buf, rset_key_control::cmp, rfd_private::eof, heap_item::fd, rset_key_control::get_segment, rfd_private::hits, rfd_private::items, rset_key_control::key_size, rset::keycontrol, rset::no_children, rsfd::priv, rsfd::rset, rset_forward, rset_read, rset::scope, rfd_private::segment, rfd_private::skip, rfd_private::tailbits, rfd_private::tailcount, and heap_item::term.
Referenced by r_forward_and().
reads one item key from an 'or' set
rfd | set handle |
buf | resulting item buffer |
term | resulting term |
0 | EOF |
1 | item could be read |
Definition at line 409 of file rsmultiandor.c.
References heap_item::buf, heap_item::fd, rfd_private::h, heap::heap, heap_balance(), heap_delete(), heap_empty(), rfd_private::hits, rset_key_control::key_size, rset::keycontrol, rsfd::priv, rsfd::rset, rset_read, rset::term, and heap_item::term.
Referenced by r_forward_or().
RSET rset_create_and | ( | NMEM | nmem, |
struct rset_key_control * | kcontrol, | ||
int | scope, | ||
int | no_rsets, | ||
RSET * | rsets | ||
) |
Definition at line 280 of file rsmultiandor.c.
References control_and, rsmulti_andor_create(), and scope.
Referenced by freq_term(), rpn_search_APT_and_list(), rpn_search_APT_numeric(), rpn_search_structure(), rset_create_between(), scan_save_set(), and zebra_snippets_hit_vector().
RSET rset_create_or | ( | NMEM | nmem, |
struct rset_key_control * | kcontrol, | ||
int | scope, | ||
TERMID | termid, | ||
int | no_rsets, | ||
RSET * | rsets | ||
) |
Definition at line 273 of file rsmultiandor.c.
References control_or, rsmulti_andor_create(), and scope.
Referenced by rpn_search_APT(), rpn_search_APT_or_list(), rpn_search_structure(), rset_trunc(), and scan_save_set().
|
static |
Definition at line 253 of file rsmultiandor.c.
References log_level, log_level_initialized, rset::nmem, rset::priv, rset_create_base(), and scope.
Referenced by rset_create_and(), and rset_create_or().
|
static |
Definition at line 59 of file rsmultiandor.c.
Referenced by rset_create_and().
|
static |
Definition at line 59 of file rsmultiandor.c.
Referenced by rset_create_or().
|
static |
Definition at line 127 of file rsmultiandor.c.
Referenced by r_pos_x(), and rsmulti_andor_create().
|
static |
Definition at line 128 of file rsmultiandor.c.
Referenced by rsmulti_andor_create().