rset_get_no_terms.
-/* $Id: d1_if.c,v 1.6 2005-01-15 19:38:18 adam Exp $
+/* $Id: d1_if.c,v 1.7 2005-06-02 11:59:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
/**
-
-data1_CountOccurences
-
-Count the number of occurences of the last instance on a tagpath.
-
-@param data1_node* node : The root of the tree we wish to look for occurences in
-@param const char* pTagPath : The tagpath we want to count the occurences of...
-
+ \brief Count the number of occurences of the last instance on a tagpath.
+ \param node : The root of the tree we wish to look for occurences in
+ \param pTagPath : The tagpath we want to count the occurences of...
*/
int data1_CountOccurences(data1_node* node, char* pTagPath)
{
-/* $Id: api.h,v 1.24 2005-05-24 11:35:41 adam Exp $
+/* $Id: api.h,v 1.25 2005-06-02 11:59:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ZebraService zebra_start_res(const char *configName,
Res def_res, Res over_res);
-/** \fn ZEBRA_RES zebra_stop(ZebraService zs)
- \brief stops a Zebra service.
- \param zs service handle
-
- Frees resources used by the service.
+/**
+ \brief stops a Zebra service.
+ \param zs service handle
+
+ Frees resources used by the service.
*/
YAZ_EXPORT
ZEBRA_RES zebra_stop(ZebraService zs);
-/** \fn void zebra_filter_info(ZebraService zs, void *cd, \
- void(*cb)(void *cd, const char *name))
- \brief lists enabled Zebra filters
- \param zs service handle
- \param cd callback parameter (opaque)
- \param cb callback function
+/**
+ \brief Lists enabled Zebra filters
+ \param zs service handle
+ \param cd callback parameter (opaque)
+ \param cb callback function
*/
YAZ_EXPORT
void zebra_filter_info(ZebraService zs, void *cd,
void (*cb)(void *cd, const char *name));
-/** \fn ZebraHandle zebra_open(ZebraService zs)
- \brief creates a Zebra session handle within service.
- \param zs service handle.
-
- There should be one handle for each thread doing something
- with zebra, be that searching or indexing. In simple apps
- one handle is sufficient
+/**
+ \brief Creates a Zebra session handle within service.
+ \param zs service handle.
+
+ There should be one handle for each thread doing something
+ with zebra, be that searching or indexing. In simple apps
+ one handle is sufficient
*/
YAZ_EXPORT
ZebraHandle zebra_open(ZebraService zs);
-/** \fn int zebra_close(ZebraHandle zh)
- \brief destroys Zebra session handle.
- \param zh zebra session handle.
+/**
+ \brief Destroys Zebra session handle.
+ \param zh zebra session handle.
*/
YAZ_EXPORT
ZEBRA_RES zebra_close(ZebraHandle zh);
-/** \fn int zebra_errCode(ZebraHandle zh)
- \brief returns error code for last error
- \param zh zebra session handle.
+/**
+ \brief Returns error code for last error
+ \param zh zebra session handle.
*/
YAZ_EXPORT
int zebra_errCode(ZebraHandle zh);
-/** \fn const char *zebra_errString(ZebraHandle zh)
- \brief returns error string for last error
- \param zh zebra session handle.
+/**
+ \brief Returns error string for last error
+ \param zh zebra session handle.
*/
YAZ_EXPORT
const char *zebra_errString(ZebraHandle zh);
-/** \fn char *zebra_errAdd(ZebraHandle zh)
- \brief returns additional info for last error
- \param zh zebra session handle.
+/**
+ \brief Returns additional info for last error
+ \param zh zebra session handle.
*/
YAZ_EXPORT
char *zebra_errAdd(ZebraHandle zh);
-/** \fn int zebra_result(ZebraHandle zh, int *code, char **addinfo)
- \brief returns error code and additional info for last error
- \param zh zebra session handle.
- \param code pointer to returned error code
- \param addinfo pointer to returned additional info
+/**
+ \brief Returns error code and additional info for last error
+ \param zh zebra session handle.
+ \param code pointer to returned error code
+ \param addinfo pointer to returned additional info
*/
YAZ_EXPORT
void zebra_result(ZebraHandle zh, int *code, char **addinfo);
-/** \fn void zebra_clearError(ZebraHandle zh)
- \brief clears last error.
+/**
+ \brief Clears last error.
\param zh zebra session handle.
- */
+*/
YAZ_EXPORT
void zebra_clearError(ZebraHandle zh);
-/** \fn ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, \
- const char *setname, zint *hits)
- \brief Search using PQF Query
- \param zh session handle
- \param pqf_query query
- \param setname name of resultset
- \param hits of hits is returned
+/**
+ \brief Search using PQF Query
+ \param zh session handle
+ \param pqf_query query
+ \param setname name of resultset
+ \param hits of hits is returned
*/
YAZ_EXPORT
ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
const char *setname, Z_RecordComposition *comp, \
oid_value input_format, int num_recs, \
ZebraRetrievalRecord *recs)
- \brief retrieve records from result set (after search)
+ \brief Retrieve records from result set (after search)
\param zh session handle
\param stream allocate records returned using this ODR
\param setname name of result set to retrieve records from
int num_recs,
ZebraRetrievalRecord *recs);
/**
- \fn int zebra_deleteResultSet(ZebraHandle zh, int function, \
- int num_setnames, char **setnames, int *statuses)
- \brief delete one or more resultsets
+ \brief Deletes one or more resultsets
\param zh session handle
\param function Z_DeleteResultSetRequest_{list,all}
\param num_setnames number of result sets
/**
- \fn ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, \
- Z_AttributesPlusTerm *zapt, oid_value attributeset, \
- int *position, int *num_entries, ZebraScanEntry **list, \
- int *is_partial)
\brief performs Scan (Z39.50 style)
\param zh session handle
\param stream ODR handle for result
\param attributeset Attributeset for Attribute plus Term
\param position input/output position
\param num_entries number of terms requested / returned
- \param list list of resulting terms (ODR allocated)
+ \param entries list of resulting terms (ODR allocated)
\param is_partial upon return 1=partial, 0=complete
*/
YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream,
Z_AttributesPlusTerm *zapt,
oid_value attributeset,
int *position, int *num_entries,
- ZebraScanEntry **list,
+ ZebraScanEntry **entries,
int *is_partial);
/**
- \fn ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, \
- const char *query, int *position, int *num_entries, \
- ZebraScanEntry **list, int *is_partial)
\brief performs Scan (taking PQF string)
\param zh session handle
\param stream ODR handle for result
\param query PQF scan query
\param position input/output position
\param num_entries number of terms requested / returned
- \param list list of resulting terms (ODR allocated)
+ \param entries list of resulting terms (ODR allocated)
\param is_partial upon return 1=partial, 0=complete
*/
YAZ_EXPORT
ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
int *position, int *num_entries, ZebraScanEntry **entries,
int *is_partial);
+
/**
- \fn ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass)
\brief authenticate user. Returns 0 if OK, != 0 on failure
\param zh session handle
\param user user name
ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass);
/**
- \fn int zebra_string_norm(ZebraHandle zh, unsigned reg_id, \
- const char *input_str, int input_len, \
- char *output_str, int output_len)
- \brief normalize zebra term for register (subject to change!)
+ \brief Normalize zebra term for register (subject to change!)
\param zh session handle
\param reg_id register ID, 'w', 'p',..
\param input_str input string buffer
int input_len, char *output_str, int output_len);
/**
- \fn ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db)
- \brief creates a database
+ \brief Creates a database
\param zh session handle
\param db database to be created
*/
ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db);
/**
- \fn int zebra_drop_database(ZebraHandle zh, const char *db)
- \brief deletes a database (drop)
+ \brief Deletes a database (drop)
\param zh session handle
\param db database to be deleted
*/
-/* $Id: rset.h,v 1.52 2005-05-24 11:35:41 adam Exp $
+/* $Id: rset.h,v 1.53 2005-06-02 11:59:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_BEGIN_CDECL
-typedef struct rsfd *RSFD; /* Rset "file descriptor" */
-typedef struct rset *RSET; /* Result set */
-
+typedef struct rsfd *RSFD;
+typedef struct rset *RSET;
/**
* rset_term is all we need to know of a term to do ranking etc.
* As far as the rsets are concerned, it is just a dummy pointer to
* be passed around.
*/
-
struct rset_term {
- /** the term itself */
- char *name;
- char *flags;
- int type;
- /** the rset corresponding to this term */
- RSET rset;
- /** private stuff for the ranking algorithm */
- void *rankpriv;
+ char *name; /** the term itself in internal encoding (UTF-8/raw) */
+ char *flags; /** flags for rank method */
+ int type; /** Term_type from RPN Query. Actually this
+ is Z_Term_general, Z_Term_numeric,
+ Z_Term_characterString, ..
+ This info is used to return encoded term back for
+ search-result-1 .
+ */
+ RSET rset; /** the rset corresponding to this term */
+ void *rankpriv;/** private stuff for the ranking algorithm */
};
typedef struct rset_term *TERMID;
/** rset_default_read implements a generic read */
int rset_default_read(RSFD rfd, void *buf, TERMID *term);
-/** rset_get_no_terms is a getterms function for those that don't have any */
-void rset_get_no_terms(RSET ct, TERMID *terms, int maxterms, int *curterm);
-
-/**
- * rset_get_one_term is a getterms function for those rsets that have
- * exactly one term, like all rsisamX types.
- */
void rset_get_one_term(RSET ct,TERMID *terms,int maxterms,int *curterm);
/**
{
const struct rset_control *control;
struct rset_key_control *keycontrol;
- int refcount; /* reference count */
- void *priv; /* stuff private to the given type of rset */
- NMEM nmem; /* nibble memory for various allocs */
- char my_nmem; /* Should the nmem be destroyed with the rset? */
- /* 1 if created with it, 0 if passed from above */
- RSFD free_list; /* all rfd's allocated but not currently in use */
- RSFD use_list; /* all rfd's in use */
- int scope; /* On what level do we count hits and compare them? */
- TERMID term; /* the term thing for ranking etc */
+ int refcount; /* reference count */
+ void *priv; /* stuff private to the given type of rset */
+ NMEM nmem; /* nibble memory for various allocs */
+ RSFD free_list; /* all rfd's allocated but not currently in use */
+ RSFD use_list; /* all rfd's in use */
+ int scope; /* On what level do we count hits and compare them? */
+ TERMID term; /* the term thing for ranking etc */
int no_children;
RSET *children;
zint hits_limit;
-/* $Id: zebraapi.c,v 1.172 2005-05-31 17:10:06 adam Exp $
+/* $Id: zebraapi.c,v 1.173 2005-06-02 11:59:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
return res;
}
-ZEBRA_RES zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
- oid_value attributeset,
- int *position,
- int *num_entries, ZebraScanEntry **entries,
- int *is_partial)
+ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
+ oid_value attributeset,
+ int *position,
+ int *num_entries, ZebraScanEntry **entries,
+ int *is_partial)
{
ZEBRA_RES res;
ASSERTZH;
return 0;
}
-ZEBRA_RES zebra_drop_database (ZebraHandle zh, const char *database)
+ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db)
{
ZEBRA_RES ret = ZEBRA_OK;
ASSERTZH;
- yaz_log(log_level, "zebra_drop_database");
+ yaz_log(log_level, "zebra_drop_database %s", db);
zebra_clearError(zh);
- if (zebra_select_database (zh, database) == ZEBRA_FAIL)
+ if (zebra_select_database (zh, db) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zebra_begin_trans (zh, 1) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zh->reg->isamb)
{
- zebraExplain_curDatabase (zh->reg->zei, database);
+ zebraExplain_curDatabase (zh->reg->zei, db);
zebraExplain_trav_ord(zh->reg->zei, zh, delete_SU_handle);
zebraExplain_removeDatabase(zh->reg->zei, zh);
return ret;
}
-ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *database)
+ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db)
{
ASSERTZH;
- yaz_log(log_level, "zebra_create_database %s", database);
- assert(database);
+ yaz_log(log_level, "zebra_create_database %s", db);
+ assert(db);
zebra_clearError(zh);
- if (zebra_select_database (zh, database) == ZEBRA_FAIL)
+ if (zebra_select_database (zh, db) == ZEBRA_FAIL)
return ZEBRA_FAIL;
if (zebra_begin_trans (zh, 1))
return ZEBRA_FAIL;
/* announce database */
- if (zebraExplain_newDatabase (zh->reg->zei, database, 0
+ if (zebraExplain_newDatabase (zh->reg->zei, db, 0
/* explainDatabase */))
{
zebra_end_trans (zh);
- zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, database);
+ zebra_setError(zh, YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED, db);
return ZEBRA_FAIL;
}
return zebra_end_trans (zh);
*/
ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
- const char *setname, zint *numhits)
+ const char *setname, zint *hits)
{
- zint hits = 0;
+ zint lhits = 0;
ZEBRA_RES res = ZEBRA_OK;
Z_RPNQuery *query;
ODR odr = odr_createmem(ODR_ENCODE);
res = ZEBRA_FAIL;
}
else
- res = zebra_search_RPN(zh, odr, query, setname, &hits);
+ res = zebra_search_RPN(zh, odr, query, setname, &lhits);
odr_destroy(odr);
- yaz_log(log_level, "Hits: " ZINT_FORMAT, hits);
+ yaz_log(log_level, "Hits: " ZINT_FORMAT, lhits);
- if (numhits)
- *numhits = hits;
+ if (hits)
+ *hits = lhits;
return res;
}
-/* $Id: zrpn.c,v 1.193 2005-05-31 13:01:37 adam Exp $
+/* $Id: zrpn.c,v 1.194 2005-06-02 11:59:54 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
return ZEBRA_OK;
}
-
+/**
+ \brief Create result set(s) for list of terms
+ \param zh Zebra Handle
+ \param termz_org term as used in query but converted to UTF-8
+ \param attributeSet default attribute set
+ \param stream memory for result
+ \param reg_type register type ('w', 'p',..)
+ \param complete_flag whether it's phrases or not
+ \param rank_type term flags for ranking
+ \param xpath_use use attribute for X-Path (-1 for no X-path)
+ \param num_bases number of databases
+ \param basenames array of databases
+ \param rset_mem memory for result sets
+ \param result_sets output result set for each term in list (output)
+ \param number number of output result sets
+ \param kc rset key control to be used for created result sets
+*/
static ZEBRA_RES term_list_trunc(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
const char *termz_org,
if (sort_flag)
return rpn_sort_spec(zh, zapt, attributeSet, stream, sort_sequence,
rank_type, rset_nmem, rset, kc);
+ /* consider if an X-Path query is used */
xpath_len = parse_xpath(zh, zapt, attributeSet, xpath, 10, stream);
if (xpath_len >= 0)
{
- xpath_use = 1016;
- if (xpath[xpath_len-1].part[0] == '@')
- xpath_use = 1015;
- }
-
+ xpath_use = 1016; /* searching for element by default */
+ if (xpath[xpath_len-1].part[0] == '@')
+ xpath_use = 1015; /* last step an attribute .. */
+ }
+
+ /* search using one of the various search type strategies
+ termz is our UTF-8 search term
+ attributeSet is top-level default attribute set
+ stream is ODR for search
+ reg_id is the register type
+ complete_flag is 1 for complete subfield, 0 for incomplete
+ xpath_use is use-attribute to be used for X-Path search, 0 for none
+ */
if (!strcmp(search_type, "phrase"))
{
res = rpn_search_APT_phrase(zh, zapt, termz, attributeSet, stream,
-/* $Id: rset.c,v 1.46 2005-05-24 11:35:43 adam Exp $
+/* $Id: rset.c,v 1.47 2005-06-02 11:59:54 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
static int log_level = 0;
static int log_level_initialized = 0;
-/** \fn rfd_create_base(RSET rs)
- *
- * 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
- */
+/**
+ \brief Common constuctor for RFDs
+ \param rs Result 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
+*/
RSFD rfd_create_base(RSET rs)
{
RSFD rnew = rs->free_list;
return rnew;
}
-/** \fn rfd_delete_base
- *
- * puts an rfd into the freelist of the rset. Only when the rset gets
- * deleted, will all the nmem disappear */
+/**
+ \brief Closes a result set RFD handle
+ \param rfd the RFD handle.
+*/
void rset_close(RSFD rfd)
{
RSFD *pfd;
rs->control->desc);
}
+/**
+ \brief Common constuctor for RSETs
+ \param sel The interface control handle
+ \param nmem The memory handle for it.
+ \param kcontrol Key control info (decode, encode, comparison etc)
+ \param scope scope for set
+ \param term Information about term for it (NULL for none).
+ \param no_children number of child rsets (0 for none)
+ \param children child 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
+*/
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)
{
RSET rset;
- NMEM M;
- assert(nmem); /* can not yet be used, api/t4 fails */
+ assert(nmem);
if (!log_level_initialized)
{
log_level = yaz_log_module_level("rset");
log_level_initialized = 1;
}
- if (nmem)
- M = nmem;
- else
- M = nmem_create();
- rset = (RSET) nmem_malloc(M, sizeof(*rset));
+ rset = (RSET) nmem_malloc(nmem, sizeof(*rset));
yaz_log(log_level, "rs_create(%s) rs=%p (nm=%p)", sel->desc, rset, nmem);
- rset->nmem = M;
- if (nmem)
- rset->my_nmem = 0;
- else
- rset->my_nmem = 1;
+ rset->nmem = nmem;
rset->control = sel;
rset->refcount = 1;
rset->priv = 0;
return rset;
}
+/**
+ \brief Destructor RSETs
+ \param rs Handle for result set.
+
+ Destroys a result set and all its children.
+ The f_delete method of control is called for the result set.
+*/
void rset_delete(RSET rs)
{
(rs->refcount)--;
rset_delete(rs->children[i]);
(*rs->control->f_delete)(rs);
(*rs->keycontrol->dec)(rs->keycontrol);
- if (rs->my_nmem)
- nmem_destroy(rs->nmem);
}
}
+/**
+ \brief Test for last use of RFD
+ \param rfd RFD handle.
+
+ Returns 1 if this RFD is the last reference to it; 0 otherwise.
+*/
int rfd_is_last(RSFD rfd)
{
if (rfd->rset->use_list == rfd && rfd->next == 0)
return 0;
}
+/**
+ \brief Duplicate an RSET
+ \param rs Handle for result set.
+
+ Duplicates a result set by incrementing the reference count to it.
+*/
RSET rset_dup (RSET rs)
{
(rs->refcount)++;
}
/**
- * 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
- */
+ \brief Estimates hit count for result set.
+ \param rs Result 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
+*/
zint rset_count(RSET rs)
{
double cur, tot;
return (zint) tot;
}
-/** rset_get_no_terms is a getterms function for those that don't have any */
-void rset_get_no_terms(RSET ct, TERMID *terms, int maxterms, int *curterm)
-{
- return;
-}
+/**
+ \brief is a getterms function for those that don't have any
+ \param ct result set handle
+ \param terms array of terms (0..maxterms-1)
+ \param maxterms length of terms array
+ \param curterm current size of terms array
-/* rset_get_one_term gets that one term from an rset. Used by rsisamX */
+ If there is a term associated with rset the term is appeneded; otherwise
+ the terms array is untouched but curterm is incremented anyway.
+*/
void rset_get_one_term(RSET ct, TERMID *terms, int maxterms, int *curterm)
{
if (ct->term)
{
if (*curterm < maxterms)
terms[*curterm] = ct->term;
- (*curterm)++;
+ (*curterm)++;
}
}
-
+/**
+ \brief Creates a TERMID entry.
+ \param name Term/Name buffer with given length
+ \param length of term
+ \param flags for term
+ \param type Term Type, Z_Term_general, Z_Term_characterString,..
+ \param nmem memory for term.
+*/
TERMID rset_term_create(const char *name, int length, const char *flags,
int type, NMEM nmem)
-/* $Id: rsnull.c,v 1.35 2005-05-24 11:35:43 adam Exp $
+/* $Id: rsnull.c,v 1.36 2005-06-02 11:59:54 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
"null",
r_delete,
- rset_get_no_terms,
+ rset_get_one_term,
r_open,
r_close,
0, /* no forward */
yaz_log(YLOG_FATAL, "NULL set type is read-only");
return -1;
}
-