Switch NumUtils client code to cu32/ci32. Change all invocations from NumUtil_xxxx_c32 to use the NumUtil_xxxx_cu32 and NumUtil_xxx_ci32 variants which are explicitly signed or unsigned.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/67656d94 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/67656d94 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/67656d94 Branch: refs/heads/master Commit: 67656d94224b9350deb224699eda5956a0b8a989 Parents: cef8cbc Author: Marvin Humphrey <mar...@rectangular.com> Authored: Mon Apr 18 17:52:42 2016 -0700 Committer: Marvin Humphrey <mar...@rectangular.com> Committed: Mon Apr 18 18:43:05 2016 -0700 ---------------------------------------------------------------------- core/Lucy/Index/DocVector.c | 18 +++++++++--------- core/Lucy/Index/HighlightWriter.c | 26 +++++++++++++------------- core/Lucy/Index/Posting/RichPosting.c | 8 ++++---- core/Lucy/Index/Posting/ScorePosting.c | 18 +++++++++--------- core/Lucy/Store/OutStream.c | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/67656d94/core/Lucy/Index/DocVector.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c index 54dfedd..2bc8192 100644 --- a/core/Lucy/Index/DocVector.c +++ b/core/Lucy/Index/DocVector.c @@ -122,13 +122,13 @@ static Hash* S_extract_tv_cache(Blob *field_buf) { Hash *tv_cache = Hash_new(0); const char *tv_string = Blob_Get_Buf(field_buf); - int32_t num_terms = NumUtil_decode_c32(&tv_string); + int32_t num_terms = NumUtil_decode_ci32(&tv_string); ByteBuf *text_buf = BB_new(0); // Read the number of highlightable terms in the field. for (int32_t i = 0; i < num_terms; i++) { - size_t overlap = NumUtil_decode_c32(&tv_string); - size_t len = NumUtil_decode_c32(&tv_string); + size_t overlap = NumUtil_decode_cu32(&tv_string); + size_t len = NumUtil_decode_cu32(&tv_string); // Decompress the term text. BB_Set_Size(text_buf, overlap); @@ -137,7 +137,7 @@ S_extract_tv_cache(Blob *field_buf) { // Get positions & offsets string. const char *bookmark_ptr = tv_string; - int32_t num_positions = NumUtil_decode_c32(&tv_string); + int32_t num_positions = NumUtil_decode_ci32(&tv_string); while (num_positions--) { // Leave nums compressed to save a little mem. NumUtil_skip_cint(&tv_string); @@ -167,17 +167,17 @@ S_extract_tv_from_tv_buf(String *field, String *term_text, Blob *tv_buf) { uint32_t num_pos = 0; if (posdata != posdata_end) { - num_pos = NumUtil_decode_c32(&posdata); + num_pos = NumUtil_decode_cu32(&posdata); positions = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t)); starts = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t)); ends = (int32_t*)MALLOCATE(num_pos * sizeof(int32_t)); } - // Expand C32s. + // Expand CI32s. for (uint32_t i = 0; i < num_pos; i++) { - positions[i] = NumUtil_decode_c32(&posdata); - starts[i] = NumUtil_decode_c32(&posdata); - ends[i] = NumUtil_decode_c32(&posdata); + positions[i] = NumUtil_decode_ci32(&posdata); + starts[i] = NumUtil_decode_ci32(&posdata); + ends[i] = NumUtil_decode_ci32(&posdata); } if (posdata != posdata_end) { http://git-wip-us.apache.org/repos/asf/lucy/blob/67656d94/core/Lucy/Index/HighlightWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c index 08ad85a..d81b623 100644 --- a/core/Lucy/Index/HighlightWriter.c +++ b/core/Lucy/Index/HighlightWriter.c @@ -149,8 +149,8 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) { uint32_t freq; UNUSED_VAR(self); - // Leave space for a c32 indicating the number of postings. - BB_Set_Size(tv_buf, C32_MAX_BYTES); + // Leave space for a cu32 indicating the number of postings. + BB_Set_Size(tv_buf, CU32_MAX_BYTES); Inversion_Reset(inversion); while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) { @@ -164,11 +164,11 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) { char *orig; size_t old_size = BB_Get_Size(tv_buf); size_t new_size = old_size - + C32_MAX_BYTES // overlap - + C32_MAX_BYTES // length of string diff + + CI32_MAX_BYTES // overlap + + CI32_MAX_BYTES // length of string diff + (token_len - overlap) // diff char data - + C32_MAX_BYTES // num prox - + (C32_MAX_BYTES * freq * 3); // pos data + + CU32_MAX_BYTES // num prox + + (CU32_MAX_BYTES * freq * 3); // pos data // Allocate for worst-case scenario. ptr = BB_Grow(tv_buf, new_size); @@ -179,8 +179,8 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) { num_postings += 1; // Append the string diff to the tv_buf. - NumUtil_encode_c32(overlap, &ptr); - NumUtil_encode_c32((token_len - overlap), &ptr); + NumUtil_encode_ci32(overlap, &ptr); + NumUtil_encode_ci32((token_len - overlap), &ptr); memcpy(ptr, (token_text + overlap), (token_len - overlap)); ptr += token_len - overlap; @@ -189,13 +189,13 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) { last_len = token_len; // Append the number of positions for this term. - NumUtil_encode_c32(freq, &ptr); + NumUtil_encode_cu32(freq, &ptr); do { // Add position, start_offset, and end_offset to tv_buf. - NumUtil_encode_c32(Token_Get_Pos(token), &ptr); - NumUtil_encode_c32(Token_Get_Start_Offset(token), &ptr); - NumUtil_encode_c32(Token_Get_End_Offset(token), &ptr); + NumUtil_encode_ci32(Token_Get_Pos(token), &ptr); + NumUtil_encode_cu32(Token_Get_Start_Offset(token), &ptr); + NumUtil_encode_cu32(Token_Get_End_Offset(token), &ptr); } while (--freq && (token = *++tokens)); // Set new byte length. @@ -204,7 +204,7 @@ HLWriter_TV_Buf_IMP(HighlightWriter *self, Inversion *inversion) { // Go back and start the term vector string with the posting count. char *dest = BB_Get_Buf(tv_buf); - NumUtil_encode_padded_c32(num_postings, &dest); + NumUtil_encode_padded_cu32(num_postings, &dest); Blob *blob = BB_Yield_Blob(tv_buf); DECREF(tv_buf); http://git-wip-us.apache.org/repos/asf/lucy/blob/67656d94/core/Lucy/Index/Posting/RichPosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/RichPosting.c b/core/Lucy/Index/Posting/RichPosting.c index 17e3e95..b3ff7e4 100644 --- a/core/Lucy/Index/Posting/RichPosting.c +++ b/core/Lucy/Index/Posting/RichPosting.c @@ -33,12 +33,12 @@ #include "Lucy/Util/MemoryPool.h" #include "Lucy/Util/NumberUtils.h" -#define FREQ_MAX_LEN C32_MAX_BYTES +#define FREQ_MAX_LEN CU32_MAX_BYTES #define MAX_RAW_POSTING_LEN(_raw_posting_size, _text_len, _freq) \ ( _raw_posting_size \ + _text_len /* term text content */ \ - + FREQ_MAX_LEN /* freq c32 */ \ - + (C32_MAX_BYTES * _freq) /* positions deltas */ \ + + FREQ_MAX_LEN /* freq cu32 */ \ + + (CU32_MAX_BYTES * _freq) /* positions deltas */ \ + _freq /* per-pos boost byte */ \ ) @@ -137,7 +137,7 @@ RichPost_Add_Inversion_To_Pool_IMP(RichPosting *self, PostingPool *post_pool, const uint32_t prox_delta = t_ivars->pos - last_prox; const float boost = field_boost * t_ivars->boost; - NumUtil_encode_c32(prox_delta, &dest); + NumUtil_encode_cu32(prox_delta, &dest); last_prox = t_ivars->pos; *((uint8_t*)dest) = Sim_Encode_Norm(sim, boost); http://git-wip-us.apache.org/repos/asf/lucy/blob/67656d94/core/Lucy/Index/Posting/ScorePosting.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Posting/ScorePosting.c b/core/Lucy/Index/Posting/ScorePosting.c index 3e995a8..bc84bf8 100644 --- a/core/Lucy/Index/Posting/ScorePosting.c +++ b/core/Lucy/Index/Posting/ScorePosting.c @@ -35,13 +35,13 @@ #include "Lucy/Util/NumberUtils.h" #define FIELD_BOOST_LEN 1 -#define FREQ_MAX_LEN C32_MAX_BYTES +#define FREQ_MAX_LEN CU32_MAX_BYTES #define MAX_RAW_POSTING_LEN(_raw_post_size, _text_len, _freq) \ ( _raw_post_size \ + _text_len /* term text content */ \ + FIELD_BOOST_LEN /* field boost byte */ \ - + FREQ_MAX_LEN /* freq c32 */ \ - + (C32_MAX_BYTES * _freq) /* positions deltas */ \ + + FREQ_MAX_LEN /* freq cu32 */ \ + + (CU32_MAX_BYTES * _freq) /* positions deltas */ \ ) ScorePosting* @@ -110,7 +110,7 @@ ScorePost_Add_Inversion_To_Pool_IMP(ScorePosting *self, for (uint32_t i = 0; i < freq; i++) { TokenIVARS *const t_ivars = Token_IVARS(tokens[i]); const uint32_t prox_delta = t_ivars->pos - last_prox; - NumUtil_encode_c32(prox_delta, &dest); + NumUtil_encode_cu32(prox_delta, &dest); last_prox = t_ivars->pos; } @@ -134,9 +134,9 @@ void ScorePost_Read_Record_IMP(ScorePosting *self, InStream *instream) { ScorePostingIVARS *const ivars = ScorePost_IVARS(self); uint32_t position = 0; - const size_t max_start_bytes = (C32_MAX_BYTES * 2) + 1; + const size_t max_start_bytes = (CU32_MAX_BYTES * 2) + 1; const char *buf = InStream_Buf(instream, max_start_bytes); - const uint32_t doc_code = NumUtil_decode_c32(&buf); + const uint32_t doc_code = NumUtil_decode_cu32(&buf); const uint32_t doc_delta = doc_code >> 1; // Apply delta doc and retrieve freq. @@ -145,7 +145,7 @@ ScorePost_Read_Record_IMP(ScorePosting *self, InStream *instream) { ivars->freq = 1; } else { - ivars->freq = NumUtil_decode_c32(&buf); + ivars->freq = NumUtil_decode_cu32(&buf); } // Decode boost/norm byte. @@ -162,9 +162,9 @@ ScorePost_Read_Record_IMP(ScorePosting *self, InStream *instream) { uint32_t *positions = ivars->prox; InStream_Advance_Buf(instream, buf); - buf = InStream_Buf(instream, num_prox * C32_MAX_BYTES); + buf = InStream_Buf(instream, num_prox * CU32_MAX_BYTES); while (num_prox--) { - position += NumUtil_decode_c32(&buf); + position += NumUtil_decode_cu32(&buf); *positions++ = position; } http://git-wip-us.apache.org/repos/asf/lucy/blob/67656d94/core/Lucy/Store/OutStream.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Store/OutStream.c b/core/Lucy/Store/OutStream.c index 3f1d941..8ae07d4 100644 --- a/core/Lucy/Store/OutStream.c +++ b/core/Lucy/Store/OutStream.c @@ -306,7 +306,7 @@ OutStream_Write_CU32_IMP(OutStream *self, uint32_t value) { static CFISH_INLINE void SI_write_cu32(OutStream *self, OutStreamIVARS *ivars, uint32_t value) { - uint8_t buf[C32_MAX_BYTES]; + uint8_t buf[CU32_MAX_BYTES]; uint8_t *ptr = buf + sizeof(buf) - 1; // Write last byte first, which has no continue bit. @@ -339,7 +339,7 @@ OutStream_Write_CU64_IMP(OutStream *self, uint64_t value) { static CFISH_INLINE void SI_write_cu64(OutStream *self, OutStreamIVARS *ivars, uint64_t value) { - uint8_t buf[C64_MAX_BYTES]; + uint8_t buf[CU64_MAX_BYTES]; uint8_t *ptr = buf + sizeof(buf) - 1; // Write last byte first, which has no continue bit.