Ticket #385: diffwithtest.patch

File diffwithtest.patch, 8.7 KB (added by Dylan G, 9 years ago)

64Bit Patch On Master Including Test

  • xapian-core/common/pack.h

    diff --git a/xapian-core/common/pack.h b/xapian-core/common/pack.h
    index 0f2887a..6794da9 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,
    149                   "Template type U too wide for database format");
     148    //static_assert(sizeof(U) <= SORTABLE_UINT_MAX_BYTES,
     149      //"Template type U too wide for database format");
    150150
    151151    char tmp[sizeof(U) + 1];
    152152    char * p = tmp + sizeof(tmp);
  • xapian-core/configure.ac

    diff --git a/xapian-core/configure.ac b/xapian-core/configure.ac
    index 7ff5288..bd99733 100644
    a b if test x$USE_MAINTAINER_MODE = xyes; then  
    456456  test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
    457457fi
    458458
     459
     460AC_ARG_ENABLE([64bit_docid],
     461               [AS_HELP_STRING([--enable-64bit-docid], [enable 64bit docids[default=no]])],
     462  [case ${enableval} in
     463    yes|no) ;;
     464  *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-docid]) ;;
     465  esac],
     466  [enable_64bit_docid=no])
     467
     468AC_ARG_ENABLE([64bit_termcount],
     469               [AS_HELP_STRING([--enable-64bit-termcount], [enable 64bit termcounts[default=no]])],
     470  [case ${enableval} in
     471    yes|no) ;;
     472  *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termcount]) ;;
     473  esac],
     474  [enable_64bit_termcount=no])
     475
    459476AC_ARG_ENABLE([documentation],
    460477  [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
    461478  [case ${enableval} in
    for backend in CHERT GLASS INMEMORY REMOTE ; do  
    12581275    cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_${backend}_BACKEND"
    12591276  fi
    12601277done
     1278
     1279if test yes = "$enable_64bit_docid" ; then
     1280  cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_64BIT_DOCID"
     1281fi
     1282
     1283if test yes = "$enable_64bit_termcount" ; then
     1284  cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_64BIT_TERMCOUNT"
     1285fi
     1286
    12611287dnl For GCC (and compilers which pretend to be GCC) and MSVC, we create some
    12621288dnl ABI checks in the generated version.h, and $CXXFLAGS may contain options
    12631289dnl which affect the ABI (e.g. -fabi-version for GCC) so we want to use these
  • xapian-core/include/xapian/types.h

    diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
    index 130411c..b47e2be 100644
    a b  
    2525# error "Never use <xapian/types.h> directly; include <xapian.h> instead."
    2626#endif
    2727
     28#include <xapian/version.h>
    2829#include <xapian/deprecated.h>
    2930
    3031namespace Xapian {
    namespace Xapian {  
    3435 *  This is used to hold values such as the number of documents in a database
    3536 *  and the frequency of a term in the database.
    3637 */
     38#ifdef XAPIAN_HAS_64BIT_DOCID
     39typedef unsigned long long doccount;
     40#else
    3741typedef unsigned doccount;
     42#endif
    3843
    3944/** A signed difference between two counts of documents.
    4045 *
    4146 *  This is used by the Xapian classes which are STL containers of documents
    4247 *  for "difference_type".
    4348 */
    44 typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */
     49#ifdef XAPIAN_HAS_64BIT_DOCID
     50typedef long long doccount_diff;
     51#else
     52typedef int doccount_diff;
     53#endif
    4554
    4655/** A unique identifier for a document.
    4756 *
    4857 *  Docid 0 is invalid, providing an "out of range" value which can be
    4958 *  used to mean "not a valid document".
    5059 */
     60#ifdef XAPIAN_HAS_64BIT_DOCID
     61typedef unsigned long long docid;
     62#else
    5163typedef unsigned docid;
     64#endif
    5265
    5366/** A normalised document length.
    5467 *
    XAPIAN_DEPRECATED(typedef int percent);  
    6881 *
    6982 *  This is used to hold values such as the Within Document Frequency (wdf).
    7083 */
     84#ifdef XAPIAN_HAS_64BIT_TERMCOUNT
     85typedef unsigned long long termcount;
     86#else
    7187typedef unsigned termcount;
     88#endif
    7289
    7390/** A signed difference between two counts of terms.
    7491 *
    7592 *  This is used by the Xapian classes which are STL containers of terms
    7693 *  for "difference_type".
    7794 */
    78 typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */
     95#ifdef XAPIAN_HAS_64BIT_TERMCOUNT
     96typedef long long termcount_diff;
     97#else
     98typedef int termcount_diff;
     99#endif
    79100
    80101/** A term position within a document or query.
    81102 */
  • xapian-core/include/xapian/version_h.cc

    diff --git a/xapian-core/include/xapian/version_h.cc b/xapian-core/include/xapian/version_h.cc
    index 064761d..0a8c9c6 100644
    a b const char * dummy[] = {  
    157157" */",
    158158"#define XAPIAN_REVISION ",REVISION,
    159159"",
     160"/// XAPIAN_HAS_64BIT_DOCID Defined if the 64bit docid is enabled.",
     161#ifdef XAPIAN_HAS_64BIT_DOCID
     162"#define XAPIAN_HAS_64BIT_DOCID 1",
     163#else
     164"/* #undef XAPIAN_HAS_64BIT_DOCID */",
     165#endif
     166"",
     167"/// XAPIAN_HAS_64BIT_TERMCOUNT Defined if the 64bit termcount is enabled.",
     168#ifdef XAPIAN_HAS_64BIT_TERMCOUNT
     169"#define XAPIAN_HAS_64BIT_TERMCOUNT 1",
     170#else
     171"/* #undef XAPIAN_HAS_64BIT_TERMCOUNT */",
     172#endif
     173"",
    160174"/// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled.",
    161175#ifdef XAPIAN_HAS_CHERT_BACKEND
    162176"#define XAPIAN_HAS_CHERT_BACKEND 1",
  • xapian-core/net/length.cc

    diff --git a/xapian-core/net/length.cc b/xapian-core/net/length.cc
    index 6f4ec33..a4a59a8 100644
    a b decode_length(const char ** p, const char *end, uint64_t & out)  
    103103}
    104104
    105105void
     106decode_length(const char ** p, const char *end, unsigned long long & out)
     107{
     108    decode_length_(p, end, out);
     109}
     110
     111void
    106112decode_length_and_check(const char ** p, const char *end, uint32_t & out)
    107113{
    108114    decode_length_and_check_(p, end, out);
    decode_length_and_check(const char ** p, const char *end, uint64_t & out)  
    113119{
    114120    decode_length_and_check_(p, end, out);
    115121}
     122
     123void
     124decode_length_and_check(const char ** p, const char *end, unsigned long long & out)
     125{
     126    decode_length_and_check_(p, end, out);
     127}
  • xapian-core/net/length.h

    diff --git a/xapian-core/net/length.h b/xapian-core/net/length.h
    index b286177..5461cd4 100644
    a b void decode_length(const char ** p, const char *end, uint32_t & out);  
    6666
    6767void decode_length(const char ** p, const char *end, uint64_t & out);
    6868
     69void decode_length(const char ** p, const char *end, unsigned long long & out);
     70
    6971/** Decode a length encoded by encode_length.
    7072 *
    7173 *  Also checks the result against the amount of data remaining after the
    void decode_length_and_check(const char ** p, const char *end, uint32_t & out);  
    8082
    8183void decode_length_and_check(const char ** p, const char *end, uint64_t & out);
    8284
     85void decode_length_and_check(const char ** p, const char *end, unsigned long long & out);
     86
    8387#endif //XAPIAN_INCLUDED_LENGTH_H
  • xapian-core/tests/api_backend.cc

    diff --git a/xapian-core/tests/api_backend.cc b/xapian-core/tests/api_backend.cc
    index d86a580..43f5279 100644
    a b DEFINE_TESTCASE(totaldoclen1, writable) {  
    9393    return true;
    9494}
    9595
     96#ifdef XAPIAN_HAS_64BIT_DOCID
     97// Assert that exceeding 32bit in combined database doesn't cause a problem
     98// when using 64bit docids.
     99DEFINE_TESTCASE(exceed32bitcombineddb1, writable) {
     100    // The InMemory backend uses a vector for the documents, so trying to add
     101    // document "-1" will fail because we can't allocate enough memory!
     102    SKIP_TEST_FOR_BACKEND("inmemory");
     103
     104    Xapian::WritableDatabase db1 = get_writable_database();
     105    Xapian::WritableDatabase db2 = get_writable_database();
     106    Xapian::Document doc;
     107    doc.set_data("prose");
     108    doc.add_term("word");
     109
     110    Xapian::docid max_id = 0xffffffff;
     111
     112    db1.replace_document(max_id, doc);
     113    db2.replace_document(max_id, doc);
     114
     115    Xapian::Database db = get_database("");
     116    db.add_database(db1);
     117    db.add_database(db2);
     118
     119    Xapian::Enquire enquire(db);
     120    enquire.set_query(Xapian::Query::MatchAll);
     121    Xapian::MSet mymset = enquire.get_mset(0, 10);
     122
     123    TEST_EQUAL(2, mymset.size());
     124
     125    for (Xapian::MSetIterator i = mymset.begin(); i != mymset.end(); ++i) {
     126      TEST_EQUAL("prose", i.get_document().get_data());
     127    }
     128
     129    return true;
     130}
     131#endif
     132
    96133DEFINE_TESTCASE(dbstats1, backend) {
    97134    Xapian::Database db = get_database("etext");
    98135
  • xapian-core/tests/api_wrdb.cc

    diff --git a/xapian-core/tests/api_wrdb.cc b/xapian-core/tests/api_wrdb.cc
    index 5bb8072..833bbef 100644
    a b DEFINE_TESTCASE(nomoredocids1, writable) {  
    16141614    doc.set_data("prose");
    16151615    doc.add_term("word");
    16161616
    1617     db.replace_document(Xapian::docid(-1), doc);
     1617    // FIXME: This probably should use the _MAX_DOCID values
     1618    Xapian::docid max_id = 0xffffffff;
     1619
     1620    db.replace_document(max_id, doc);
    16181621
    16191622    TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc));
    16201623