[Xapian-devel] uint4 in quartz/flint

James Aylett james-xapian at tartarus.org
Fri Aug 5 11:40:29 BST 2005


We have:

----------------------------------------------------------------------
typedef unsigned long uint4;
----------------------------------------------------------------------

which on an LP64 system is a lie. If uint4 is used on disk (and it's
used in the btree implementation) then it would make the databases
unportable, which probably isn't a good idea (unless we already have
endianness issues, although even there, an ILP32 and an LP64 process
on the same machine should really be able to share databases, although
I haven't checked for alignment problems).

I'm also not sure why quartz_types.h / flint_types.h has a comment
about a double implementation in the following:

----------------------------------------------------------------------
/** An integer type which can store the sum of the lengths of the
documents
 *  in the database.
 *
 *  FIXME - change this to a double?
 */
typedef unsigned long long int flint_totlen_t;
----------------------------------------------------------------------

unsigned long long is dead right on both major data type sizes in use
at the moment. While double certainly takes up 64bits, I don't see why
an integer isn't the right choice. The comment comes from:

----------------------------------------------------------------------
r2514 | richard | 2000-10-20 18:23:11 +0100 (Fri, 20 Oct 2000) | 4
lines

In quartz: store document lengths in termlists, store total
length in a field in the record table, and add methods to access
all these.  QuartzDatabase::get_avlength() now implemented.
----------------------------------------------------------------------



I'm also not keen on the way that we use:

#define UINT64 unsigned long long
#define uint64_t unsigned long long

These should (a) be the same (:-), (b) be typedefs, and (c) not be
there anyway because #include <inttypes.h> will get them for us on
modern systems. (If they aren't there, we can add configure checks -
inttypes.h is in C99.)

(If we used inttypes.h in quartz/flint, the uint4 typedef would be
reliable, or actually just replaced by uint32_t.)

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org




More information about the Xapian-devel mailing list