X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Frankstatic.c;h=f3d773c9c02b16fbb193c72d76c15a8ac929a298;hp=cc86ca10e150ed546a225f88cf566868a28382bb;hb=8a0144a3925311102133d62ac6258ace8d7187eb;hpb=1369748dd7899789c97d94801048bf942e0cc6e6 diff --git a/index/rankstatic.c b/index/rankstatic.c index cc86ca1..f3d773c 100644 --- a/index/rankstatic.c +++ b/index/rankstatic.c @@ -1,8 +1,5 @@ -/* $Id: rankstatic.c,v 1.7 2006-05-19 23:20:24 adam Exp $ - Copyright (C) 1995-2005 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -15,11 +12,14 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -41,7 +41,7 @@ struct rank_set_info { }; /* - * create: Creates/Initialises this rank handler. This routine is + * create: Creates/Initialises this rank handler. This routine is * called exactly once. The routine returns the class_handle. */ static void *create (ZebraHandle zh) @@ -71,11 +71,11 @@ static void destroy (struct zebra_register *reg, void *class_handle) * each result set. The returned handle is a "set handle" and * will be used in each of the handlers below. */ -static void *begin (struct zebra_register *reg, +static void *begin (struct zebra_register *reg, void *class_handle, RSET rset, NMEM nmem, TERMID *terms, int numterms) { - struct rank_set_info *si = + struct rank_set_info *si = (struct rank_set_info *) nmem_malloc (nmem, sizeof(*si)); int i; @@ -86,12 +86,12 @@ static void *begin (struct zebra_register *reg, { struct ord_list *ol = terms[i]->ol; - yaz_log(log_level, "i=%d flags=%s '%s'", i, + yaz_log(log_level, "i=%d flags=%s '%s'", i, terms[i]->flags, terms[i]->name ); for (; ol; ol = ol->next) { - int index_type = 0; + const char *index_type = 0; const char *db = 0; const char *string_index = 0; int set = -1; @@ -101,13 +101,13 @@ static void *begin (struct zebra_register *reg, ol->ord, &index_type, &db, &string_index); if (string_index) - yaz_log(log_level, " ord=%d index_type=%c db=%s str-index=%s", - ol->ord, index_type, db, string_index); + yaz_log(log_level, " ord=%d index_type=%s db=%s str-index=%s", + ol->ord, index_type, db, string_index); else - yaz_log(log_level, " ord=%d index_type=%c db=%s set=%d use=%d", - ol->ord, index_type, db, set, use); + yaz_log(log_level, " ord=%d index_type=%s db=%s set=%d use=%d", + ol->ord, index_type, db, set, use); } - if (!strncmp (terms[i]->flags, "rank,", 5)) + if (!strncmp (terms[i]->flags, "rank,", 5)) (si->no_rank_entries)++; } return si; @@ -133,7 +133,7 @@ static void add (void *set_handle, int seqno, TERMID term) } /* - * calc: Called for each document in a result. This handler should + * calc: Called for each document in a result. This handler should * produce a score based on previous call(s) to the add handler. The * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. @@ -148,7 +148,10 @@ static int calc (void *set_handle, zint sysno, zint staticrank, /* if we set *stop_flag = 1, we stop processing (of result set list) */ /* staticrank = 0 is highest, MAXINT lowest */ - return INT_MAX - staticrank; /* but score is reverse (logical) */ + if (staticrank >= INT_MAX) + return 0; + /* but score is reverse (logical) */ + return INT_MAX - CAST_ZINT_TO_INT(staticrank); } /* @@ -178,11 +181,12 @@ static struct rank_control rank_control = { calc, add, }; - + struct rank_control *rank_static_class = &rank_control; /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab