Repository: lucy
Updated Branches:
  refs/heads/master abee805b1 -> 67c6fec0b


Various adaptations to I32Array size change.

These changes are a grab bag, some of which are easy to review and some
of which are more subtle.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e7b501ca
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e7b501ca
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e7b501ca

Branch: refs/heads/master
Commit: e7b501caf3e6b6672f7c888e3fadecb30d07b360
Parents: 3f0e59b
Author: Marvin Humphrey <mar...@rectangular.com>
Authored: Tue Apr 5 19:14:53 2016 -0700
Committer: Marvin Humphrey <mar...@rectangular.com>
Committed: Wed Apr 6 13:03:09 2016 -0700

----------------------------------------------------------------------
 core/Lucy/Index/DeletionsWriter.c         |  5 ++++-
 core/Lucy/Index/IndexManager.c            |  6 +++---
 core/Lucy/Index/SegWriter.c               |  4 ++--
 core/Lucy/Index/TermVector.c              | 16 +++++++++-------
 core/Lucy/Index/TermVector.cfh            |  2 +-
 core/Lucy/Search/SeriesMatcher.c          |  2 +-
 core/Lucy/Search/TermQuery.c              |  2 +-
 core/Lucy/Test/Object/TestI32Array.c      |  8 ++++----
 core/Lucy/Test/Search/TestSeriesMatcher.c | 17 ++++++++---------
 9 files changed, 33 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Index/DeletionsWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsWriter.c 
