diff --git a/xapian-bindings/java/SmokeTest.java b/xapian-bindings/java/SmokeTest.java
index 21355d1..e24466e 100644
|
a
|
b
|
public class SmokeTest {
|
| 74 | 74 | // FIXME: was WritableDatabase db = Xapian.InMemory.open(); |
| 75 | 75 | WritableDatabase db = InMemory.open(); |
| 76 | 76 | 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()); |
| 79 | 79 | System.exit(1); |
| 80 | 80 | } |
| 81 | 81 | |
| … |
… |
public class SmokeTest {
|
| 109 | 109 | } |
| 110 | 110 | Enquire enq = new Enquire(db); |
| 111 | 111 | 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()); |
| 115 | 115 | System.exit(1); |
| 116 | 116 | } |
| 117 | 117 | MSetIterator m_itor = mset.begin(); |
| 118 | 118 | Document m_doc = null; |
| 119 | | long m_id; |
| | 119 | java.math.BigInteger m_id; |
| 120 | 120 | while(m_itor.hasNext()) { |
| 121 | 121 | m_id = m_itor.next(); |
| 122 | 122 | if(m_itor.hasNext()) { |
| … |
… |
public class SmokeTest {
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // 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)) { |
| 129 | 129 | System.err.println("Unexpected docid"); |
| 130 | 130 | System.exit(1); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | String term_str = ""; |
| 134 | | TermIterator itor = enq.getMatchingTermsBegin(mset.getElement(0)); |
| | 134 | TermIterator itor = enq.getMatchingTermsBegin(mset.getElement(java.math.BigInteger.valueOf(0))); |
| 135 | 135 | while (itor.hasNext()) { |
| 136 | 136 | term_str += itor.next(); |
| 137 | 137 | if (itor.hasNext()) |
| … |
… |
public class SmokeTest {
|
| 162 | 162 | } |
| 163 | 163 | */ |
| 164 | 164 | 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()); |
| 167 | 167 | // FIXME: temporary simple check |
| 168 | | if (0 == eset.size()) { |
| | 168 | if (java.math.BigInteger.valueOf(0).equals(eset.size())) { |
| 169 | 169 | System.err.println("ESet.size() was 0"); |
| 170 | 170 | System.exit(1); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | | int count = 0; |
| | 173 | java.math.BigInteger count = java.math.BigInteger.valueOf(0); |
| 174 | 174 | for(ESetIterator eit = eset.begin(); eit.hasNext(); ) { |
| 175 | 175 | // for (int i = 0; i < eset.size(); i++) { |
| 176 | 176 | if (eit.getTerm().charAt(0) == 'a') { |
| 177 | 177 | System.err.println("MyExpandDecider wasn't used"); |
| 178 | 178 | System.exit(1); |
| 179 | 179 | } |
| 180 | | ++count; |
| | 180 | count = count.add(java.math.BigInteger.valueOf(1)); |
| 181 | 181 | eit.next(); |
| 182 | 182 | } |
| 183 | | if (count != eset.size()) { |
| | 183 | if (!count.equals(eset.size())) { |
| 184 | 184 | System.err.println("ESet.size() mismatched number of terms returned by ESetIterator"); |
| 185 | 185 | System.err.println(count + " " + eset.size()); |
| 186 | 186 | System.exit(1); |
diff --git a/xapian-core/api/snipper.cc b/xapian-core/api/snipper.cc
index c038746..d5ef158 100644
|
a
|
b
|
Snipper::~Snipper()
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | void |
| 64 | | Snipper::set_mset(const MSet & mset, unsigned int rm_docno) |
| | 64 | Snipper::set_mset(const MSet & mset, Xapian::doccount rm_docno) |
| 65 | 65 | { |
| 66 | 66 | internal->calculate_rm(mset, rm_docno); |
| 67 | 67 | } |
| … |
… |
Snipper::set_mset(const MSet & mset, unsigned int rm_docno)
|
| 69 | 69 | string |
| 70 | 70 | Snipper::generate_snippet(const string & text, |
| 71 | 71 | size_t length, |
| 72 | | unsigned int window_size, |
| | 72 | Xapian::termcount window_size, |
| 73 | 73 | double smoothing) |
| 74 | 74 | { |
| 75 | 75 | return internal->generate_snippet(text, length, window_size, smoothing); |
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 {
|
| 120 | 120 | /** Return snippet generated from text using the precalculated relevance model */ |
| 121 | 121 | std::string generate_snippet(const std::string & text, |
| 122 | 122 | size_t length, |
| 123 | | unsigned int window_size, |
| | 123 | Xapian::termcount window_size, |
| 124 | 124 | double smoothing); |
| 125 | 125 | |
| 126 | 126 | /** Calculate relevance model based on a MSet. |
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)
|
| 1145 | 1145 | { |
| 1146 | 1146 | LOGCALL(DB, Xapian::docid, "ChertWritableDatabase::add_document", document); |
| 1147 | 1147 | // 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) |
| 1149 | 1149 | throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents"); |
| 1150 | 1150 | // Use the next unused document ID. |
| 1151 | 1151 | RETURN(add_document_(stats.get_next_docid(), document)); |
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;
|
| 55 | 55 | * correspondingly. |
| 56 | 56 | */ |
| 57 | 57 | #define CHERT_DEFAULT_BLOCK_SIZE 8192 |
| | 58 | #define CHERT_MAX_DOCID 0xffffffff |
| 58 | 59 | |
| 59 | 60 | #endif /* OM_HGUARD_CHERT_TYPES_H */ |
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)
|
| 989 | 989 | { |
| 990 | 990 | LOGCALL(DB, Xapian::docid, "GlassWritableDatabase::add_document", document); |
| 991 | 991 | // 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) |
| 993 | 993 | throw Xapian::DatabaseError("Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents"); |
| 994 | 994 | // Use the next unused document ID. |
| 995 | 995 | RETURN(add_document_(stats.get_next_docid(), document)); |
diff --git a/xapian-core/backends/glass/glass_defs.h b/xapian-core/backends/glass/glass_defs.h
index baab8f4..824a4a9 100644
|
a
|
b
|
|
| 28 | 28 | |
| 29 | 29 | /// Default B-tree block size. |
| 30 | 30 | #define GLASS_DEFAULT_BLOCKSIZE 8192 |
| | 31 | #define GLASS_MAX_DOCID 0xffffffff |
| 31 | 32 | |
| 32 | 33 | namespace Glass { |
| 33 | 34 | enum table_type { |
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)
|
| 145 | 145 | { |
| 146 | 146 | // Check U is an unsigned type. |
| 147 | 147 | 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"); |
| 150 | 150 | |
| 151 | 151 | char tmp[sizeof(U) + 1]; |
| 152 | 152 | char * p = tmp + sizeof(tmp); |
diff --git a/xapian-core/include/xapian/types.h b/xapian-core/include/xapian/types.h
index 130411c..65ce52a 100644
|
a
|
b
|
|
| 27 | 27 | |
| 28 | 28 | #include <xapian/deprecated.h> |
| 29 | 29 | |
| | 30 | #define USE_64BIT_DOCID 1 |
| | 31 | #define USE_64BIT_TERMCOUNT 1 |
| | 32 | |
| 30 | 33 | namespace Xapian { |
| 31 | 34 | |
| 32 | 35 | /** A count of documents. |
| … |
… |
namespace Xapian {
|
| 34 | 37 | * This is used to hold values such as the number of documents in a database |
| 35 | 38 | * and the frequency of a term in the database. |
| 36 | 39 | */ |
| | 40 | #ifdef USE_64BIT_DOCID |
| | 41 | typedef unsigned long long doccount; |
| | 42 | #else |
| 37 | 43 | typedef unsigned doccount; |
| | 44 | #endif |
| 38 | 45 | |
| 39 | 46 | /** A signed difference between two counts of documents. |
| 40 | 47 | * |
| 41 | 48 | * This is used by the Xapian classes which are STL containers of documents |
| 42 | 49 | * for "difference_type". |
| 43 | 50 | */ |
| 44 | | typedef int doccount_diff; /* FIXME: can overflow with more than 2^31 docs. */ |
| | 51 | /* FIXME: can overflow. */ |
| | 52 | #ifdef USE_64BIT_DOCID |
| | 53 | typedef long long doccount_diff; |
| | 54 | #else |
| | 55 | typedef int doccount_diff; |
| | 56 | #endif |
| 45 | 57 | |
| 46 | 58 | /** A unique identifier for a document. |
| 47 | 59 | * |
| 48 | 60 | * Docid 0 is invalid, providing an "out of range" value which can be |
| 49 | 61 | * used to mean "not a valid document". |
| 50 | 62 | */ |
| | 63 | #ifdef USE_64BIT_DOCID |
| | 64 | typedef unsigned long long docid; |
| | 65 | #else |
| 51 | 66 | typedef unsigned docid; |
| | 67 | #endif |
| 52 | 68 | |
| 53 | 69 | /** A normalised document length. |
| 54 | 70 | * |
| … |
… |
XAPIAN_DEPRECATED(typedef int percent);
|
| 68 | 84 | * |
| 69 | 85 | * This is used to hold values such as the Within Document Frequency (wdf). |
| 70 | 86 | */ |
| | 87 | #ifdef USE_64BIT_TERMCOUNT |
| | 88 | typedef unsigned long long termcount; |
| | 89 | #else |
| 71 | 90 | typedef unsigned termcount; |
| | 91 | #endif |
| 72 | 92 | |
| 73 | 93 | /** A signed difference between two counts of terms. |
| 74 | 94 | * |
| 75 | 95 | * This is used by the Xapian classes which are STL containers of terms |
| 76 | 96 | * for "difference_type". |
| 77 | 97 | */ |
| 78 | | typedef int termcount_diff; /* FIXME: can overflow with more than 2^31 terms. */ |
| | 98 | /* FIXME: can overflow. */ |
| | 99 | #ifdef USE_64BIT_DOCID |
| | 100 | typedef long long termcount_diff; |
| | 101 | #else |
| | 102 | typedef int termcount_diff; |
| | 103 | #endif |
| 79 | 104 | |
| 80 | 105 | /** A term position within a document or query. |
| 81 | 106 | */ |
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)
|
| 68 | 68 | unsigned char ch; |
| 69 | 69 | int shift = 0; |
| 70 | 70 | do { |
| 71 | | if (*p == end || shift > 28) |
| | 71 | if (*p == end || shift > 63) |
| 72 | 72 | throw_network_error("Bad encoded length: insufficient data"); |
| 73 | 73 | ch = *(*p)++; |
| 74 | 74 | len |= size_t(ch & 0x7f) << shift; |
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) {
|
| 1615 | 1615 | doc.set_data("prose"); |
| 1616 | 1616 | doc.add_term("word"); |
| 1617 | 1617 | |
| 1618 | | db.replace_document(Xapian::docid(-1), doc); |
| | 1618 | db.replace_document(0xffffffff, doc); |
| 1619 | 1619 | |
| 1620 | 1620 | TEST_EXCEPTION(Xapian::DatabaseError, db.add_document(doc)); |
| 1621 | 1621 | |
diff --git a/xapian-core/tests/harness/testutils.cc b/xapian-core/tests/harness/testutils.cc
index d2bcf21..e56d0d4 100644
|
a
|
b
|
|
| 30 | 30 | |
| 31 | 31 | using namespace std; |
| 32 | 32 | |
| 33 | | ostream & |
| 34 | | operator<<(ostream &os, const vector<unsigned int> &ints) |
| | 33 | template<class T> ostream & |
| | 34 | operator<<(ostream &os, const vector<T> &ints) |
| 35 | 35 | { |
| 36 | 36 | copy(ints.begin(), ints.end(), |
| 37 | | ostream_iterator<unsigned int>(os, ", ")); |
| | 37 | ostream_iterator<T>(os, ", ")); |
| 38 | 38 | return os; |
| 39 | 39 | } |
| 40 | 40 | |
diff --git a/xapian-core/tests/harness/testutils.h b/xapian-core/tests/harness/testutils.h
index 1af4c2e..581c537 100644
|
a
|
b
|
|
| 29 | 29 | // ###################################################################### |
| 30 | 30 | // Useful display operators |
| 31 | 31 | |
| | 32 | template<class T> |
| 32 | 33 | std::ostream &operator<<(std::ostream &os, |
| 33 | | const std::vector<unsigned int> &ints); |
| | 34 | const std::vector<T> &ints); |
| 34 | 35 | |
| 35 | 36 | // ###################################################################### |
| 36 | 37 | // Useful comparison operators |