Added a few casts from zint to double/int where appropriate.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Mar 2005 14:02:08 +0000 (14:02 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Mar 2005 14:02:08 +0000 (14:02 +0000)
Change a few types from int to zint. Out parameter hits in
zebra_search_.. changed from int * to zint *.

14 files changed:
include/idzebra/api.h
include/idzebra/isamb.h
include/zebrautl.h
index/extract.c
index/invstat.c
index/rank1.c
index/zebraapi.c
index/zinfo.h
index/zserver.c
index/zsets.c
index/zvrank.c
isamb/isamb.c
rset/rsmultiandor.c
rset/rsprox.c

index 677dee6..2023533 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: api.h,v 1.13 2005-01-24 14:44:23 adam Exp $
+/* $Id: api.h,v 1.14 2005-03-08 14:02:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -178,10 +178,10 @@ YAZ_EXPORT void zebra_clearError(ZebraHandle zh);
     \param hits of hits is returned
  */
 YAZ_EXPORT int zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
-                               const char *setname, int *hits);
+                               const char *setname, zint *hits);
 
 /** \fn int zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
-    const char *setname, int *hits)
+    const char *setname, zint *hits)
     \brief Search using RPN Query 
     \param zh session handle
     \param o ODR handle
@@ -190,7 +190,7 @@ YAZ_EXPORT int zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
     \param hits number of hits is returned
  */
 YAZ_EXPORT int zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