b/core/Lucy/Index/DeletionsWriter.c
index e2b9b09..c646658 100644
--- a/core/Lucy/Index/DeletionsWriter.c
+++ b/core/Lucy/Index/DeletionsWriter.c
@@ -53,6 +53,9 @@ DelWriter_Generate_Doc_Map_IMP(DeletionsWriter *self, Matcher 
*deletions,
     int32_t *doc_map = (int32_t*)CALLOCATE(doc_max + 1, sizeof(int32_t));
     int32_t  next_deletion = deletions ? Matcher_Next(deletions) : INT32_MAX;
     UNUSED_VAR(self);
+    if (doc_max < 0) {
+        THROW(ERR, "Negative doc_max is invalid: %i32", doc_max);
+    }
 
     // 0 for a deleted doc, a new number otherwise
     for (int32_t i = 1, new_doc_id = 1; i <= doc_max; i++) {
@@ -308,7 +311,7 @@ DefDelWriter_Delete_By_Doc_ID_IMP(DefaultDeletionsWriter 
*self, int32_t doc_id)
     DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     uint32_t   sub_tick   = PolyReader_sub_tick(ivars->seg_starts, doc_id);
     BitVector *bit_vec    = (BitVector*)Vec_Fetch(ivars->bit_vecs, sub_tick);
-    uint32_t   offset     = I32Arr_Get(ivars->seg_starts, sub_tick);
+    int32_t    offset     = I32Arr_Get(ivars->seg_starts, sub_tick);
     int32_t    seg_doc_id = doc_id - offset;
 
     if (!BitVec_Get(bit_vec, seg_doc_id)) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Index/IndexManager.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index af6205f..15425e9 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -192,14 +192,14 @@ uint32_t
 IxManager_Choose_Sparse_IMP(IndexManager *self, I32Array *doc_counts) {
     UNUSED_VAR(self);
     uint32_t threshold  = 0;
-    uint32_t total_docs = 0;
-    const uint32_t num_candidates = I32Arr_Get_Size(doc_counts);
+    int32_t total_docs = 0;
+    const uint32_t num_candidates = (uint32_t)I32Arr_Get_Size(doc_counts);
 
     // Find sparsely populated segments.
     for (uint32_t i = 0; i < num_candidates; i++) {
         uint32_t num_segs_when_done = num_candidates - threshold + 1;
         total_docs += I32Arr_Get(doc_counts, i);
-        if (total_docs < S_fibonacci(num_segs_when_done + 5)) {
+        if (total_docs < (int32_t)S_fibonacci(num_segs_when_done + 5)) {
             threshold = i + 1;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Index/SegWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegWriter.c b/core/Lucy/Index/SegWriter.c
index e67df82..1026b94 100644
--- a/core/Lucy/Index/SegWriter.c
+++ b/core/Lucy/Index/SegWriter.c
@@ -127,8 +127,8 @@ SegWriter_Add_Inverted_Doc_IMP(SegWriter *self, Inverter 
*inverter,
 static void
 S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map) {
     SegWriterIVARS *const ivars = SegWriter_IVARS(self);
-    uint32_t doc_count = SegReader_Doc_Max(reader);
-    for (uint32_t i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
+    size_t doc_count = SegReader_Doc_Max(reader);
+    for (size_t i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
         if (I32Arr_Get(doc_map, i) == 0) { doc_count--; }
     }
     Seg_Increment_Count(ivars->segment, doc_count);

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Index/TermVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/TermVector.c b/core/Lucy/Index/TermVector.c
index e8d5aab..b1a3391 100644
--- a/core/Lucy/Index/TermVector.c
+++ b/core/Lucy/Index/TermVector.c
@@ -46,8 +46,10 @@ TV_init(TermVector *self, String *field, String *text,
     if (I32Arr_Get_Size(start_offsets) != ivars->num_pos
         || I32Arr_Get_Size(end_offsets) != ivars->num_pos
        ) {
-        THROW(ERR, "Unbalanced arrays: %u32 %u32 %u32", ivars->num_pos,
-              I32Arr_Get_Size(start_offsets), I32Arr_Get_Size(end_offsets));
+        THROW(ERR, "Unbalanced arrays: %u64 %u64 %u64",
+              (uint64_t)ivars->num_pos,
+              (uint64_t)I32Arr_Get_Size(start_offsets),
+              (uint64_t)I32Arr_Get_Size(end_offsets));
     }
 
     return self;
@@ -88,9 +90,9 @@ TV_Serialize_IMP(TermVector *self, OutStream *target) {
 
     Freezer_serialize_string(ivars->field, target);
     Freezer_serialize_string(ivars->text, target);
-    OutStream_Write_C32(target, ivars->num_pos);
+    OutStream_Write_C64(target, ivars->num_pos);
 
-    for (uint32_t i = 0; i < ivars->num_pos; i++) {
+    for (size_t i = 0; i < ivars->num_pos; i++) {
         OutStream_Write_C32(target, posits[i]);
         OutStream_Write_C32(target, starts[i]);
         OutStream_Write_C32(target, ends[i]);
@@ -101,13 +103,13 @@ TermVector*
 TV_Deserialize_IMP(TermVector *self, InStream *instream) {
     String *field = Freezer_read_string(instream);
     String *text  = Freezer_read_string(instream);
-    uint32_t num_pos = InStream_Read_C32(instream);
+    size_t  num_pos = InStream_Read_C64(instream);
 
     // Read positional data.
     int32_t *posits = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t));
     int32_t *starts = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t));
     int32_t *ends   = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t));
-    for (uint32_t i = 0; i < num_pos; i++) {
+    for (size_t i = 0; i < num_pos; i++) {
         posits[i] = InStream_Read_C32(instream);
         starts[i] = InStream_Read_C32(instream);
         ends[i]   = InStream_Read_C32(instream);
@@ -142,7 +144,7 @@ TV_Equals_IMP(TermVector *self, Obj *other) {
     int32_t *const other_posits = I32Arr_IVARS(ovars->positions)->ints;
     int32_t *const other_starts = I32Arr_IVARS(ovars->start_offsets)->ints;
     int32_t *const other_ends   = I32Arr_IVARS(ovars->start_offsets)->ints;
-    for (uint32_t i = 0; i < ivars->num_pos; i++) {
+    for (size_t i = 0; i < ivars->num_pos; i++) {
         if (posits[i] != other_posits[i]) { return false; }
         if (starts[i] != other_starts[i]) { return false; }
         if (ends[i]   != other_ends[i])   { return false; }

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Index/TermVector.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/TermVector.cfh b/core/Lucy/Index/TermVector.cfh
index 4242008..5e6eb7d 100644
--- a/core/Lucy/Index/TermVector.cfh
+++ b/core/Lucy/Index/TermVector.cfh
@@ -24,7 +24,7 @@ class Lucy::Index::TermVector nickname TV
 
     String *field;
     String *text;
-    uint32_t num_pos;
+    size_t num_pos;
     I32Array  *positions;
     I32Array  *start_offsets;
     I32Array  *end_offsets;

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Search/SeriesMatcher.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/SeriesMatcher.c b/core/Lucy/Search/SeriesMatcher.c
index a36d820..4d7231b 100644
--- a/core/Lucy/Search/SeriesMatcher.c
+++ b/core/Lucy/Search/SeriesMatcher.c
@@ -71,7 +71,7 @@ SeriesMatcher_Advance_IMP(SeriesMatcher *self, int32_t 
target) {
                 uint32_t next_offset
                     = ivars->tick + 1 == ivars->num_matchers
                       ? INT32_MAX
-                      : I32Arr_Get(ivars->offsets, ivars->tick + 1);
+                      : (uint32_t)I32Arr_Get(ivars->offsets, 
(size_t)(ivars->tick + 1));
                 ivars->current_matcher = (Matcher*)Vec_Fetch(ivars->matchers,
                                                            ivars->tick);
                 ivars->current_offset = ivars->next_offset;

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Search/TermQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/TermQuery.c b/core/Lucy/Search/TermQuery.c
index 9003036..397f865 100644
--- a/core/Lucy/Search/TermQuery.c
+++ b/core/Lucy/Search/TermQuery.c
@@ -303,7 +303,7 @@ TermCompiler_Highlight_Spans_IMP(TermCompiler *self, 
Searcher *searcher,
 
     starts = TV_Get_Start_Offsets(term_vector);
     ends   = TV_Get_End_Offsets(term_vector);
-    for (uint32_t i = 0, max = I32Arr_Get_Size(starts); i < max; i++) {
+    for (size_t i = 0, max = I32Arr_Get_Size(starts); i < max; i++) {
         int32_t start  = I32Arr_Get(starts, i);
         int32_t length = I32Arr_Get(ends, i) - start;
         Vec_Push(spans,

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Test/Object/TestI32Array.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Object/TestI32Array.c 
b/core/Lucy/Test/Object/TestI32Array.c
index 7661d7c..7236d7b 100644
--- a/core/Lucy/Test/Object/TestI32Array.c
+++ b/core/Lucy/Test/Object/TestI32Array.c
@@ -49,16 +49,16 @@ test_all(TestBatchRunner *runner) {
             break;
         }
     }
-    TEST_INT_EQ(runner, num_matched, num_ints,
-                "Matched all source ints with Get()");
+    TEST_UINT_EQ(runner, num_matched, num_ints,
+                 "Matched all source ints with Get()");
 
     for (num_matched = 0; num_matched < num_ints; num_matched++) {
         if (source_ints[num_matched] != I32Arr_Get(stolen, num_matched)) {
             break;
         }
     }
-    TEST_INT_EQ(runner, num_matched, num_ints,
-                "Matched all source ints in stolen I32Array with Get()");
+    TEST_UINT_EQ(runner, num_matched, num_ints,
+                 "Matched all source ints in stolen I32Array with Get()");
 
     DECREF(i32_array);
     DECREF(stolen);

http://git-wip-us.apache.org/repos/asf/lucy/blob/e7b501ca/core/Lucy/Test/Search/TestSeriesMatcher.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSeriesMatcher.c 
b/core/Lucy/Test/Search/TestSeriesMatcher.c
index 7becce4..d0ec08e 100644
--- a/core/Lucy/Test/Search/TestSeriesMatcher.c
+++ b/core/Lucy/Test/Search/TestSeriesMatcher.c
@@ -31,14 +31,13 @@ TestSeriesMatcher_new() {
 
 static SeriesMatcher*
 S_make_series_matcher(I32Array *doc_ids, I32Array *offsets, int32_t doc_max) {
-    int32_t  num_doc_ids  = I32Arr_Get_Size(doc_ids);
-    int32_t  num_matchers = I32Arr_Get_Size(offsets);
+    size_t   num_doc_ids  = I32Arr_Get_Size(doc_ids);
+    size_t   num_matchers = I32Arr_Get_Size(offsets);
     Vector  *matchers     = Vec_new(num_matchers);
-    int32_t  tick         = 0;
-    int32_t  i;
+    size_t   tick         = 0;
 
     // Divvy up doc_ids by segment into BitVectors.
-    for (i = 0; i < num_matchers; i++) {
+    for (size_t i = 0; i < num_matchers; i++) {
         int32_t offset = I32Arr_Get(offsets, i);
         int32_t max    = i == num_matchers - 1
                          ? doc_max + 1
@@ -83,16 +82,16 @@ S_do_test_matrix(TestBatchRunner *runner, int32_t doc_max, 
int32_t first_doc_id,
         = S_generate_match_list(0, doc_max, offset_inc);
     SeriesMatcher *series_matcher
         = S_make_series_matcher(doc_ids, offsets, doc_max);
-    uint32_t num_in_agreement = 0;
+    size_t num_in_agreement = 0;
     int32_t got;
 
     while (0 != (got = SeriesMatcher_Next(series_matcher))) {
         if (got != I32Arr_Get(doc_ids, num_in_agreement)) { break; }
         num_in_agreement++;
     }
-    TEST_INT_EQ(runner, num_in_agreement, I32Arr_Get_Size(doc_ids),
-                "doc_max=%d first_doc_id=%d doc_inc=%d offset_inc=%d",
-                doc_max, first_doc_id, doc_inc, offset_inc);
+    TEST_UINT_EQ(runner, num_in_agreement, I32Arr_Get_Size(doc_ids),
+                 "doc_max=%d first_doc_id=%d doc_inc=%d offset_inc=%d",
+                 doc_max, first_doc_id, doc_inc, offset_inc);
 
     DECREF(doc_ids);
     DECREF(offsets);

Reply via email to