Adjust for Float32/Int32 removal
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/8144f5c7 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8144f5c7 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8144f5c7 Branch: refs/heads/master Commit: 8144f5c7f3806873b58a9f1e751243f2c294eb13 Parents: 957ae1e Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Thu Jul 9 14:46:15 2015 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Thu Jul 9 16:38:43 2015 +0200 ---------------------------------------------------------------------- c/src/Lucy/Index/DocReader.c | 8 +++----- c/src/Lucy/Index/Inverter.c | 12 ++---------- core/Lucy/Index/DeletionsWriter.c | 12 ++++++------ core/Lucy/Index/DocWriter.c | 4 ++-- core/Lucy/Index/Inverter.c | 4 ---- core/Lucy/Index/Segment.c | 10 +++++----- core/Lucy/Index/SortCache/NumericSortCache.c | 4 ++-- core/Lucy/Index/SortFieldWriter.c | 20 +++++++++---------- core/Lucy/Test/Search/TestSortSpec.c | 10 +++++----- core/Lucy/Test/Util/TestFreezer.c | 16 ++------------- core/Lucy/Util/Freezer.c | 24 ++++------------------- perl/xs/Lucy/Index/Inverter.c | 12 +++++------- 12 files changed, 46 insertions(+), 90 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/c/src/Lucy/Index/DocReader.c ---------------------------------------------------------------------- diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c index 59a5a10..b775613 100644 --- a/c/src/Lucy/Index/DocReader.c +++ b/c/src/Lucy/Index/DocReader.c @@ -86,15 +86,13 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) { break; } case FType_FLOAT32: - value = (Obj*)Float32_new( - InStream_Read_F32(dat_in)); + value = (Obj*)Float64_new(InStream_Read_F32(dat_in)); break; case FType_FLOAT64: - value = (Obj*)Float64_new( - InStream_Read_F64(dat_in)); + value = (Obj*)Float64_new(InStream_Read_F64(dat_in)); break; case FType_INT32: - value = (Obj*)Int32_new( + value = (Obj*)Int64_new( (int32_t)InStream_Read_C32(dat_in)); break; case FType_INT64: http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/c/src/Lucy/Index/Inverter.c ---------------------------------------------------------------------- diff --git a/c/src/Lucy/Index/Inverter.c b/c/src/Lucy/Index/Inverter.c index efcaa58..15761f0 100644 --- a/c/src/Lucy/Index/Inverter.c +++ b/c/src/Lucy/Index/Inverter.c @@ -91,21 +91,13 @@ Inverter_Invert_Doc_IMP(Inverter *self, Doc *doc) { inventry_ivars->value = INCREF(blob); break; } - case FType_INT32: { - Integer32* value = (Integer32*)inventry_ivars->value; - Int32_Mimic(value, obj); - break; - } + case FType_INT32: case FType_INT64: { Integer64* value = (Integer64*)inventry_ivars->value; Int64_Mimic(value, obj); break; } - case FType_FLOAT32: { - Float32* value = (Float32*)inventry_ivars->value; - Float32_Mimic(value, obj); - break; - } + case FType_FLOAT32: case FType_FLOAT64: { Float64* value = (Float64*)inventry_ivars->value; Float64_Mimic(value, obj); http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/DeletionsWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/DeletionsWriter.c b/core/Lucy/Index/DeletionsWriter.c index b626188..c7c75ee 100644 --- a/core/Lucy/Index/DeletionsWriter.c +++ b/core/Lucy/Index/DeletionsWriter.c @@ -114,7 +114,7 @@ DefDelWriter_init(DefaultDeletionsWriter *self, Schema *schema, Vec_Store(ivars->bit_vecs, i, (Obj*)bit_vec); Hash_Store(ivars->name_to_tick, SegReader_Get_Seg_Name(seg_reader), - (Obj*)Int32_new(i)); + (Obj*)Int64_new(i)); } return self; @@ -214,9 +214,9 @@ DefDelWriter_Seg_Deletions_IMP(DefaultDeletionsWriter *self, Matcher *deletions = NULL; Segment *segment = SegReader_Get_Segment(seg_reader); String *seg_name = Seg_Get_Name(segment); - Integer32 *tick_obj = (Integer32*)Hash_Fetch(ivars->name_to_tick, + Integer64 *tick_obj = (Integer64*)Hash_Fetch(ivars->name_to_tick, seg_name); - int32_t tick = tick_obj ? Int32_Get_Value(tick_obj) : 0; + int32_t tick = tick_obj ? (int32_t)Int64_Get_Value(tick_obj) : 0; SegReader *candidate = tick_obj ? (SegReader*)Vec_Fetch(ivars->seg_readers, tick) : NULL; @@ -241,10 +241,10 @@ int32_t DefDelWriter_Seg_Del_Count_IMP(DefaultDeletionsWriter *self, String *seg_name) { DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self); - Integer32 *tick - = (Integer32*)Hash_Fetch(ivars->name_to_tick, seg_name); + Integer64 *tick + = (Integer64*)Hash_Fetch(ivars->name_to_tick, seg_name); BitVector *deldocs = tick - ? (BitVector*)Vec_Fetch(ivars->bit_vecs, Int32_Get_Value(tick)) + ? (BitVector*)Vec_Fetch(ivars->bit_vecs, Int64_Get_Value(tick)) : NULL; return deldocs ? BitVec_Count(deldocs) : 0; } http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/DocWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c index 07129a7..f9272a7 100644 --- a/core/Lucy/Index/DocWriter.c +++ b/core/Lucy/Index/DocWriter.c @@ -130,7 +130,7 @@ DocWriter_Add_Inverted_Doc_IMP(DocWriter *self, Inverter *inverter, break; } case FType_INT32: { - int32_t val = Int32_Get_Value((Integer32*)value); + int32_t val = (int32_t)Int64_Get_Value((Integer64*)value); OutStream_Write_C32(dat_out, val); break; } @@ -140,7 +140,7 @@ DocWriter_Add_Inverted_Doc_IMP(DocWriter *self, Inverter *inverter, break; } case FType_FLOAT32: { - float val = Float32_Get_Value((Float32*)value); + float val = (float)Float64_Get_Value((Float64*)value); OutStream_Write_F32(dat_out, val); break; } http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/Inverter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c index 8c9fd6d..ec963a5 100644 --- a/core/Lucy/Index/Inverter.c +++ b/core/Lucy/Index/Inverter.c @@ -221,14 +221,10 @@ InvEntry_init(InverterEntry *self, Schema *schema, String *field, ivars->value = NULL; break; case FType_INT32: - ivars->value = (Obj*)Int32_new(0); - break; case FType_INT64: ivars->value = (Obj*)Int64_new(0); break; case FType_FLOAT32: - ivars->value = (Obj*)Float32_new(0); - break; case FType_FLOAT64: ivars->value = (Obj*)Float64_new(0); break; http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/Segment.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c index fdf46fc..9ef0672 100644 --- a/core/Lucy/Index/Segment.c +++ b/core/Lucy/Index/Segment.c @@ -160,13 +160,13 @@ Seg_Write_File_IMP(Segment *self, Folder *folder) { int32_t Seg_Add_Field_IMP(Segment *self, String *field) { SegmentIVARS *const ivars = Seg_IVARS(self); - Integer32 *num = (Integer32*)Hash_Fetch(ivars->by_name, field); + Integer64 *num = (Integer64*)Hash_Fetch(ivars->by_name, field); if (num) { - return Int32_Get_Value(num); + return (int32_t)Int64_Get_Value(num); } else { int32_t field_num = Vec_Get_Size(ivars->by_num); - Hash_Store(ivars->by_name, field, (Obj*)Int32_new(field_num)); + Hash_Store(ivars->by_name, field, (Obj*)Int64_new(field_num)); Vec_Push(ivars->by_num, (Obj*)Str_Clone(field)); return field_num; } @@ -257,8 +257,8 @@ Seg_Field_Num_IMP(Segment *self, String *field) { } else { SegmentIVARS *const ivars = Seg_IVARS(self); - Integer32 *num = (Integer32*)Hash_Fetch(ivars->by_name, field); - return num ? Int32_Get_Value(num) : 0; + Integer64 *num = (Integer64*)Hash_Fetch(ivars->by_name, field); + return num ? (int32_t)Int64_Get_Value(num) : 0; } } http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/SortCache/NumericSortCache.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortCache/NumericSortCache.c b/core/Lucy/Index/SortCache/NumericSortCache.c index ba4d6fc..4389996 100644 --- a/core/Lucy/Index/SortCache/NumericSortCache.c +++ b/core/Lucy/Index/SortCache/NumericSortCache.c @@ -151,7 +151,7 @@ F32SortCache_Value_IMP(Float32SortCache *self, int32_t ord) { } else { InStream_Seek(ivars->dat_in, ord * sizeof(float)); - return (Obj*)Float32_new(InStream_Read_F32(ivars->dat_in)); + return (Obj*)Float64_new(InStream_Read_F32(ivars->dat_in)); } } @@ -189,7 +189,7 @@ I32SortCache_Value_IMP(Int32SortCache *self, int32_t ord) { } else { InStream_Seek(ivars->dat_in, ord * sizeof(int32_t)); - return (Obj*)Int32_new(InStream_Read_I32(ivars->dat_in)); + return (Obj*)Int64_new(InStream_Read_I32(ivars->dat_in)); } } http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Index/SortFieldWriter.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c index d63bed2..010741d 100644 --- a/core/Lucy/Index/SortFieldWriter.c +++ b/core/Lucy/Index/SortFieldWriter.c @@ -276,23 +276,23 @@ S_write_val(Obj *val, int8_t prim_id, OutStream *ix_out, OutStream *dat_out, break; } case FType_INT32: { - Integer32 *i32 = (Integer32*)val; - OutStream_Write_I32(dat_out, Int32_Get_Value(i32)); + int32_t i32 = (int32_t)Int64_Get_Value((Integer64*)val); + OutStream_Write_I32(dat_out, i32); break; } case FType_INT64: { - Integer64 *i64 = (Integer64*)val; - OutStream_Write_I64(dat_out, Int64_Get_Value(i64)); + int64_t i64 = Int64_Get_Value((Integer64*)val); + OutStream_Write_I64(dat_out, i64); break; } - case FType_FLOAT64: { - Float64 *float64 = (Float64*)val; - OutStream_Write_F64(dat_out, Float64_Get_Value(float64)); + case FType_FLOAT32: { + float f32 = (float)Float64_Get_Value((Float64*)val); + OutStream_Write_F32(dat_out, f32); break; } - case FType_FLOAT32: { - Float32 *float32 = (Float32*)val; - OutStream_Write_F32(dat_out, Float32_Get_Value(float32)); + case FType_FLOAT64: { + double f64 = Float64_Get_Value((Float64*)val); + OutStream_Write_F64(dat_out, f64); break; } default: http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Test/Search/TestSortSpec.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c index f7a2f1e..628918e 100644 --- a/core/Lucy/Test/Search/TestSortSpec.c +++ b/core/Lucy/Test/Search/TestSortSpec.c @@ -237,13 +237,13 @@ S_add_vehicle(Indexer *indexer, String *name, int32_t speed, int32_t sloth, Doc_Store(doc, home_str, (Obj*)home); Doc_Store(doc, cat_str, (Obj*)cat); - Integer32 *speed_obj = Int32_new(speed); + Integer64 *speed_obj = Int64_new(speed); Doc_Store(doc, speed_str, (Obj*)speed_obj); DECREF(speed_obj); - Integer32 *sloth_obj = Int32_new(sloth); + Integer64 *sloth_obj = Int64_new(sloth); Doc_Store(doc, sloth_str, (Obj*)sloth_obj); DECREF(sloth_obj); - Integer32 *weight_obj = Int32_new(weight); + Integer64 *weight_obj = Int64_new(weight); Doc_Store(doc, weight_str, (Obj*)weight_obj); DECREF(weight_obj); @@ -284,7 +284,7 @@ S_random_string() { static Obj* S_random_int32() { uint64_t num = TestUtils_random_u64(); - return (Obj*)Int32_new(num & 0x7FFFFFFF); + return (Obj*)Int64_new(num & 0x7FFFFFFF); } static Obj* @@ -297,7 +297,7 @@ static Obj* S_random_float32() { uint64_t num = TestUtils_random_u64(); double d = CHY_U64_TO_DOUBLE(num) * (10.0 / UINT64_MAX); - return (Obj*)Float32_new((float)d); + return (Obj*)Float64_new((float)d); } static Obj* http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Test/Util/TestFreezer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Util/TestFreezer.c b/core/Lucy/Test/Util/TestFreezer.c index b77f20b..aff1aaf 100644 --- a/core/Lucy/Test/Util/TestFreezer.c +++ b/core/Lucy/Test/Util/TestFreezer.c @@ -93,7 +93,7 @@ test_hash(TestBatchRunner *runner) { for (uint32_t i = 0; i < 10; i++) { String *str = TestUtils_random_string(rand() % 1200); - Integer32 *num = Int32_new(i); + Integer64 *num = Int64_new(i); Hash_Store(wanted, str, (Obj*)num); DECREF(str); } @@ -117,35 +117,23 @@ test_hash(TestBatchRunner *runner) { static void test_num(TestBatchRunner *runner) { - Float32 *f32 = Float32_new(1.33f); Float64 *f64 = Float64_new(1.33); - Integer32 *i32 = Int32_new(-1); Integer64 *i64 = Int64_new(-1); - Float32 *f32_thaw = (Float32*)S_freeze_thaw((Obj*)f32); Float64 *f64_thaw = (Float64*)S_freeze_thaw((Obj*)f64); - Integer32 *i32_thaw = (Integer32*)S_freeze_thaw((Obj*)i32); Integer64 *i64_thaw = (Integer64*)S_freeze_thaw((Obj*)i64); Boolean *true_thaw = (Boolean*)S_freeze_thaw((Obj*)CFISH_TRUE); - TEST_TRUE(runner, Float32_Equals(f32, (Obj*)f32_thaw), - "Float32 freeze/thaw"); TEST_TRUE(runner, Float64_Equals(f64, (Obj*)f64_thaw), "Float64 freeze/thaw"); - TEST_TRUE(runner, Int32_Equals(i32, (Obj*)i32_thaw), - "Integer32 freeze/thaw"); TEST_TRUE(runner, Int64_Equals(i64, (Obj*)i64_thaw), "Integer64 freeze/thaw"); TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)true_thaw), "Boolean freeze/thaw"); DECREF(i64_thaw); - DECREF(i32_thaw); DECREF(f64_thaw); - DECREF(f32_thaw); DECREF(i64); - DECREF(i32); DECREF(f64); - DECREF(f32); } static void @@ -173,7 +161,7 @@ test_varray(TestBatchRunner *runner) { void TestFreezer_Run_IMP(TestFreezer *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 11); + TestBatchRunner_Plan(runner, (TestBatch*)self, 9); test_blob(runner); test_string(runner); test_hash(runner); http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/core/Lucy/Util/Freezer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c index 4512017..29b2104 100644 --- a/core/Lucy/Util/Freezer.c +++ b/core/Lucy/Util/Freezer.c @@ -66,21 +66,13 @@ Freezer_serialize(Obj *obj, OutStream *outstream) { } else if (Obj_is_a(obj, NUM)) { if (Obj_is_a(obj, INTNUM)) { - if (Obj_is_a(obj, INTEGER32)) { - int32_t val = Int32_Get_Value((Integer32*)obj); - OutStream_Write_C32(outstream, (uint32_t)val); - } - else if (Obj_is_a(obj, INTEGER64)) { + if (Obj_is_a(obj, INTEGER64)) { int64_t val = Int64_Get_Value((Integer64*)obj); OutStream_Write_C64(outstream, (uint64_t)val); } } else if (Obj_is_a(obj, FLOATNUM)) { - if (Obj_is_a(obj, FLOAT32)) { - float val = Float32_Get_Value((Float32*)obj); - OutStream_Write_F32(outstream, val); - } - else if (Obj_is_a(obj, FLOAT64)) { + if (Obj_is_a(obj, FLOAT64)) { double val = Float64_Get_Value((Float64*)obj); OutStream_Write_F64(outstream, val); } @@ -139,21 +131,13 @@ Freezer_deserialize(Obj *obj, InStream *instream) { } else if (Obj_is_a(obj, NUM)) { if (Obj_is_a(obj, INTNUM)) { - if (Obj_is_a(obj, INTEGER32)) { - int32_t value = (int32_t)InStream_Read_C32(instream); - obj = (Obj*)Int32_init((Integer32*)obj, value); - } - else if (Obj_is_a(obj, INTEGER64)) { + if (Obj_is_a(obj, INTEGER64)) { int64_t value = (int64_t)InStream_Read_C64(instream); obj = (Obj*)Int64_init((Integer64*)obj, value); } } else if (Obj_is_a(obj, FLOATNUM)) { - if (Obj_is_a(obj, FLOAT32)) { - float value = InStream_Read_F32(instream); - obj = (Obj*)Float32_init((Float32*)obj, value); - } - else if (Obj_is_a(obj, FLOAT64)) { + if (Obj_is_a(obj, FLOAT64)) { double value = InStream_Read_F64(instream); obj = (Obj*)Float64_init((Float64*)obj, value); } http://git-wip-us.apache.org/repos/asf/lucy/blob/8144f5c7/perl/xs/Lucy/Index/Inverter.c ---------------------------------------------------------------------- diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c index 4ad6e2d..b470f3a 100644 --- a/perl/xs/Lucy/Index/Inverter.c +++ b/perl/xs/Lucy/Index/Inverter.c @@ -113,23 +113,21 @@ LUCY_Inverter_Invert_Doc_IMP(lucy_Inverter *self, lucy_Doc *doc) { break; } case lucy_FType_INT32: { - cfish_Integer32* value = (cfish_Integer32*)entry_ivars->value; - CFISH_Int32_Set_Value(value, SvIV(value_sv)); + cfish_Integer64* value = (cfish_Integer64*)entry_ivars->value; + CFISH_Int64_Set_Value(value, SvIV(value_sv)); break; } case lucy_FType_INT64: { cfish_Integer64* value = (cfish_Integer64*)entry_ivars->value; + // nwellnhof: Using SvNOK could avoid a int/float/int + // round-trip with 32-bit IVs. int64_t val = sizeof(IV) == 8 ? SvIV(value_sv) : (int64_t)SvNV(value_sv); // lossy CFISH_Int64_Set_Value(value, val); break; } - case lucy_FType_FLOAT32: { - cfish_Float32* value = (cfish_Float32*)entry_ivars->value; - CFISH_Float32_Set_Value(value, (float)SvNV(value_sv)); - break; - } + case lucy_FType_FLOAT32: case lucy_FType_FLOAT64: { cfish_Float64* value = (cfish_Float64*)entry_ivars->value; CFISH_Float64_Set_Value(value, SvNV(value_sv));