Also, please use `totlen_t` as the type for a sum of document lengths as it could easily overflow `Xapian::doccount`.  By default `Xapian::doccount` is 32 bit by default and `totlen_t` is 64 bit.