IDZEBRA 2.2.11
rset.c File Reference
#include <stdio.h>
#include <string.h>
#include <idzebra/util.h>
#include <assert.h>
#include <yaz/nmem.h>
#include <rset.h>

Go to the source code of this file.

Functions

RSFD rfd_create_base (RSET rs)
 Common constuctor for RFDs.
static void rset_close_int (RSET rs, RSFD rfd)
void rset_set_hits_limit (RSET rs, zint l)
void rset_close (RSFD rfd)
 Closes a result set RFD handle.
RSET rset_create_base (const struct rset_control *sel, NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID term, int no_children, RSET *children)
 Common constuctor for RSETs.
void rset_delete (RSET rs)
 Destructor RSETs.
int rfd_is_last (RSFD rfd)
 Test for last use of RFD.
RSET rset_dup (RSET rs)
 Duplicate an RSET.
zint rset_count (RSET rs)
 Estimates hit count for result set.
void rset_get_one_term (RSET ct, TERMID *terms, int maxterms, int *curterm)
 is a getterms function for those that don't have any
struct ord_list * ord_list_create (NMEM nmem)
struct ord_list * ord_list_append (NMEM nmem, struct ord_list *list, int ord)
struct ord_list * ord_list_dup (NMEM nmem, struct ord_list *list)
void ord_list_print (struct ord_list *list)
TERMID rset_term_create (const char *name, int length, const char *flags, int type, NMEM nmem, struct ord_list *ol, int reg_type, zint hits_limit, const char *ref_id)
 Creates a TERMID entry.
int rset_default_read (RSFD rfd, void *buf, TERMID *term)
int rset_default_forward (RSFD rfd, void *buf, TERMID *term, const void *untilbuf)
void rset_visit (RSET rset, int level)
int rset_no_write (RSFD rfd, const void *buf)

Variables

static int log_level = 0
static int log_level_initialized = 0

Function Documentation

◆ ord_list_append()

struct ord_list * ord_list_append ( NMEM nmem,
struct ord_list * list,
int ord )

Definition at line 306 of file rset.c.

References ord_list::next, and ord_list::ord.

Referenced by numeric_term(), ord_list_dup(), scan_save_set(), and string_term().

◆ ord_list_create()

struct ord_list * ord_list_create ( NMEM nmem)

Definition at line 301 of file rset.c.

Referenced by numeric_term(), ord_list_dup(), scan_save_set(), and string_term().

◆ ord_list_dup()

struct ord_list * ord_list_dup ( NMEM nmem,
struct ord_list * list )

Definition at line 315 of file rset.c.

References ord_list::next, ord_list::ord, ord_list_append(), and ord_list_create().

Referenced by rset_term_create().

◆ ord_list_print()

void ord_list_print ( struct ord_list * list)

Definition at line 323 of file rset.c.

References ord_list::next, and ord_list::ord.

Referenced by resultSetSortSingle().

◆ rfd_create_base()

RSFD rfd_create_base ( RSET rs)

Common constuctor for RFDs.

Parameters
rsResult set handle.

Creates an rfd. Either allocates a new one, in which case the priv pointer is null, and will have to be filled in, or picks up one from the freelist, in which case the priv is already allocated, and presumably everything that hangs from it as well

Definition at line 43 of file rset.c.

References rsfd::counted_buf, rsfd::counted_items, rset::free_list, rset_key_control::key_size, rset::keycontrol, log_level, rsfd::next, rset::nmem, rsfd::priv, rsfd::rset, and rset::use_list.

Referenced by r_open(), r_open(), r_open(), r_open(), r_open(), r_open(), r_open(), r_open(), and r_open_andor().

◆ rfd_is_last()

int rfd_is_last ( RSFD rfd)

Test for last use of RFD.

Parameters
rfdRFD handle.

Returns 1 if this RFD is the last reference to it; 0 otherwise.

Definition at line 242 of file rset.c.

References rsfd::next, rsfd::rset, and rset::use_list.

Referenced by r_close().

◆ rset_close()

◆ rset_close_int()

void rset_close_int ( RSET rs,
RSFD rfd )
static

◆ rset_count()

zint rset_count ( RSET rs)

Estimates hit count for result set.

Parameters
rsResult Set.

rset_count uses rset_pos to get the total and returns that. This is ok for rsisamb/c/s, and for some other rsets, but in case of booleans etc it will give bad estimate, as nothing has been read from that rset

Definition at line 272 of file rset.c.

References rset_close_int(), rset_open, and rset_pos.

Referenced by begin(), and begin().

◆ rset_create_base()

