Repository: lucy Updated Branches: refs/heads/master 42ce69634 -> e914c3cee
Adapt doc ID int types to placate -Wconversion. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f37309a2 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f37309a2 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f37309a2 Branch: refs/heads/master Commit: f37309a2f03194b2a40108f1cdb032168b3bff22 Parents: ac91ea9 Author: Marvin Humphrey <[email protected]> Authored: Wed May 4 19:38:17 2016 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Fri May 6 18:28:20 2016 -0700 ---------------------------------------------------------------------- core/Lucy/Index/DeletionsWriter.c | 4 ++-- core/Lucy/Index/Posting/MatchPosting.c | 4 ++-- core/Lucy/Index/Posting/RawPosting.c | 2 +- core/Lucy/Index/Posting/RichPosting.c | 2 +- core/Lucy/Index/Posting/ScorePosting.c | 2 +- core/Lucy/Index/SegPostingList.c | 14 +++++++------- core/Lucy/Index/SegWriter.c | 2 +- core/Lucy/Index/SortFieldWriter.c | 10 ++++++---- core/Lucy/Search/Searcher.c | 2 +- core/Lucy/Search/SeriesMatcher.c | 4 ++-- 10 files changed, 24 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/DeletionsWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/DeletionsWriter.c b/core/Lucy/Index/DeletionsWriter.c index 3b82f84..fb60be3 100644 --- a/core/Lucy/Index/DeletionsWriter.c +++ b/core/Lucy/Index/DeletionsWriter.c @@ -50,12 +50,12 @@ DelWriter_init(DeletionsWriter *self, Schema *schema, Snapshot *snapshot, I32Array* DelWriter_Generate_Doc_Map_IMP(DeletionsWriter *self, Matcher *deletions, int32_t doc_max, int32_t offset) { - 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); } + int32_t *doc_map = (int32_t*)CALLOCATE((size_t)doc_max + 1, sizeof(int32_t)); + int32_t next_deletion = deletions ? Matcher_Next(deletions) : INT32_MAX; // 0 for a deleted doc, a new number otherwise for (int32_t i = 1, new_doc_id = 1; i <= doc_max; i++) { http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/Posting/MatchPosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/MatchPosting.c b/core/Lucy/Index/Posting/MatchPosting.c index a428fac..7197de9 100644 --- a/core/Lucy/Index/Posting/MatchPosting.c +++ b/core/Lucy/Index/Posting/MatchPosting.c @@ -102,7 +102,7 @@ MatchPost_Read_Raw_IMP(MatchPosting *self, InStream *instream, const size_t text_size = Str_Get_Size(term_text); const uint32_t doc_code = InStream_Read_CU32(instream); const uint32_t delta_doc = doc_code >> 1; - const int32_t doc_id = last_doc_id + delta_doc; + const int32_t doc_id = last_doc_id + (int32_t)delta_doc; const uint32_t freq = (doc_code & 1) ? 1 : InStream_Read_CU32(instream); @@ -207,7 +207,7 @@ MatchPostWriter_Write_Posting_IMP(MatchPostingWriter *self, RawPosting *posting) RawPostingIVARS *const posting_ivars = RawPost_IVARS(posting); OutStream *const outstream = ivars->outstream; const int32_t doc_id = posting_ivars->doc_id; - const uint32_t delta_doc = doc_id - ivars->last_doc_id; + const uint32_t delta_doc = (uint32_t)(doc_id - ivars->last_doc_id); char *const aux_content = posting_ivars->blob + posting_ivars->content_len; if (posting_ivars->freq == 1) { http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/Posting/RawPosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/RawPosting.c b/core/Lucy/Index/Posting/RawPosting.c index 0fc5b2e..db2e5b7 100644 --- a/core/Lucy/Index/Posting/RawPosting.c +++ b/core/Lucy/Index/Posting/RawPosting.c @@ -128,7 +128,7 @@ RawPostWriter_Write_Posting_IMP(RawPostingWriter *self, RawPosting *posting) { RawPostingIVARS *const posting_ivars = RawPost_IVARS(posting); OutStream *const outstream = ivars->outstream; const int32_t doc_id = posting_ivars->doc_id; - const uint32_t delta_doc = doc_id - ivars->last_doc_id; + const uint32_t delta_doc = (uint32_t)(doc_id - ivars->last_doc_id); char *const aux_content = posting_ivars->blob + posting_ivars->content_len; if (posting_ivars->freq == 1) { http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/Posting/RichPosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/RichPosting.c b/core/Lucy/Index/Posting/RichPosting.c index eeb5ca6..693307e 100644 --- a/core/Lucy/Index/Posting/RichPosting.c +++ b/core/Lucy/Index/Posting/RichPosting.c @@ -160,7 +160,7 @@ RichPost_Read_Raw_IMP(RichPosting *self, InStream *instream, const size_t text_size = Str_Get_Size(term_text); const uint32_t doc_code = InStream_Read_CU32(instream); const uint32_t delta_doc = doc_code >> 1; - const int32_t doc_id = last_doc_id + delta_doc; + const int32_t doc_id = last_doc_id + (int32_t)delta_doc; const uint32_t freq = (doc_code & 1) ? 1 : InStream_Read_CU32(instream); http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/Posting/ScorePosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/ScorePosting.c b/core/Lucy/Index/Posting/ScorePosting.c index 8044fa3..34bb5f9 100644 --- a/core/Lucy/Index/Posting/ScorePosting.c +++ b/core/Lucy/Index/Posting/ScorePosting.c @@ -179,7 +179,7 @@ ScorePost_Read_Raw_IMP(ScorePosting *self, InStream *instream, const size_t text_size = Str_Get_Size(term_text); const uint32_t doc_code = InStream_Read_CU32(instream); const uint32_t delta_doc = doc_code >> 1; - const int32_t doc_id = last_doc_id + delta_doc; + const int32_t doc_id = last_doc_id + (int32_t)delta_doc; const uint32_t freq = (doc_code & 1) ? 1 : InStream_Read_CU32(instream); http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/SegPostingList.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SegPostingList.c b/core/Lucy/Index/SegPostingList.c index 78a8d11..39b3aab 100644 --- a/core/Lucy/Index/SegPostingList.c +++ b/core/Lucy/Index/SegPostingList.c @@ -177,15 +177,15 @@ int32_t SegPList_Advance_IMP(SegPostingList *self, int32_t target) { SegPostingListIVARS *const ivars = SegPList_IVARS(self); PostingIVARS *const posting_ivars = Post_IVARS(ivars->posting); - const uint32_t skip_interval = ivars->skip_interval; + const int32_t skip_interval = ivars->skip_interval; - if (ivars->doc_freq >= skip_interval) { + if ((int32_t)ivars->doc_freq >= skip_interval) { InStream *post_stream = ivars->post_stream; InStream *skip_stream = ivars->skip_stream; SkipStepper *const skip_stepper = ivars->skip_stepper; SkipStepperIVARS *const skip_stepper_ivars = SkipStepper_IVARS(skip_stepper); - uint32_t new_doc_id = skip_stepper_ivars->doc_id; + int32_t new_doc_id = skip_stepper_ivars->doc_id; int64_t new_filepos = InStream_Tell(post_stream); /* Assuming the default skip_interval of 16... @@ -195,7 +195,7 @@ SegPList_Advance_IMP(SegPostingList *self, int32_t target) { * yet, but we'll have already gone past 5 of the 16 skip docs -- * ergo, the modulus in the following formula. */ - int32_t num_skipped = 0 - (ivars->count % skip_interval); + int32_t num_skipped = 0 - ((int32_t)ivars->count % skip_interval); if (num_skipped == 0 && ivars->count != 0) { num_skipped = 0 - skip_interval; } @@ -229,7 +229,7 @@ SegPList_Advance_IMP(SegPostingList *self, int32_t target) { posting_ivars->doc_id = new_doc_id; // Increase count by the number of docs we skipped over. - ivars->count += num_skipped; + ivars->count += (uint32_t)num_skipped; } } @@ -286,7 +286,7 @@ S_seek_tinfo(SegPostingList *self, TermInfo *tinfo) { else { // Transfer doc_freq, seek main stream. int64_t post_filepos = TInfo_Get_Post_FilePos(tinfo); - ivars->doc_freq = TInfo_Get_Doc_Freq(tinfo); + ivars->doc_freq = (uint32_t)TInfo_Get_Doc_Freq(tinfo); InStream_Seek(ivars->post_stream, post_filepos); // Prepare posting. @@ -294,7 +294,7 @@ S_seek_tinfo(SegPostingList *self, TermInfo *tinfo) { // Prepare to skip. ivars->skip_count = 0; - ivars->num_skips = ivars->doc_freq / ivars->skip_interval; + ivars->num_skips = ivars->doc_freq / (uint32_t)ivars->skip_interval; SkipStepper_Set_ID_And_Filepos(ivars->skip_stepper, 0, post_filepos); InStream_Seek(ivars->skip_stream, TInfo_Get_Skip_FilePos(tinfo)); } http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/SegWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SegWriter.c b/core/Lucy/Index/SegWriter.c index 1026b94..1e2ec28 100644 --- a/core/Lucy/Index/SegWriter.c +++ b/core/Lucy/Index/SegWriter.c @@ -127,7 +127,7 @@ 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); - size_t doc_count = SegReader_Doc_Max(reader); + int32_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--; } } http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Index/SortFieldWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c index 88c9742..a300f1d 100644 --- a/core/Lucy/Index/SortFieldWriter.c +++ b/core/Lucy/Index/SortFieldWriter.c @@ -349,7 +349,8 @@ S_lazy_init_sorted_ids(SortFieldWriter *self) { int32_t run_max = ivars->run_max; // Count. - int32_t *counts = (int32_t*)CALLOCATE(run_cardinality, sizeof(int32_t)); + int32_t *counts + = (int32_t*)CALLOCATE((size_t)run_cardinality, sizeof(int32_t)); for (int32_t doc_id = 0; doc_id <= run_max; ++doc_id) { int32_t ord = SortCache_Ordinal(sort_cache, doc_id); ++counts[ord]; @@ -364,7 +365,8 @@ S_lazy_init_sorted_ids(SortFieldWriter *self) { } // Distribute. - int32_t *sorted_ids = (int32_t*)MALLOCATE((run_max + 1) * sizeof(int32_t)); + int32_t *sorted_ids + = (int32_t*)MALLOCATE(((size_t)run_max + 1) * sizeof(int32_t)); for (int32_t doc_id = 0; doc_id <= run_max; ++doc_id) { int32_t ord = SortCache_Ordinal(sort_cache, doc_id); int32_t pos = counts[ord]++; @@ -535,7 +537,7 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out, int8_t prim_id = ivars->prim_id; int32_t doc_max = (int32_t)Seg_Get_Count(ivars->segment); bool has_nulls = ivars->count == doc_max ? false : true; - size_t size = (doc_max + 1) * sizeof(int32_t); + size_t size = ((size_t)doc_max + 1) * sizeof(int32_t); int32_t *ords = (int32_t*)MALLOCATE(size); int32_t ord = 0; int64_t dat_start = OutStream_Tell(dat_out); @@ -602,7 +604,7 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out, int32_t ord_width = ivars->ord_width; // Write ords. - size_t byte_count; + size_t byte_count = SIZE_MAX; switch (ord_width) { case 1: byte_count = (((size_t)doc_max + 1) + 7) / 8; http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Search/Searcher.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Search/Searcher.c b/core/Lucy/Search/Searcher.c index 5d65a7d..e2d7a21 100644 --- a/core/Lucy/Search/Searcher.c +++ b/core/Lucy/Search/Searcher.c @@ -51,7 +51,7 @@ Hits* Searcher_Hits_IMP(Searcher *self, Obj *query, uint32_t offset, uint32_t num_wanted, SortSpec *sort_spec) { Query *real_query = Searcher_Glean_Query(self, query); - uint32_t doc_max = Searcher_Doc_Max(self); + uint32_t doc_max = (uint32_t)Searcher_Doc_Max(self); uint32_t wanted = offset + num_wanted > doc_max ? doc_max : offset + num_wanted; http://git-wip-us.apache.org/repos/asf/lucy/blob/f37309a2/core/Lucy/Search/SeriesMatcher.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Search/SeriesMatcher.c b/core/Lucy/Search/SeriesMatcher.c index 4d7231b..3774468 100644 --- a/core/Lucy/Search/SeriesMatcher.c +++ b/core/Lucy/Search/SeriesMatcher.c @@ -68,10 +68,10 @@ SeriesMatcher_Advance_IMP(SeriesMatcher *self, int32_t target) { // Proceed to next matcher or bail. if (ivars->tick < ivars->num_matchers) { while (1) { - uint32_t next_offset + int32_t next_offset = ivars->tick + 1 == ivars->num_matchers ? INT32_MAX - : (uint32_t)I32Arr_Get(ivars->offsets, (size_t)(ivars->tick + 1)); + : (int32_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;
