Ticket #385: v1.2.21-x64.patch

File v1.2.21-x64.patch, 7.4 KB (added by Dylan G, 9 years ago)

Here is the patch we're currently using against v1.2.21 . I will submit another patch against v1.3.3 which will be a little more tidy but this is just here in case anybody wants to use it. It passes all the tests on debian and appears to be working on our production systems but we are only using it for searching right now. I've run searches across combined databases with max docid > 232 and it has successfully solved all our DocNotFoundError problems. There are a few outstanding problems with this: 1. Tests don't compile on mac (just scaleweight1 and scaleweight2) 2. There are some hardcoded backend limits which I've not bothered to change

  • xapian-core/backends/brass/brass_database.cc

    diff --git a/xapian-core/backends/brass/brass_database.cc b/xapian-core/backends/brass/brass_database.cc
    index 2626782..b73dedf 100644
    a b BrassWritableDatabase::add_document(const Xapian::Document & document)  
    11061106{
    11071107    LOGCALL(DB, Xapian::docid, "BrassWritableDatabase::add_document", document);
    11081108    // Make sure the docid counter doesn't overflow.
    1109     if (stats.get_last_docid() == Xapian::docid(-1))
     1109    if (stats.get_last_docid() == 0xffffffff)
    11101110        throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
    11111111    // Use the next unused document ID.
    11121112    RETURN(add_document_(stats.get_next_docid(), document));
  • xapian-core/backends/chert/chert_database.cc

    diff --git a/xapian-core/backends/chert/chert_database.cc b/xapian-core/backends/chert/chert_database.cc
    index 0320d1d..83b9597 100644
    a b ChertWritableDatabase::add_document(const Xapian::Document & document)  
    11521152{
    11531153    LOGCALL(DB, Xapian::docid, "ChertWritableDatabase::add_document", document);
    11541154    // Make sure the docid counter doesn't overflow.
    1155     if (stats.get_last_docid() == Xapian::docid(-1))
     1155    if (stats.get_last_docid() == 0xffffffff)
    11561156        throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
    11571157    // Use the next unused document ID.
    11581158    RETURN(add_document_(stats.get_next_docid(), document));
  • xapian-core/backends/flint/flint_database.cc

    diff --git a/xapian-core/backends/flint/flint_database.cc b/xapian-core/backends/flint/flint_database.cc
    index e98cee8..f43b5af 100644
    a b FlintWritableDatabase::add_document(const Xapian::Document & document)  
    11271127{
    11281128    LOGCALL(DB, Xapian::docid, "FlintWritableDatabase::add_document", document);
    11291129    // Make sure the docid counter doesn't overflow.
    1130     if (lastdocid == Xapian::docid(-1))
     1130    if (lastdocid == 0xffffffff)
    11311131        throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
    11321132    // Use the next unused document ID.
    11331133    RETURN(add_document_(++lastdocid, document));
  • xapian-core/common/pack.h

    diff --git a/xapian-core/common/pack.h b/xapian-core/common/pack.h
    index 01143eb..d37e104 100644
    a b pack_uint_preserving_sort(std::string & s, U value)  
    145145{
    146146    // Check U is an unsigned type.
    147147    STATIC_ASSERT_UNSIGNED_TYPE(U);
    148     STATIC_ASSERT(sizeof(U) <= SORTABLE_UINT_MAX_BYTES);
     148    //STATIC_ASSERT(sizeof(U) <= SORTABLE_UINT_MAX_BYTES);
    149149
    150150    char tmp[sizeof(U) + 1];
    151151    char * p = tmp + sizeof(tmp);
  • xapian-core/include/xapian/types.h

    diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
    index 30e6160..d11d20b 100644
    a b  
    2121#ifndef XAPIAN_INCLUDED_TYPES_H
    2222#define XAPIAN_INCLUDED_TYPES_H
    2323
     24#define USE_64BIT_DOCID 1
     25#define USE_64BIT_TERMCOUNT 1
     26
    2427namespace Xapian {
    2528
    2629/** A count of documents.
    namespace Xapian {  
    2831 *  This is used to hold values such as the number of documents in a database
    2932 *  and the frequency of a term in the database.
    3033 */
     34#ifdef USE_64BIT_DOCID
     35typedef unsigned long long doccount;
     36#else
    3137typedef unsigned doccount;
     38#endif
    3239
    3340/** A signed difference between two counts of documents.
    3441 *
    3542 *  This is used by the Xapian classes which are STL containers of documents
    3643 *  for "difference_type".
    3744 */
    38 typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */
     45/* FIXME: can overflow. */
     46#ifdef USE_64BIT_DOCID
     47typedef long long doccount_diff;
     48#else
     49typedef int doccount_diff;
     50#endif
    3951
    4052/** A unique identifier for a document.
    4153 *
    4254 *  Docid 0 is invalid, providing an "out of range" value which can be
    4355 *  used to mean "not a valid document".
    4456 */
     57#ifdef USE_64BIT_DOCID
     58typedef unsigned long long docid;
     59#else
    4560typedef unsigned docid;
     61#endif
    4662
    4763/** A normalised document length.
    4864 *
    typedef int percent;  
    5874 *
    5975 *  This is used to hold values such as the Within Document Frequency (wdf).
    6076 */
     77#ifdef USE_64BIT_TERMCOUNT
     78typedef unsigned long long termcount;
     79#else
    6180typedef unsigned termcount;
     81#endif
    6282
    6383/** A signed difference between two counts of terms.
    6484 *
    6585 *  This is used by the Xapian classes which are STL containers of terms
    6686 *  for "difference_type".
    6787 */
    68 typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */
     88/* FIXME: can overflow. */
     89#ifdef USE_64BIT_DOCID
     90typedef long long termcount_diff;
     91#else
     92typedef int termcount_diff;
     93#endif
    6994
    7095/** A term position within a document or query.
    7196 */
  • xapian-core/net/remoteconnection.cc

    diff --git a/xapian-core/net/remoteconnection.cc b/xapian-core/net/remoteconnection.cc
    index c7515bb..a8de28c 100644
    a b RemoteConnection::get_message(string &result, double end_time)  
    489489    unsigned char ch;
    490490    int shift = 0;
    491491    do {
    492         if (i == buffer.end() || shift > 28) {
     492        if (i == buffer.end() || shift > 63) {
    493493            // Something is very wrong...
    494494            throw Xapian::NetworkError("Insane message length specified!");
    495495        }
  • xapian-core/net/serialise.cc

    diff --git a/xapian-core/net/serialise.cc b/xapian-core/net/serialise.cc
    index af035b9..ef5b26d 100644
    a b decode_length(const char ** p, const char *end, bool check_remaining)  
    5151        unsigned char ch;
    5252        int shift = 0;
    5353        do {
    54             if (*p == end || shift > 28)
     54            if (*p == end || shift > 63)
    5555                throw Xapian::NetworkError("Bad encoded length: insufficient data");
    5656            ch = *(*p)++;
    5757            len |= size_t(ch & 0x7f) << shift;
  • xapian-core/tests/api_wrdb.cc

    diff --git a/xapian-core/tests/api_wrdb.cc b/xapian-core/tests/api_wrdb.cc
    index 4f98d55..e602e7b 100644
    a b DEFINE_TESTCASE(nomoredocids1, writable) {  
    15921592    doc.set_data("prose");
    15931593    doc.add_term("word");
    15941594
    1595     db.replace_document(Xapian::docid(-1), doc);
     1595    db.replace_document(0xffffffff, doc);
    15961596
    15971597    TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc));
    15981598
  • xapian-core/tests/harness/testutils.cc

    diff --git a/xapian-core/tests/harness/testutils.cc b/xapian-core/tests/harness/testutils.cc
    index d2bcf21..e56d0d4 100644
    a b  
    3030
    3131using namespace std;
    3232
    33 ostream &
    34 operator<<(ostream &os, const vector<unsigned int> &ints)
     33template<class T> ostream &
     34operator<<(ostream &os, const vector<T> &ints)
    3535{
    3636    copy(ints.begin(), ints.end(),
    37          ostream_iterator<unsigned int>(os, ", "));
     37            ostream_iterator<T>(os, ", "));
    3838    return os;
    3939}
    4040
  • xapian-core/tests/harness/testutils.h

    diff --git a/xapian-core/tests/harness/testutils.h b/xapian-core/tests/harness/testutils.h
    index b0d4cd4..357a287 100644
    a b  
    2828// ######################################################################
    2929// Useful display operators
    3030
     31template<class T>
    3132std::ostream &operator<<(std::ostream &os,
    32                          const std::vector<unsigned int> &ints);
     33                         const std::vector<T> &ints);
    3334
    3435// ######################################################################
    3536// Useful comparison operators