#include <math.h>
#include <stdlib.h>
+#include "pazpar2_config.h"
#include "relevance.h"
#include "session.h"
+#include "client.h"
#ifdef WIN32
#define log2(x) (log(x)/log(2))
for (; entries; entries = entries->next, i++)
{
if (*norm_str && !strcmp(norm_str, entries->norm_str))
- {
- break;
- if (!highlight)
- {
- highlight = 1;
- wrbuf_puts(w_snippet, "<match>");
- }
break;
- }
}
if (entries)
{
}
// Prepare for a relevance-sorted read
-void relevance_prepare_read(struct relevance *rel, struct reclist *reclist)
+void relevance_prepare_read(struct relevance *rel, struct reclist *reclist,
+ enum conf_sortkey_type type)
{
int i;
float *idfvec = xmalloc(rel->vec_len * sizeof(float));
+ int n_clients = clients_count();
+ struct client * clients[n_clients];
+ yaz_log(YLOG_LOG,"round-robin: have %d clients", n_clients);
+ for (i = 0; i < n_clients; i++)
+ clients[i] = 0;
+
reclist_enter(reclist);
// Calculate document frequency vector for each term.
{
wrbuf_printf(w, "score = relevance(%d);\n", relevance);
}
+ // Experimental round-robin
+ // Overwrites the score calculated above, but I keep it there to
+ // get the log entries
+ if (type == Metadata_sortkey_relevance_h) {
+ struct record *record;
+ int thisclient = 0;
+ struct record *bestrecord = 0;
+ int nclust = 0;
+ for (record = rec->records; record; record = record->next) {
+ if ( bestrecord == 0 || bestrecord->position < record->position )
+ bestrecord = record;
+ nclust++;
+ }
+ while ( clients[thisclient] != 0
+ && clients[thisclient] != bestrecord->client )
+ thisclient++;
+ if ( clients[thisclient] == 0 )
+ {
+ yaz_log(YLOG_LOG,"round-robin: found new client at %d: p=%p\n", thisclient, bestrecord->client);
+ clients[thisclient] = bestrecord->client;
+ }
+ int tfrel = relevance;
+ relevance = -(bestrecord->position * n_clients + thisclient) ;
+ wrbuf_printf(w,"round-robin score: pos=%d client=%d ncl=%d tfscore=%d score=%d\n",
+ bestrecord->position, thisclient, nclust, tfrel, relevance );
+ yaz_log(YLOG_LOG,"round-robin score: pos=%d client=%d ncl=%d score=%d",
+ bestrecord->position, thisclient, nclust, relevance );
+ }
rec->relevance_score = relevance;
}
reclist_leave(reclist);