New result set method: r_score.
[idzebra-moved-to-github.git] / rset / rsrel.c
index 9fc32d4..0d52250 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rsrel.c,v $
- * Revision 1.4  1995-09-14 07:48:56  adam
+ * Revision 1.5  1995-10-06 14:38:06  adam
+ * New result set method: r_score.
+ * Local no (sysno) and score is transferred to retrieveCtrl.
+ *
+ * Revision 1.4  1995/09/14  07:48:56  adam
  * Other score calculation.
  *
  * Revision 1.3  1995/09/11  15:23:40  adam
@@ -35,6 +39,7 @@ static void r_rewind (RSFD rfd);
 static int r_count (rset_control *ct);
 static int r_read (RSFD rfd, void *buf);
 static int r_write (RSFD rfd, const void *buf);
+static int r_score (RSFD rfd, int *score);
 
 static const rset_control control = 
 {
@@ -47,7 +52,8 @@ static const rset_control control =
     r_rewind,
     r_count,
     r_read,
-    r_write
+    r_write,
+    r_score
 };
 
 const rset_control *rset_kind_relevance = &control;
@@ -281,14 +287,23 @@ static int r_read (RSFD rfd, void *buf)
     if (p->position <= 0)
         return 0;
     --(p->position);
-    logf (LOG_DEBUG, "score: %f",
-          info->score_buf[info->sort_idx[p->position]]);
     memcpy ((char*) buf,
             info->key_buf + info->key_size * info->sort_idx[p->position],
             info->key_size);
     return 1;
 }
 
+static int r_score (RSFD rfd, int *score)
+{
+    struct rset_rel_rfd *p = rfd;
+    struct rset_rel_info *info = p->info;
+
+    if (p->position < 0)
+        return 0;
+    *score = (int) (1000*info->score_buf[info->sort_idx[p->position]]);
+    return 1;
+}
+
 static int r_write (RSFD rfd, const void *buf)
 {
     logf (LOG_FATAL, "relevance set type is read-only");