-                               const char *setname, int *hits);
+                               const char *setname, zint *hits);
 
 /** 
     \fn int zebra_records_retrieve(ZebraHandle zh, ODR stream,
index 1745299..1e5e98a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: isamb.h,v 1.3 2005-01-15 19:38:24 adam Exp $
+/* $Id: isamb.h,v 1.4 2005-03-08 14:02:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -65,7 +65,7 @@ int isamb_unlink(ISAMB b, ISAMC_P pos);
 YAZ_EXPORT
 ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAMB_P pos, int *level, int scope);
 YAZ_EXPORT
-void isamb_pp_close_x(ISAMB_PP pp, int *size, int *blocks);
+void isamb_pp_close_x(ISAMB_PP pp, zint *size, zint *blocks);
 
 YAZ_EXPORT
 int isamb_block_info(ISAMB isamb, int cat);
index 3393468..ecc5d42 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebrautl.h,v 1.13 2005-01-15 19:38:24 adam Exp $
+/* $Id: zebrautl.h,v 1.14 2005-03-08 14:02:08 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -37,4 +37,7 @@ YAZ_BEGIN_CDECL
 zint atoi_zn (const char *buf, zint len);
 YAZ_END_CDECL
 
+#define CAST_ZINT_TO_INT(x) (int)(x)
+#define CAST_ZINT_TO_DOUBLE(x) (double)(x)
+
 #endif
index 84250b5..04acd4b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extract.c,v 1.172 2005-03-05 09:19:14 adam Exp $
+/* $Id: extract.c,v 1.173 2005-03-08 14:02:09 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -1248,7 +1248,7 @@ void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
         (zh->reg->key_buf)[zh->reg->ptr_top - zh->reg->ptr_i] =
            (char*)zh->reg->key_buf + zh->reg->key_buf_used;
 
-       ch = key.mem[0];  /* ordinal for field/use/attribute */
+       ch = (int) key.mem[0];  /* ordinal for field/use/attribute */
 
        zh->reg->key_buf_used +=
            key_SU_encode (ch,((char*)zh->reg->key_buf) +
index c4bc74f..2e5f91e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: invstat.c,v 1.43 2005-01-15 19:38:25 adam Exp $
+/* $Id: invstat.c,v 1.44 2005-03-08 14:02:09 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -36,8 +36,8 @@ struct inv_stat_info {
     int isam_occurrences[20];
     char tmp[128];
     int isamb_levels[10][5];
-    int isamb_sizes[10];
-    int isamb_blocks[10];
+    zint isamb_sizes[10];
+    zint isamb_blocks[10];
     unsigned long cksum;
     int dumpwords;
 };
@@ -124,8 +124,8 @@ static int inv_stat_handle (char *name, const char *info, int pos,
         struct it_key key;
         int cat = (int) (isam_p & 3);
         int level;
-        int size;
-        int blocks;
+        zint size;
+        zint blocks;
         
         pp = isamb_pp_open_x(stat_info->zh->reg->isamb, isam_p, &level, 0);
 
index 0df8d89..7792647 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rank1.c,v 1.22 2005-01-15 19:38:26 adam Exp $
+/* $Id: rank1.c,v 1.23 2005-03-08 14:02:12 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -56,7 +56,7 @@ struct rank_set_info {
     NMEM nmem;
 };
 
-static int log2_int (unsigned g)
+static int log2_int (zint g)
 {
     int n = 0;
     while ((g = g>>1))
index a2256f1..d0f4e79 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.152 2005-01-23 12:36:27 adam Exp $
+/* $Id: zebraapi.c,v 1.153 2005-03-08 14:02:12 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -823,7 +823,7 @@ int zebra_select_databases (ZebraHandle zh, int num_bases,
 }
 
 int zebra_search_RPN (ZebraHandle zh, ODR o,
-                      Z_RPNQuery *query, const char *setname, int *hits)
+                      Z_RPNQuery *query, const char *setname, zint *hits)
 {
     const char *max;
     zint maxhits;
@@ -1687,10 +1687,10 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
                  zh->records_processed, zh->records_inserted,
                  zh->records_updated, zh->records_deleted);
         
-        status->processed = zh->records_processed;
-        status->inserted = zh->records_inserted;
-        status->updated = zh->records_updated;
-        status->deleted = zh->records_deleted;
+        status->processed = (int) zh->records_processed;
+        status->inserted = (int) zh->records_inserted;
+        status->updated = (int) zh->records_updated;
+        status->deleted = (int) zh->records_deleted;
         
         zebra_get_state (zh, &val, &seqno);
         if (val != 'd')
@@ -2091,9 +2091,9 @@ int zebra_delete_record (ZebraHandle zh,
 */
 
 int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
-                     const char *setname, int *numhits)
+                     const char *setname, zint *numhits)
 {
-    int hits = 0;
+    zint hits = 0;
     int res = -1;
     Z_RPNQuery *query;
     ODR odr = odr_createmem(ODR_ENCODE);
index f3cad35..38b2a9a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zinfo.h,v 1.22 2005-03-05 09:19:15 adam Exp $
+/* $Id: zinfo.h,v 1.23 2005-03-08 14:02:12 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -72,7 +72,7 @@ int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *updateHandle);
 typedef struct {
     int recordSize;
     off_t recordOffset;
-    int runNumber;
+    zint runNumber;
 } RecordAttr;
 RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec);
 
index 66dd98a..09b11fe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zserver.c,v 1.129 2005-01-21 18:41:19 adam Exp $
+/* $Id: zserver.c,v 1.130 2005-03-08 14:02:12 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -262,6 +262,7 @@ static void search_terms (ZebraHandle zh, bend_search_rr *r)
 int bend_search (void *handle, bend_search_rr *r)
 {
     ZebraHandle zh = (ZebraHandle) handle;
+    zint zhits = 0;
 
     r->hits = 0;
     r->errcode = 0;
@@ -278,7 +279,11 @@ int bend_search (void *handle, bend_search_rr *r)
     {
     case Z_Query_type_1: case Z_Query_type_101:
        zebra_search_RPN (zh, r->stream, r->query->u.type_1,
-                         r->setname, &r->hits);
+                         r->setname, &zhits);
+       if (zhits >   2147483646)
+           r->hits = 2147483647;
+       else
+           r->hits = (int) zhits;
         zebra_result (zh, &r->errcode, &r->errstring);
         if (!r->errcode)
             search_terms (zh, r);
index 1109f81..01ef906 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zsets.c,v 1.77 2005-01-15 19:38:30 adam Exp $
+/* $Id: zsets.c,v 1.78 2005-03-08 14:02:15 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -825,7 +825,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset, NMEM nmem)
                 (zebraSet->hits)++;
                 psysno = this_sys;
             }
-            (*rc->add) (handle, seqno, termid);
+            (*rc->add) (handle, CAST_ZINT_TO_INT(seqno), termid);
             
             if ((est==-2) && (zebraSet->hits==esthits))
             { /* time to estimate the hits */
index 8bf3224..6239a3a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zvrank.c,v 1.15 2005-01-15 19:38:30 adam Exp $
+/* $Id: zvrank.c,v 1.16 2005-03-08 14:02:15 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -342,7 +342,7 @@ static void idf_squared(void *rsi, void *dsi) {
         if (gocc==0)
             idf=0.0;
         else 
-            idf=blog(num_docs/gocc);
+            idf=blog(CAST_ZINT_TO_DOUBLE(num_docs/gocc));
         idf=idf*idf;
         ds->terms[i].idf=idf;
     }
index ab657d7..675c21e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: isamb.c,v 1.72 2005-03-05 09:19:15 adam Exp $
+/* $Id: isamb.c,v 1.73 2005-03-08 14:02:15 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -141,10 +141,10 @@ static void encode_ptr(char **dst, zint pos)
 
     while (pos > 127)
     {
-         *bp++ = 128 | (pos & 127);
+         *bp++ = (unsigned char) (128 | (pos & 127));
          pos = pos >> 7;
     }
-    *bp++ = pos;
+    *bp++ = (unsigned char) pos;
     *dst = (char *) bp;
 }
 #else
@@ -266,9 +266,9 @@ ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method,
            decode_ptr(&src, &isamb->file[i].head.first_block);
            decode_ptr(&src, &isamb->file[i].head.last_block);
            decode_ptr(&src, &zint_tmp);
-           isamb->file[i].head.block_size = zint_tmp;
+           isamb->file[i].head.block_size = (int) zint_tmp;
            decode_ptr(&src, &zint_tmp);
-           isamb->file[i].head.block_max = zint_tmp;
+           isamb->file[i].head.block_max = (int) zint_tmp;
            decode_ptr(&src, &isamb->file[i].head.free_list);
        }
         assert (isamb->file[i].head.block_size >= isamb->file[i].head.block_offset);
@@ -1269,7 +1269,7 @@ ISAMB_PP isamb_pp_open (ISAMB isamb, ISAMB_P pos, int scope)
     return isamb_pp_open_x(isamb, pos, 0, scope);
 }
 
-void isamb_pp_close_x(ISAMB_PP pp, int *size, int *blocks)
+void isamb_pp_close_x(ISAMB_PP pp, zint *size, zint *blocks)
 {
     int i;
     if (!pp)
@@ -1798,7 +1798,7 @@ void isamb_pp_pos(ISAMB_PP pp, double *current, double *total)
     assert(current);
     assert(p->leaf);
 
-    *total = pp->block[0]->no_items;
+    *total = (double) (pp->block[0]->no_items);
     *current = (double) pp->returned_numbers;
 #if ISAMB_DEBUG
     yaz_log(YLOG_LOG, "isamb_pp_pos returning: cur= %0.1f tot=%0.1f rn="
index b5c1bd2..0204cac 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsmultiandor.c,v 1.13 2005-01-15 20:47:16 adam Exp $
+/* $Id: rsmultiandor.c,v 1.14 2005-03-08 14:02:15 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -586,7 +586,7 @@ static void r_pos (RSFD rfd, double *current, double *total)
     }
     else
     {
-       *current = mrfd->hits;
+       *current = (double) (mrfd->hits);
        *total = *current*stot/scur;
        yaz_log(log_level, "r_pos: =  %0.1f %0.1f",  *current, *total);
     }
index 77aa4a7..d0746dd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rsprox.c,v 1.24 2005-01-17 01:16:37 adam Exp $
+/* $Id: rsprox.c,v 1.25 2005-03-08 14:02:15 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -245,7 +245,7 @@ static int r_forward (RSFD rfd, void *buf, TERMID *term, const void *untilbuf)
                 
                 for (i = 0; i<n; i++)
                 {
-                    int diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
+                    zint diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
                     int excl = info->exclusion;
                     if (!info->ordered && diff < 0)
                         diff = -diff;
@@ -333,7 +333,7 @@ static void r_pos (RSFD rfd, double *current, double *total)
         *total = 0;
     } else {
         r = scur/stot; 
-        *current = p->hits;
+        *current = (double) p->hits;
         *total=*current/r ; 
     }
     yaz_log(YLOG_DEBUG,"prox_pos: [%d] %0.1f/%0.1f= %0.4f ",