projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/yaz
[yaz-moved-to-github.git]
/
ztest
/
ztest.c
diff --git
a/ztest/ztest.c
b/ztest/ztest.c
index
896f56e
..
b43b5bd
100644
(file)
--- a/
ztest/ztest.c
+++ b/
ztest/ztest.c
@@
-95,7
+95,7
@@
static void remove_sets(struct session_handle *sh)
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)
@@
-114,13
+114,19
@@
static Odr_int get_term_hit(Z_RPNStructure *s)
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);
if (h == -1)
if (h == -1)
- h = get_term_hit(s->u.complex->s2);
+ h = get_term_hit(s->u.complex->s2, hash);
break;
}
return h;
break;
}
return h;
@@
-128,7
+134,7
@@
static Odr_int get_term_hit(Z_RPNStructure *s)
/** \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)
+ \return number of hits
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
@@
-139,12
+145,23
@@
static Odr_int get_hit_count(Z_Query *q)
{
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)
{
+ unsigned hash = 0;
Odr_int h = -1;
Odr_int h = -1;
- h = get_term_hit(q->u.type_1->RPNStructure);
+ h = get_term_hit(q->u.type_1->RPNStructure, &hash);
if (h == -1)
if (h == -1)
- h = rand() % 24;
+ h = hash % 24;
return h;
}
return h;
}
+ 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;
+ }
else
return 24;
}
else
return 24;
}
@@
-818,6
+835,7
@@
int ztest_fetch(void *handle, bend_fetch_rr *r)
char *cp;
const Odr_oid *oid = r->request_format;
struct result_set *set = get_set(sh, r->setname);
char *cp;
const Odr_oid *oid = r->request_format;
struct result_set *set = get_set(sh, r->setname);
+ const char *esn = yaz_get_esn(r->comp);
if (!set)
{
if (!set)
{
@@
-918,7
+936,7
@@
int ztest_fetch(void *handle, bend_fetch_rr *r)
}
else if (!oid_oidcmp(oid, yaz_oid_recsyn_xml))
{
}
else if (!oid_oidcmp(oid, yaz_oid_recsyn_xml))
{
- if ((cp = dummy_xml_record(r->number, r->stream)))
+ if ((cp = dummy_xml_record(r->number, r->stream, esn)))
{
r->len = strlen(cp);
r->record = cp;
{
r->len = strlen(cp);
r->record = cp;