projects
/
pazpar2-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a6d3bfe
)
Using approximation for sorting in version 2
author
Dennis Schafroth
<dennis@indexdata.com>
Fri, 13 Apr 2012 11:15:32 +0000
(13:15 +0200)
committer
Dennis Schafroth
<dennis@indexdata.com>
Fri, 13 Apr 2012 11:15:32 +0000
(13:15 +0200)
src/session.c
patch
|
blob
|
history
diff --git
a/src/session.c
b/src/session.c
index
36be061
..
76b43fe
100644
(file)
--- a/
src/session.c
+++ b/
src/session.c
@@
-1015,6
+1015,14
@@
static int cmp_ht(const void *p1, const void *p2)
return h2->hits - h1->hits;
}
return h2->hits - h1->hits;
}
+// Compares two hitsbytarget nodes by hitcount
+static int cmp_ht_approx(const void *p1, const void *p2)
+{
+ const struct hitsbytarget *h1 = p1;
+ const struct hitsbytarget *h2 = p2;
+ return h2->approximation - h1->approximation;
+}
+
static int targets_termlist_nb(WRBUF wrbuf, struct session *se, int num,
NMEM nmem, int version)
{
static int targets_termlist_nb(WRBUF wrbuf, struct session *se, int num,
NMEM nmem, int version)
{
@@
-1022,7
+1030,10
@@
static int targets_termlist_nb(WRBUF wrbuf, struct session *se, int num,
int count, i;
ht = hitsbytarget_nb(se, &count, nmem);
int count, i;
ht = hitsbytarget_nb(se, &count, nmem);
- qsort(ht, count, sizeof(struct hitsbytarget), cmp_ht);
+ if (version >= 2)
+ qsort(ht, count, sizeof(struct hitsbytarget), cmp_ht_approx);
+ else
+ qsort(ht, count, sizeof(struct hitsbytarget), cmp_ht);
for (i = 0; i < count && i < num && ht[i].hits > 0; i++)
{
for (i = 0; i < count && i < num && ht[i].hits > 0; i++)
{