IDZEBRA  2.1.2
Data Structures | Macros | Typedefs | Functions
rset.h File Reference
#include <yaz/yaz-util.h>
#include <idzebra/isamb.h>
#include <idzebra/isamc.h>
#include <idzebra/isams.h>

Go to the source code of this file.

Data Structures

struct  ord_list
 
struct  rset_term
 
struct  rsfd
 
struct  rset_control
 
struct  rset_key_control
 
struct  rset
 

Macros

#define RSETF_READ   0
 
#define RSETF_WRITE   1
 
#define rset_open(rs, wflag)   (*(rs)->control->f_open)((rs), (wflag))
 
#define rset_forward(rfd, buf, term, untilbuf)   rset_default_forward((rfd), (buf), (term), (untilbuf))
 
#define rset_getterms(ct, terms, maxterms, curterm)   (*(ct)->control->f_getterms)((ct),(terms),(maxterms),(curterm))
 
#define rset_pos(rfd, cur, tot)   (*(rfd)->rset->control->f_pos)((rfd),(cur),(tot))
 
#define rset_read(rfd, buf, term)   rset_default_read((rfd), (buf), (term))
 
#define rset_write(rfd, buf)   (*(rfd)->rset->control->f_write)((rfd), (buf))
 
#define rset_type(rs)   ((rs)->control->desc)
 

Typedefs

typedef struct rsfdRSFD
 
typedef struct rsetRSET
 
typedef struct rset_termTERMID
 
typedef struct rset rset
 

Functions

struct ord_listord_list_create (NMEM nmem)
 
struct ord_listord_list_append (NMEM nmem, struct ord_list *list, int ord)
 
struct ord_listord_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. More...
 
int rset_default_forward (RSFD rfd, void *buf, TERMID *term, const void *untilbuf)
 
int rset_default_read (RSFD rfd, void *buf, TERMID *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 More...
 
RSFD rfd_create_base (RSET rs)
 Common constuctor for RFDs. More...
 
int rfd_is_last (RSFD rfd)
 Test for last use of RFD. More...
 
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. More...
 
void rset_delete (RSET rs)
 Destructor RSETs. More...
 
RSET rset_dup (RSET rs)
 Duplicate an RSET. More...
 
void rset_close (RSFD rfd)
 Closes a result set RFD handle. More...
 
zint rset_count (RSET rs)
 Estimates hit count for result set. More...
 
RSET rset_create_temp (NMEM nmem, struct rset_key_control *kcontrol, int scope, const char *temp_path, TERMID term)
 
RSET rset_create_null (NMEM nmem, struct rset_key_control *kcontrol, TERMID term)
 
RSET rset_create_not (NMEM nmem, struct rset_key_control *kcontrol, int scope, RSET rset_l, RSET rset_r)
 
RSET rset_create_between (NMEM nmem, struct rset_key_control *kcontrol, int scope, RSET rset_l, RSET rset_m1, RSET rset_m2, RSET rset_r, RSET rset_attr)
 
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)
 
RSET rset_create_prox (NMEM nmem, struct rset_key_control *kcontrol, int scope, int rset_no, RSET *rset, int ordered, int exclusion, int relation, int distance)
 
RSET rsisamb_create (NMEM nmem, struct rset_key_control *kcontrol, int scope, ISAMB is, ISAM_P pos, TERMID term)
 
RSET rsisamc_create (NMEM nmem, struct rset_key_control *kcontrol, int scope, ISAMC is, ISAM_P pos, TERMID term)
 
RSET rsisams_create (NMEM nmem, struct rset_key_control *kcontrol, int scope, ISAMS is, ISAM_P pos, TERMID term)
 
void rset_visit (RSET rset, int level)
 
void rset_set_hits_limit (RSET rs, zint l)
 
int rset_no_write (RSFD rfd, const void *buf)
 

Macro Definition Documentation

#define rset_forward (   rfd,
  buf,
  term,
  untilbuf 
)    rset_default_forward((rfd), (buf), (term), (untilbuf))

