Ticket #385: v1.3.3-x64.patch

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

Patch for 64 bit on v1.3.3

  • xapian-bindings/java/SmokeTest.java

    diff --git a/xapian-bindings/java/SmokeTest.java b/xapian-bindings/java/SmokeTest.java
    index 21355d1..e24466e 100644
    a b public class SmokeTest {  
    7474            // FIXME: was WritableDatabase db = Xapian.InMemory.open();
    7575            WritableDatabase db = InMemory.open();
    7676            db.addDocument(doc);
    77             if (db.getDocCount() != 1) {
    78                 System.err.println("Unexpected db.getDocCount()");
     77            if (!db.getDocCount().equals(java.math.BigInteger.valueOf(1))) {
     78                System.err.println("Unexpected db.getDocCount(): " + db.getDocCount().toString());
    7979                System.exit(1);
    8080            }
    8181
    public class SmokeTest {  
    109109            }
    110110            Enquire enq = new Enquire(db);
    111111            enq.setQuery(new Query(Query.OP_OR, "there", "is"));
    112             MSet mset = enq.getMSet(0, 10);
    113             if (mset.size() != 1) {
    114                 System.err.println("Unexpected mset.size()");
     112            MSet mset = enq.getMSet(java.math.BigInteger.valueOf(0), java.math.BigInteger.valueOf(10));
     113            if (!mset.size().equals(java.math.BigInteger.valueOf(1))) {
     114                System.err.println("Unexpected mset.size(): " + mset.size().toString());
    115115                System.exit(1);
    116116            }
    117117            MSetIterator m_itor = mset.begin();
    118118            Document m_doc = null;
    119             long m_id;
     119            java.math.BigInteger m_id;
    120120            while(m_itor.hasNext()) {
    121121                m_id = m_itor.next();
    122122                if(m_itor.hasNext()) {
    public class SmokeTest {  
    125125            }
    126126
    127127            // Only one doc exists in this mset
    128             if(m_doc != null && m_doc.getDocId() != 0) {
     128            if(m_doc != null && m_doc.getDocId() != java.math.BigInteger.valueOf(0)) {
    129129                System.err.println("Unexpected docid");
    130130                    System.exit(1);
    131131            }
    132132
    133133            String term_str = "";
    134             TermIterator itor = enq.getMatchingTermsBegin(mset.getElement(0));
     134            TermIterator itor = enq.getMatchingTermsBegin(mset.getElement(java.math.BigInteger.valueOf(0)));
    135135            while (itor.hasNext()) {
    136136                term_str += itor.next();
    137137                if (itor.hasNext())
    public class SmokeTest {  
    162162            }
    163163*/
    164164            RSet rset = new RSet();
    165             rset.addDocument(1);
    166             ESet eset = enq.getESet(10, rset, new MyExpandDecider());
     165            rset.addDocument(java.math.BigInteger.valueOf(1));
     166            ESet eset = enq.getESet(java.math.BigInteger.valueOf(10), rset, new MyExpandDecider());
    167167            // FIXME: temporary simple check
    168             if (0 == eset.size()) {
     168            if (java.math.BigInteger.valueOf(0).equals(eset.size())) {
    169169                System.err.println("ESet.size() was 0");
    170170                System.exit(1);
    171171            }
    172172
    173             int count = 0;
     173            java.math.BigInteger count = java.math.BigInteger.valueOf(0);
    174174            for(ESetIterator eit = eset.begin(); eit.hasNext(); ) {
    175175            // for (int i = 0; i < eset.size(); i++) {
    176176                if (eit.getTerm().charAt(0) == 'a') {
    177177                    System.err.println("MyExpandDecider wasn't used");
    178178                    System.exit(1);
    179179                }
    180                 ++count;
     180                count = count.add(java.math.BigInteger.valueOf(1));
    181181                eit.next();
    182182            }
    183             if (count != eset.size()) {
     183            if (!count.equals(eset.size())) {
    184184                System.err.println("ESet.size() mismatched number of terms returned by ESetIterator");
    185185                System.err.println(count + " " + eset.size());
    186186                System.exit(1);
  • xapian-core/api/snipper.cc

    diff --git a/xapian-core/api/snipper.cc b/xapian-core/api/snipper.cc
    index c038746..d5ef158 100644
    a b Snipper::~Snipper()  
    6161}
    6262
    6363void
    64 Snipper::set_mset(const MSet & mset, unsigned int rm_docno)
     64Snipper::set_mset(const MSet & mset, Xapian::doccount rm_docno)
    6565{
    6666    internal->calculate_rm(mset, rm_docno);
    6767}
    Snipper::set_mset(const MSet & mset, unsigned int rm_docno)  
    6969string
    7070Snipper::generate_snippet(const string & text,
    7171                          size_t length,
    72                           unsigned int window_size,
     72                          Xapian::termcount window_size,
    7373                          double smoothing)
    7474{
    7575    return internal->generate_snippet(text, length, window_size, smoothing);
  • xapian-core/api/snipperinternal.h

    diff --git a/xapian-core/api/snipperinternal.h b/xapian-core/api/snipperinternal.h
    index def5c8b..e3c2b41 100644
    a b class Snipper::Internal : public Xapian::Internal::intrusive_base {  
    120120        /** Return snippet generated from text using the precalculated relevance model */
    121121        std::string generate_snippet(const std::string & text,
    122122                                     size_t length,
    123                                      unsigned int window_size,
     123                                     Xapian::termcount window_size,
    124124                                     double smoothing);
    125125
    126126        /** Calculate relevance model based on a MSet.
  • 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 a269ce9..0d1fd59 100644
    a b ChertWritableDatabase::add_document(const Xapian::Document & document)  
    11451145{
    11461146    LOGCALL(DB, Xapian::docid, "ChertWritableDatabase::add_document", document);
    11471147    // Make sure the docid counter doesn't overflow.
    1148     if (stats.get_last_docid() == Xapian::docid(-1))
     1148    if (stats.get_last_docid() == CHERT_MAX_DOCID)
    11491149        throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
    11501150    // Use the next unused document ID.
    11511151    RETURN(add_document_(stats.get_next_docid(), document));
  • xapian-core/backends/chert/chert_types.h

    diff --git a/xapian-core/backends/chert/chert_types.h b/xapian-core/backends/chert/chert_types.h
    index 6ff8798..3bf3d6f 100644
    a b typedef unsigned int chert_doclen_t;  
    5555 *  correspondingly.
    5656 */
    5757#define CHERT_DEFAULT_BLOCK_SIZE 8192
     58#define CHERT_MAX_DOCID 0xffffffff
    5859
    5960#endif /* OM_HGUARD_CHERT_TYPES_H */
  • xapian-core/backends/glass/glass_database.cc

    diff --git a/xapian-core/backends/glass/glass_database.cc b/xapian-core/backends/glass/glass_database.cc
    index db6facf..c84f588 100644
    a b GlassWritableDatabase::add_document(const Xapian::Document & document)  
    989989{
    990990    LOGCALL(DB, Xapian::docid, "GlassWritableDatabase::add_document", document);
    991991    // Make sure the docid counter doesn't overflow.
    992     if (stats.get_last_docid() == Xapian::docid(-1))
     992    if (stats.get_last_docid() == GLASS_MAX_DOCID)
    993993        throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
    994994    // Use the next unused document ID.
    995995    RETURN(add_document_(stats.get_next_docid(), document));
  • xapian-core/backends/glass/glass_defs.h

    diff --git a/xapian-core/backends/glass/glass_defs.h b/xapian-core/backends/glass/glass_defs.h
    index baab8f4..824a4a9 100644
    a b  
    2828
    2929/// Default B-tree block size.
    3030#define GLASS_DEFAULT_BLOCKSIZE 8192
     31#define GLASS_MAX_DOCID 0xffffffff
    3132
    3233namespace Glass {
    3334    enum table_type {
  • xapian-core/common/pack.h

    diff --git a/xapian-core/common/pack.h b/xapian-core/common/pack.h
    index 0f2887a..d0270ba 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/include/xapian/types.h

    diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
    index 130411c..65ce52a 100644
    a b  
    2727
    2828#include <xapian/deprecated.h>
    2929
     30#define USE_64BIT_DOCID 1
     31#define USE_64BIT_TERMCOUNT 1
     32
    3033namespace Xapian {
    3134
    3235/** A count of documents.
    namespace Xapian {  
    3437 *  This is used to hold values such as the number of documents in a database
    3538 *  and the frequency of a term in the database.
    3639 */
     40#ifdef USE_64BIT_DOCID
     41typedef unsigned long long doccount;
     42#else
    3743typedef unsigned doccount;
     44#endif
    3845
    3946/** A signed difference between two counts of documents.
    4047 *
    4148 *  This is used by the Xapian classes which are STL containers of documents
    4249 *  for "difference_type".
    4350 */
    44 typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */
     51/* FIXME: can overflow. */
     52#ifdef USE_64BIT_DOCID
     53typedef long long doccount_diff;
     54#else
     55typedef int doccount_diff;
     56#endif
    4557
    4658/** A unique identifier for a document.
    4759 *
    4860 *  Docid 0 is invalid, providing an "out of range" value which can be
    4961 *  used to mean "not a valid document".
    5062 */
     63#ifdef USE_64BIT_DOCID
     64typedef unsigned long long docid;
     65#else
    5166typedef unsigned docid;
     67#endif
    5268
    5369/** A normalised document length.
    5470 *
    XAPIAN_DEPRECATED(typedef int percent);  
    6884 *
    6985 *  This is used to hold values such as the Within Document Frequency (wdf).
    7086 */
     87#ifdef USE_64BIT_TERMCOUNT
     88typedef unsigned long long termcount;
     89#else
    7190typedef unsigned termcount;
     91#endif
    7292
    7393/** A signed difference between two counts of terms.
    7494 *
    7595 *  This is used by the Xapian classes which are STL containers of terms
    7696 *  for "difference_type".
    7797 */
    78 typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */
     98/* FIXME: can overflow. */
     99#ifdef USE_64BIT_DOCID
     100typedef long long termcount_diff;
     101#else
     102typedef int termcount_diff;
     103#endif
    79104
    80105/** A term position within a document or query.
    81106 */
  • xapian-core/net/length.cc

    diff --git a/xapian-core/net/length.cc b/xapian-core/net/length.cc
    index 535e955..1bf2abb 100644
    a b decode_length(const char ** p, const char *end, bool check_remaining)  
    6868        unsigned char ch;
    6969        int shift = 0;
    7070        do {
    71             if (*p == end || shift > 28)
     71            if (*p == end || shift > 63)
    7272                throw_network_error("Bad encoded length: insufficient data");
    7373            ch = *(*p)++;
    7474            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 ffef490..12659eb 100644
    a b DEFINE_TESTCASE(nomoredocids1, writable) {  
    16151615    doc.set_data("prose");
    16161616    doc.add_term("word");
    16171617
    1618     db.replace_document(Xapian::docid(-1), doc);
     1618    db.replace_document(0xffffffff, doc);
    16191619
    16201620    TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc));
    16211621
  • 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 1af4c2e..581c537 100644
    a b  
    2929// ######################################################################
    3030// Useful display operators
    3131
     32template<class T>
    3233std::ostream &operator<<(std::ostream &os,
    33                          const std::vector<unsigned int> &ints);
     34                         const std::vector<T> &ints);
    3435
    3536// ######################################################################
    3637// Useful comparison operators