summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
696ae40)
Before, random number was used. This is problematic for unit tests
using yaz-ztest. This patch also makes a hash for CQL queries.
For RPN, any term with a leading digit will be treated as pseudu
hit count (to force any particular hit count by a client).
Only terms that looks a numeric is used.. Returns -1 if
no sub tree has a hit count term
*/
Only terms that looks a numeric is used.. Returns -1 if
no sub tree has a hit count term
*/
-static Odr_int get_term_hit(Z_RPNStructure *s)
+static Odr_int get_term_hit(Z_RPNStructure *s, unsigned *hash)
{
Odr_int h = -1;
switch(s->which)
{
Odr_int h = -1;
switch(s->which)
h = odr_atoi(wrbuf_cstr(hits_str));
wrbuf_destroy(hits_str);
}
h = odr_atoi(wrbuf_cstr(hits_str));
wrbuf_destroy(hits_str);
}
+ else
+ {
+ int i;
+ for (i = 0; i < oct->len; i++)
+ *hash = *hash * 65509 + oct->buf[i];
+ }
}
}
break;
case Z_RPNStructure_complex:
}
}
break;
case Z_RPNStructure_complex:
- h = get_term_hit(s->u.complex->s1);
+ h = get_term_hit(s->u.complex->s1, hash);
- h = get_term_hit(s->u.complex->s2);
+ h = get_term_hit(s->u.complex->s2, hash);
/** \brief gets hit count for numeric terms in RPN queries
\param q RPN Query
/** \brief gets hit count for numeric terms in RPN queries
\param q RPN Query
- \return number of hits (random or number for term)
This is just for testing.. A real database of course uses
the content of a database to establish a value.. In our case, we
This is just for testing.. A real database of course uses
the content of a database to establish a value.. In our case, we
{
if (q->which == Z_Query_type_1 || q->which == Z_Query_type_101)
{
{
if (q->which == Z_Query_type_1 || q->which == Z_Query_type_101)
{
- h = get_term_hit(q->u.type_1->RPNStructure);
+ h = get_term_hit(q->u.type_1->RPNStructure, &hash);
+ else if (q->which == Z_Query_type_104 &&
+ q->u.type_104->which == Z_External_CQL)
+ {
+ unsigned hash = 0;
+ const char *cql = q->u.type_104->u.cql;
+ int i;
+ for (i = 0; cql[i]; i++)
+ hash = hash * 65509 + cql[i];
+ return hash % 24;
+ }