Definition at line 205 of file rset.h.

Referenced by r_forward(), r_forward_and(), r_forward_or(), r_read_and(), and r_read_not().

#define rset_getterms (   ct,
  terms,
  maxterms,
  curterm 
)    (*(ct)->control->f_getterms)((ct),(terms),(maxterms),(curterm))

Definition at line 209 of file rset.h.

Referenced by r_get_terms(), resultSetRank(), and resultSetSortSingle().

#define rset_open (   rs,
  wflag 
)    (*(rs)->control->f_open)((rs), (wflag))
#define rset_pos (   rfd,
  cur,
  tot 
)    (*(rfd)->rset->control->f_pos)((rfd),(cur),(tot))

Definition at line 213 of file rset.h.

Referenced by compare_ands(), r_pos(), r_pos_x(), rset_close(), and rset_count().

#define rset_read (   rfd,
  buf,
  term 
)    rset_default_read((rfd), (buf), (term))
#define rset_type (   rs)    ((rs)->control->desc)

Definition at line 223 of file rset.h.

#define rset_write (   rfd,
  buf 
)    (*(rfd)->rset->control->f_write)((rfd), (buf))

Definition at line 220 of file rset.h.

Referenced by rpn_search_APT_local(), rset_trunc_r(), and zebra_snippets_hit_vector().

#define RSETF_READ   0
#define RSETF_WRITE   1

Typedef Documentation

typedef struct rset* RSET

Definition at line 33 of file rset.h.

typedef struct rset rset

A rset is an ordered sequence of keys, either directly from an underlaying isam, or from one of the higher-level operator rsets (and, or, ...). Actually, it is "virtual base class", no pure rsets exist in the system, they all are of some derived type.

typedef struct rsfd* RSFD

Definition at line 32 of file rset.h.

typedef struct rset_term* TERMID

Definition at line 67 of file rset.h.

Function Documentation

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().

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().

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().

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().

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(), and r_open_andor().

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().

void rset_close ( RSFD  rfd)
zint rset_count ( RSET  rs)

Estimates hit count for result set.

rset_count counts or estimates the keys in it

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().

RSET rset_create_and ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
int  no_rsets,
RSET rsets 
)
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_term::hits_limit, rset::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, scope, rset::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 rset_create_between ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
RSET  rset_l,
RSET  rset_m1,
RSET  rset_m2,
RSET  rset_r,
RSET  rset_attr 
)
RSET rset_create_not ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
RSET  rset_l,
RSET  rset_r 
)

Definition at line 92 of file rsbool.c.

References rsbool_create_base().

Referenced by rpn_search_structure().

RSET rset_create_null ( NMEM  nmem,
struct rset_key_control kcontrol,
TERMID  term 
)
RSET rset_create_or ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
TERMID  termid,
int  no_rsets,
RSET rsets 
)
RSET rset_create_prox ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
int  rset_no,
RSET rset,
int  ordered,
int  exclusion,
int  relation,
int  distance 
)
RSET rset_create_temp ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
const char *  temp_path,
TERMID  term 
)
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_read, and rset::scope.

int rset_default_read ( RSFD  rfd,
void *  buf,
TERMID term 
)
void rset_delete ( RSET  rs)
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().

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().

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.

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().

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(), and rset_trunc().

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, and ZINT_FORMAT.

RSET rsisamb_create ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
ISAMB  is,
ISAM_P  pos,
TERMID  term 
)
RSET rsisamc_create ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
ISAMC  is,
ISAM_P  pos,
TERMID  term 
)
RSET rsisams_create ( NMEM  nmem,
struct rset_key_control kcontrol,
int  scope,
ISAMS  is,
ISAM_P  pos,
TERMID  term 
)

Definition at line 57 of file rsisams.c.

References rset_private::is, rset::nmem, rset_private::pos, rset::priv, and rset_create_base().

Referenced by zebra_create_rset_isam().