RSET rset_create_base ( const struct rset_control * sel,
NMEM nmem,
struct rset_key_control * kcontrol,
int scope,
TERMID term,
int no_children,
RSET * children )

Common constuctor for RSETs.

Parameters
selThe interface control handle
nmemThe memory handle for it.
kcontrolKey control info (decode, encode, comparison etc)
scopescope for set
termInformation about term for it (NULL for none).
no_childrennumber of child rsets (0 for none)
childrenchild rsets (NULL for none).

Creates an rfd. Either allocates a new one, in which case the priv pointer is null, and will have to be filled in, or picks up one from the freelist, in which case the priv is already allocated, and presumably everything that hangs from it as well

Definition at line 164 of file rset.c.

References rset::children, rset::control, rset_control::desc, rset::free_list, rset::hits_count, rset::hits_limit, rset_term::hits_limit, rset::hits_round, rset_key_control::inc, rset::keycontrol, log_level, log_level_initialized, rset::nmem, rset::no_children, rset::priv, rset_term::ref_id, rset::refcount, rset_term::rset, rset::scope, scope, rset::term, and rset::use_list.

Referenced by rsbool_create_base(), rset_create_between(), rset_create_null(), rset_create_prox(), rset_create_temp(), rsisamb_create(), rsisamc_create(), rsisams_create(), and rsmulti_andor_create().

◆ rset_default_forward()

int rset_default_forward ( RSFD rfd,
void * buf,
TERMID * term,
const void * untilbuf )

rset_default_forward implements a generic forward with a read-loop

Definition at line 396 of file rset.c.

References rset_key_control::cmp, rset::control, rsfd::counted_items, rset_control::f_forward, rset::hits_limit, rset::keycontrol, log_level, rsfd::rset, rset_default_forward(), rset_read, and rset::scope.

Referenced by rset_default_forward().

◆ rset_default_read()

int rset_default_read ( RSFD rfd,
void * buf,
TERMID * term )

◆ rset_delete()

◆ rset_dup()

RSET rset_dup ( RSET rs)

Duplicate an RSET.

Parameters
rsHandle for result set.

Duplicates a result set by incrementing the reference count to it.

Definition at line 255 of file rset.c.

References rset::control, rset_control::desc, log_level, and rset::refcount.

Referenced by freq_term(), resultSetClone(), rpn_search_structure(), scan_save_set(), and zebra_snippets_hit_vector().

◆ rset_get_one_term()

void rset_get_one_term ( RSET ct,
TERMID * terms,
int maxterms,
int * curterm )

is a getterms function for those that don't have any

Parameters
ctresult set handle
termsarray of terms (0..maxterms-1)
maxtermslength of terms array
curtermcurrent size of terms array

If there is a term associated with rset the term is appeneded; otherwise the terms array is untouched but curterm is incremented anyway.

Definition at line 291 of file rset.c.

References rset::term.

Referenced by r_get_terms().

◆ rset_no_write()

int rset_no_write ( RSFD rfd,
const void * buf )

Definition at line 431 of file rset.c.

References rset::control, rset_control::desc, and rsfd::rset.

◆ rset_set_hits_limit()

void rset_set_hits_limit ( RSET rs,
zint l )

Definition at line 88 of file rset.c.

References rset::hits_limit, log_level, and ZINT_FORMAT.

Referenced by resultSetSearch(), and resultSetSortSingle().

◆ rset_term_create()

TERMID rset_term_create ( const char * name,
int length,
const char * flags,
int type,
NMEM nmem,
struct ord_list * ol,
int reg_type,
zint hits_limit,
const char * ref_id )

Creates a TERMID entry.

Parameters
nameTerm/Name buffer with given length
lengthof term
flagsfor term
typeTerm Type, Z_Term_general, Z_Term_characterString,..
nmemmemory for term.
olord list
reg_typeregister type
hits_limitlimit before counting stops and gets approximate
ref_idsupplied ID for term that can be used to identify this

Definition at line 340 of file rset.c.

References rset_term::flags, rset_term::hits_limit, rset_term::name, rset_term::ol, ord_list_dup(), rset_term::rankpriv, rset_term::ref_id, rset_term::reg_type, rset_term::rset, and rset_term::type.

Referenced by checkterm(), freq_term(), and rset_trunc().

◆ rset_visit()

void rset_visit ( RSET rset,
int level )

Definition at line 421 of file rset.c.

References rset::children, rset::hits_approx, rset::hits_count, rset::no_children, rset_visit(), and ZINT_FORMAT.

Referenced by rset_visit().

Variable Documentation

◆ log_level

int log_level = 0
static

Definition at line 30 of file rset.c.

◆ log_level_initialized

int log_level_initialized = 0
static

Definition at line 31 of file rset.c.