You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/07/11 14:54:25 UTC

[1/6] lucy git commit: Adjust for Float/Integer renaming

Repository: lucy
Updated Branches:
  refs/heads/master 20dbfa386 -> a1d2e1c6d


Adjust for Float/Integer renaming


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

Branch: refs/heads/master
Commit: 1d2632f175e8b910238104efed6a618f80cdd9f2
Parents: 24df913
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 16:30:05 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:38:43 2015 +0200

----------------------------------------------------------------------
 c/src/Lucy/Index/DocReader.c                 | 10 +++---
 c/src/Lucy/Index/Inverter.c                  |  8 ++---
 core/Lucy/Index/DeletionsWriter.c            | 11 +++----
 core/Lucy/Index/DocWriter.c                  |  8 ++---
 core/Lucy/Index/Inverter.c                   |  4 +--
 core/Lucy/Index/Segment.c                    | 10 +++---
 core/Lucy/Index/SortCache/NumericSortCache.c |  8 ++---
 core/Lucy/Index/SortFieldWriter.c            | 10 +++---
 core/Lucy/Test/Search/TestSortSpec.c         | 14 ++++----
 core/Lucy/Test/Util/TestFreezer.c            | 18 +++++-----
 core/Lucy/Test/Util/TestJson.c               | 16 ++++-----
 core/Lucy/Test/Util/TestPriorityQueue.c      | 38 ++++++++++-----------
 core/Lucy/Util/Freezer.c                     | 20 ++++++------
 core/Lucy/Util/Json.c                        | 40 +++++++++++------------
 perl/xs/Lucy/Index/Inverter.c                | 12 +++----
 15 files changed, 112 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index b775613..1e7767b 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -86,18 +86,16 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
                     break;
                 }
             case FType_FLOAT32:
-                value = (Obj*)Float64_new(InStream_Read_F32(dat_in));
+                value = (Obj*)Float_new(InStream_Read_F32(dat_in));
                 break;
             case FType_FLOAT64:
-                value = (Obj*)Float64_new(InStream_Read_F64(dat_in));
+                value = (Obj*)Float_new(InStream_Read_F64(dat_in));
                 break;
             case FType_INT32:
-                value = (Obj*)Int64_new(
-                                (int32_t)InStream_Read_C32(dat_in));
+                value = (Obj*)Int_new((int32_t)InStream_Read_C32(dat_in));
                 break;
             case FType_INT64:
-                value = (Obj*)Int64_new(
-                                (int64_t)InStream_Read_C64(dat_in));
+                value = (Obj*)Int_new((int64_t)InStream_Read_C64(dat_in));
                 break;
             default:
                 value = NULL;

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/c/src/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/Inverter.c b/c/src/Lucy/Index/Inverter.c
index 15761f0..9f18761 100644
--- a/c/src/Lucy/Index/Inverter.c
+++ b/c/src/Lucy/Index/Inverter.c
@@ -93,14 +93,14 @@ Inverter_Invert_Doc_IMP(Inverter *self, Doc *doc) {
                 }
             case FType_INT32:
             case FType_INT64: {
-                    Integer64* value = (Integer64*)inventry_ivars->value;
-                    Int64_Mimic(value, obj);
+                    Integer* value = (Integer*)inventry_ivars->value;
+                    Int_Mimic(value, obj);
                     break;
                 }
             case FType_FLOAT32:
             case FType_FLOAT64: {
-                    Float64* value = (Float64*)inventry_ivars->value;
-                    Float64_Mimic(value, obj);
+                    Float* value = (Float*)inventry_ivars->value;
+                    Float_Mimic(value, obj);
                     break;
                 }
             default:

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/DeletionsWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsWriter.c b/core/Lucy/Index/DeletionsWriter.c
index c7c75ee..aa020ad 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*)Int64_new(i));
+                   (Obj*)Int_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);
-    Integer64 *tick_obj   = (Integer64*)Hash_Fetch(ivars->name_to_tick,
+    Integer *tick_obj     = (Integer*)Hash_Fetch(ivars->name_to_tick,
                                                    seg_name);
-    int32_t tick          = tick_obj ? (int32_t)Int64_Get_Value(tick_obj) : 0;
+    int32_t tick          = tick_obj ? (int32_t)Int_Get_Value(tick_obj) : 0;
     SegReader *candidate  = tick_obj
                             ? (SegReader*)Vec_Fetch(ivars->seg_readers, tick)
                             : NULL;
@@ -241,10 +241,9 @@ int32_t
 DefDelWriter_Seg_Del_Count_IMP(DefaultDeletionsWriter *self,
                                String *seg_name) {
     DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
-    Integer64 *tick
-        = (Integer64*)Hash_Fetch(ivars->name_to_tick, seg_name);
+    Integer *tick = (Integer*)Hash_Fetch(ivars->name_to_tick, seg_name);
     BitVector *deldocs = tick
-                         ? (BitVector*)Vec_Fetch(ivars->bit_vecs, Int64_Get_Value(tick))
+                         ? (BitVector*)Vec_Fetch(ivars->bit_vecs, Int_Get_Value(tick))
                          : NULL;
     return deldocs ? BitVec_Count(deldocs) : 0;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/DocWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c
index f9272a7..49bbf6d 100644
--- a/core/Lucy/Index/DocWriter.c
+++ b/core/Lucy/Index/DocWriter.c
@@ -130,22 +130,22 @@ DocWriter_Add_Inverted_Doc_IMP(DocWriter *self, Inverter *inverter,
                     break;
                 }
                 case FType_INT32: {
-                    int32_t val = (int32_t)Int64_Get_Value((Integer64*)value);
+                    int32_t val = (int32_t)Int_Get_Value((Integer*)value);
                     OutStream_Write_C32(dat_out, val);
                     break;
                 }
                 case FType_INT64: {
-                    int64_t val = Int64_Get_Value((Integer64*)value);
+                    int64_t val = Int_Get_Value((Integer*)value);
                     OutStream_Write_C64(dat_out, val);
                     break;
                 }
                 case FType_FLOAT32: {
-                    float val = (float)Float64_Get_Value((Float64*)value);
+                    float val = (float)Float_Get_Value((Float*)value);
                     OutStream_Write_F32(dat_out, val);
                     break;
                 }
                 case FType_FLOAT64: {
-                    double val = Float64_Get_Value((Float64*)value);
+                    double val = Float_Get_Value((Float*)value);
                     OutStream_Write_F64(dat_out, val);
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c
index ec963a5..92f43ac 100644
--- a/core/Lucy/Index/Inverter.c
+++ b/core/Lucy/Index/Inverter.c
@@ -222,11 +222,11 @@ InvEntry_init(InverterEntry *self, Schema *schema, String *field,
                 break;
             case FType_INT32:
             case FType_INT64:
-                ivars->value = (Obj*)Int64_new(0);
+                ivars->value = (Obj*)Int_new(0);
                 break;
             case FType_FLOAT32:
             case FType_FLOAT64:
-                ivars->value = (Obj*)Float64_new(0);
+                ivars->value = (Obj*)Float_new(0);
                 break;
             default:
                 THROW(ERR, "Unrecognized primitive id: %i8", prim_id);

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index 9ef0672..f016512 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);
-    Integer64 *num = (Integer64*)Hash_Fetch(ivars->by_name, field);
+    Integer *num = (Integer*)Hash_Fetch(ivars->by_name, field);
     if (num) {
-        return (int32_t)Int64_Get_Value(num);
+        return (int32_t)Int_Get_Value(num);
     }
     else {
         int32_t field_num = Vec_Get_Size(ivars->by_num);
-        Hash_Store(ivars->by_name, field, (Obj*)Int64_new(field_num));
+        Hash_Store(ivars->by_name, field, (Obj*)Int_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);
-        Integer64 *num = (Integer64*)Hash_Fetch(ivars->by_name, field);
-        return num ? (int32_t)Int64_Get_Value(num) : 0;
+        Integer *num = (Integer*)Hash_Fetch(ivars->by_name, field);
+        return num ? (int32_t)Int_Get_Value(num) : 0;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/SortCache/NumericSortCache.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortCache/NumericSortCache.c b/core/Lucy/Index/SortCache/NumericSortCache.c
index 4389996..3355978 100644
--- a/core/Lucy/Index/SortCache/NumericSortCache.c
+++ b/core/Lucy/Index/SortCache/NumericSortCache.c
@@ -113,7 +113,7 @@ F64SortCache_Value_IMP(Float64SortCache *self, int32_t ord) {
     }
     else {
         InStream_Seek(ivars->dat_in, ord * sizeof(double));
-        return (Obj*)Float64_new(InStream_Read_F64(ivars->dat_in));
+        return (Obj*)Float_new(InStream_Read_F64(ivars->dat_in));
     }
 }
 
@@ -151,7 +151,7 @@ F32SortCache_Value_IMP(Float32SortCache *self, int32_t ord) {
     }
     else {
         InStream_Seek(ivars->dat_in, ord * sizeof(float));
-        return (Obj*)Float64_new(InStream_Read_F32(ivars->dat_in));
+        return (Obj*)Float_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*)Int64_new(InStream_Read_I32(ivars->dat_in));
+        return (Obj*)Int_new(InStream_Read_I32(ivars->dat_in));
     }
 }
 
@@ -227,7 +227,7 @@ I64SortCache_Value_IMP(Int64SortCache *self, int32_t ord) {
     }
     else {
         InStream_Seek(ivars->dat_in, ord * sizeof(int64_t));
-        return (Obj*)Int64_new(InStream_Read_I64(ivars->dat_in));
+        return (Obj*)Int_new(InStream_Read_I64(ivars->dat_in));
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 010741d..bb05aa0 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -132,7 +132,7 @@ SortFieldWriter_init(SortFieldWriter *self, Schema *schema,
         ivars->var_width = true;
     }
     else {
-        ivars->mem_per_entry += Class_Get_Obj_Alloc_Size(FLOAT64);
+        ivars->mem_per_entry += Class_Get_Obj_Alloc_Size(FLOAT);
         ivars->var_width = false;
     }
 
@@ -276,22 +276,22 @@ S_write_val(Obj *val, int8_t prim_id, OutStream *ix_out, OutStream *dat_out,
                     break;
                 }
             case FType_INT32: {
-                    int32_t i32 = (int32_t)Int64_Get_Value((Integer64*)val);
+                    int32_t i32 = (int32_t)Int_Get_Value((Integer*)val);
                     OutStream_Write_I32(dat_out, i32);
                     break;
                 }
             case FType_INT64: {
-                    int64_t i64 = Int64_Get_Value((Integer64*)val);
+                    int64_t i64 = Int_Get_Value((Integer*)val);
                     OutStream_Write_I64(dat_out, i64);
                     break;
                 }
             case FType_FLOAT32: {
-                    float f32 = (float)Float64_Get_Value((Float64*)val);
+                    float f32 = (float)Float_Get_Value((Float*)val);
                     OutStream_Write_F32(dat_out, f32);
                     break;
                 }
             case FType_FLOAT64: {
-                    double f64 = Float64_Get_Value((Float64*)val);
+                    double f64 = Float_Get_Value((Float*)val);
                     OutStream_Write_F64(dat_out, f64);
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index 628918e..6b4afb2 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);
 
-    Integer64 *speed_obj = Int64_new(speed);
+    Integer *speed_obj = Int_new(speed);
     Doc_Store(doc, speed_str, (Obj*)speed_obj);
     DECREF(speed_obj);
-    Integer64 *sloth_obj = Int64_new(sloth);
+    Integer *sloth_obj = Int_new(sloth);
     Doc_Store(doc, sloth_str, (Obj*)sloth_obj);
     DECREF(sloth_obj);
-    Integer64 *weight_obj = Int64_new(weight);
+    Integer *weight_obj = Int_new(weight);
     Doc_Store(doc, weight_str, (Obj*)weight_obj);
     DECREF(weight_obj);
 
@@ -284,26 +284,26 @@ S_random_string() {
 static Obj*
 S_random_int32() {
     uint64_t num = TestUtils_random_u64();
-    return (Obj*)Int64_new(num & 0x7FFFFFFF);
+    return (Obj*)Int_new(num & 0x7FFFFFFF);
 }
 
 static Obj*
 S_random_int64() {
     uint64_t num = TestUtils_random_u64();
-    return (Obj*)Int64_new(num & INT64_C(0x7FFFFFFFFFFFFFFF));
+    return (Obj*)Int_new(num & INT64_C(0x7FFFFFFFFFFFFFFF));
 }
 
 static Obj*
 S_random_float32() {
     uint64_t num = TestUtils_random_u64();
     double d = CHY_U64_TO_DOUBLE(num) * (10.0 / UINT64_MAX);
-    return (Obj*)Float64_new((float)d);
+    return (Obj*)Float_new((float)d);
 }
 
 static Obj*
 S_random_float64() {
     uint64_t num = TestUtils_random_u64();
-    return (Obj*)Float64_new(CHY_U64_TO_DOUBLE(num) * (10.0 / UINT64_MAX));
+    return (Obj*)Float_new(CHY_U64_TO_DOUBLE(num) * (10.0 / UINT64_MAX));
 }
 
 static Vector*

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Test/Util/TestFreezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestFreezer.c b/core/Lucy/Test/Util/TestFreezer.c
index aff1aaf..50543bc 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);
-        Integer64 *num = Int64_new(i);
+        Integer *num = Int_new(i);
         Hash_Store(wanted, str, (Obj*)num);
         DECREF(str);
     }
@@ -117,16 +117,16 @@ test_hash(TestBatchRunner *runner) {
 
 static void
 test_num(TestBatchRunner *runner) {
-    Float64   *f64 = Float64_new(1.33);
-    Integer64 *i64 = Int64_new(-1);
-    Float64   *f64_thaw = (Float64*)S_freeze_thaw((Obj*)f64);
-    Integer64 *i64_thaw = (Integer64*)S_freeze_thaw((Obj*)i64);
+    Float   *f64 = Float_new(1.33);
+    Integer *i64 = Int_new(-1);
+    Float   *f64_thaw = (Float*)S_freeze_thaw((Obj*)f64);
+    Integer *i64_thaw = (Integer*)S_freeze_thaw((Obj*)i64);
     Boolean   *true_thaw = (Boolean*)S_freeze_thaw((Obj*)CFISH_TRUE);
 
-    TEST_TRUE(runner, Float64_Equals(f64, (Obj*)f64_thaw),
-              "Float64 freeze/thaw");
-    TEST_TRUE(runner, Int64_Equals(i64, (Obj*)i64_thaw),
-              "Integer64 freeze/thaw");
+    TEST_TRUE(runner, Float_Equals(f64, (Obj*)f64_thaw),
+              "Float freeze/thaw");
+    TEST_TRUE(runner, Int_Equals(i64, (Obj*)i64_thaw),
+              "Integer freeze/thaw");
     TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)true_thaw),
               "Boolean freeze/thaw");
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Test/Util/TestJson.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestJson.c b/core/Lucy/Test/Util/TestJson.c
index f6dc731..8e858d8 100644
--- a/core/Lucy/Test/Util/TestJson.c
+++ b/core/Lucy/Test/Util/TestJson.c
@@ -160,14 +160,14 @@ test_escapes(TestBatchRunner *runner) {
 
 static void
 test_numbers(TestBatchRunner *runner) {
-    Integer64 *i64     = Int64_new(33);
-    String    *json    = Json_to_json((Obj*)i64);
-    String    *trimmed = Str_Trim(json);
+    Integer *i64     = Int_new(33);
+    String  *json    = Json_to_json((Obj*)i64);
+    String  *trimmed = Str_Trim(json);
     TEST_TRUE(runner, Str_Equals_Utf8(trimmed, "33", 2), "Integer");
     DECREF(json);
     DECREF(trimmed);
 
-    Float64 *f64 = Float64_new(33.33);
+    Float *f64 = Float_new(33.33);
     json = Json_to_json((Obj*)f64);
     if (json) {
         double value = Str_To_F64(json);
@@ -278,7 +278,7 @@ test_syntax_errors(TestBatchRunner *runner) {
 
 static void
 S_round_trip_integer(TestBatchRunner *runner, int64_t value) {
-    Integer64 *num = Int64_new(value);
+    Integer *num = Int_new(value);
     Vector *array = Vec_new(1);
     Vec_Store(array, 0, (Obj*)num);
     String *json = Json_to_json((Obj*)array);
@@ -300,13 +300,13 @@ test_integers(TestBatchRunner *runner) {
 
 static void
 S_round_trip_float(TestBatchRunner *runner, double value, double max_diff) {
-    Float64 *num = Float64_new(value);
+    Float *num = Float_new(value);
     Vector *array = Vec_new(1);
     Vec_Store(array, 0, (Obj*)num);
     String *json = Json_to_json((Obj*)array);
     Obj *dump = CERTIFY(Json_from_json(json), VECTOR);
-    Float64 *got = (Float64*)CERTIFY(Vec_Fetch((Vector*)dump, 0), FLOAT64);
-    double diff = Float64_Get_Value(num) - Float64_Get_Value(got);
+    Float *got = (Float*)CERTIFY(Vec_Fetch((Vector*)dump, 0), FLOAT);
+    double diff = Float_Get_Value(num) - Float_Get_Value(got);
     if (diff < 0) { diff = 0 - diff; }
     TEST_TRUE(runner, diff <= max_diff, "Round trip float %f", value);
     DECREF(dump);

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Test/Util/TestPriorityQueue.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestPriorityQueue.c b/core/Lucy/Test/Util/TestPriorityQueue.c
index 4e939f2..e84bf3a 100644
--- a/core/Lucy/Test/Util/TestPriorityQueue.c
+++ b/core/Lucy/Test/Util/TestPriorityQueue.c
@@ -37,23 +37,23 @@ NumPriQ_new(uint32_t max_size) {
 
 bool
 NumPriQ_Less_Than_IMP(NumPriorityQueue *self, Obj *a, Obj *b) {
-    Float64 *num_a = (Float64*)a;
-    Float64 *num_b = (Float64*)b;
+    Float *num_a = (Float*)a;
+    Float *num_b = (Float*)b;
     UNUSED_VAR(self);
-    return Float64_Get_Value(num_a) < Float64_Get_Value(num_b) ? true : false;
+    return Float_Get_Value(num_a) < Float_Get_Value(num_b) ? true : false;
 }
 
 static void
 S_insert_num(NumPriorityQueue *pq, int32_t value) {
-    NumPriQ_Insert(pq, (Obj*)Float64_new((double)value));
+    NumPriQ_Insert(pq, (Obj*)Float_new((double)value));
 }
 
 static int32_t
 S_pop_num(NumPriorityQueue *pq) {
-    Float64 *num = (Float64*)NumPriQ_Pop(pq);
+    Float *num = (Float*)NumPriQ_Pop(pq);
     int32_t retval;
     if (!num) { THROW(ERR, "Queue is empty"); }
-    retval = (int32_t)Float64_Get_Value(num);
+    retval = (int32_t)Float_Get_Value(num);
     DECREF(num);
     return retval;
 }
@@ -61,28 +61,28 @@ S_pop_num(NumPriorityQueue *pq) {
 static void
 test_Peek_and_Pop_All(TestBatchRunner *runner) {
     NumPriorityQueue *pq = NumPriQ_new(5);
-    Float64 *val;
+    Float *val;
 
     S_insert_num(pq, 3);
     S_insert_num(pq, 1);
     S_insert_num(pq, 2);
     S_insert_num(pq, 20);
     S_insert_num(pq, 10);
-    val = (Float64*)CERTIFY(NumPriQ_Peek(pq), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val), 1,
+    val = (Float*)CERTIFY(NumPriQ_Peek(pq), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val), 1,
                 "peek at the least item in the queue");
 
     Vector  *got = NumPriQ_Pop_All(pq);
-    val = (Float64*)CERTIFY(Vec_Fetch(got, 0), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val), 20, "pop_all");
-    val = (Float64*)CERTIFY(Vec_Fetch(got, 1), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val), 10, "pop_all");
-    val = (Float64*)CERTIFY(Vec_Fetch(got, 2), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val),  3, "pop_all");
-    val = (Float64*)CERTIFY(Vec_Fetch(got, 3), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val),  2, "pop_all");
-    val = (Float64*)CERTIFY(Vec_Fetch(got, 4), FLOAT64);
-    TEST_INT_EQ(runner, (long)Float64_Get_Value(val),  1, "pop_all");
+    val = (Float*)CERTIFY(Vec_Fetch(got, 0), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val), 20, "pop_all");
+    val = (Float*)CERTIFY(Vec_Fetch(got, 1), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val), 10, "pop_all");
+    val = (Float*)CERTIFY(Vec_Fetch(got, 2), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val),  3, "pop_all");
+    val = (Float*)CERTIFY(Vec_Fetch(got, 3), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val),  2, "pop_all");
+    val = (Float*)CERTIFY(Vec_Fetch(got, 4), FLOAT);
+    TEST_INT_EQ(runner, (long)Float_Get_Value(val),  1, "pop_all");
 
     DECREF(got);
     DECREF(pq);

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index afb37e6..11b82d5 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -64,12 +64,12 @@ Freezer_serialize(Obj *obj, OutStream *outstream) {
     else if (Obj_is_a(obj, HASH)) {
         Freezer_serialize_hash((Hash*)obj, outstream);
     }
-    else if (Obj_is_a(obj, INTEGER64)) {
-        int64_t val = Int64_Get_Value((Integer64*)obj);
+    else if (Obj_is_a(obj, INTEGER)) {
+        int64_t val = Int_Get_Value((Integer*)obj);
         OutStream_Write_C64(outstream, (uint64_t)val);
     }
-    else if (Obj_is_a(obj, FLOAT64)) {
-        double val = Float64_Get_Value((Float64*)obj);
+    else if (Obj_is_a(obj, FLOAT)) {
+        double val = Float_Get_Value((Float*)obj);
         OutStream_Write_F64(outstream, val);
     }
     else if (Obj_is_a(obj, BOOLEAN)) {
@@ -123,13 +123,13 @@ Freezer_deserialize(Obj *obj, InStream *instream) {
     else if (Obj_is_a(obj, HASH)) {
         obj = (Obj*)Freezer_deserialize_hash((Hash*)obj, instream);
     }
-    else if (Obj_is_a(obj, INTEGER64)) {
+    else if (Obj_is_a(obj, INTEGER)) {
         int64_t value = (int64_t)InStream_Read_C64(instream);
-        obj = (Obj*)Int64_init((Integer64*)obj, value);
+        obj = (Obj*)Int_init((Integer*)obj, value);
     }
-    else if (Obj_is_a(obj, FLOAT64)) {
+    else if (Obj_is_a(obj, FLOAT)) {
         double value = InStream_Read_F64(instream);
-        obj = (Obj*)Float64_init((Float64*)obj, value);
+        obj = (Obj*)Float_init((Float*)obj, value);
     }
     else if (Obj_is_a(obj, BOOLEAN)) {
         bool value = !!InStream_Read_U8(instream);
@@ -358,8 +358,8 @@ Freezer_dump(Obj *obj) {
     else if (Obj_is_a(obj, QUERY)) {
         return Query_Dump((Query*)obj);
     }
-    else if (Obj_is_a(obj, FLOAT64)
-             || Obj_is_a(obj, INTEGER64)
+    else if (Obj_is_a(obj, FLOAT)
+             || Obj_is_a(obj, INTEGER)
              || Obj_is_a(obj, BOOLEAN)) {
         return Obj_Clone(obj);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 4d5ad8a..002485e 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -51,7 +51,7 @@ static Obj*
 S_do_parse_json(void *json_parser, const char *json, size_t len);
 
 // Parse a JSON number.  Advance the text buffer just past the number.
-static Float64*
+static Float*
 S_parse_number(const char **json_ptr, const char *limit);
 
 // Parse a JSON string.  Advance the text buffer from pointing at the opening
@@ -281,11 +281,11 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
     else if (Obj_is_a(dump, STRING)) {
         S_append_json_string((String*)dump, buf);
     }
-    else if (Obj_is_a(dump, INTEGER64)) {
-        CB_catf(buf, "%i64", Int64_Get_Value((Integer64*)dump));
+    else if (Obj_is_a(dump, INTEGER)) {
+        CB_catf(buf, "%i64", Int_Get_Value((Integer*)dump));
     }
-    else if (Obj_is_a(dump, FLOAT64)) {
-        CB_catf(buf, "%f64", Float64_Get_Value((Float64*)dump));
+    else if (Obj_is_a(dump, FLOAT)) {
+        CB_catf(buf, "%f64", Float_Get_Value((Float*)dump));
     }
     else if (Obj_is_a(dump, VECTOR)) {
         Vector *array = (Vector*)dump;
@@ -492,7 +492,7 @@ S_do_parse_json(void *json_parser, const char *json, size_t len) {
     return state.result;
 }
 
-static Float64*
+static Float*
 S_parse_number(const char **json_ptr, const char *limit) {
     const char *top = *json_ptr;
     const char *end = top;
@@ -515,13 +515,13 @@ S_parse_number(const char **json_ptr, const char *limit) {
         }
     }
 
-    Float64 *result = NULL;
+    Float *result = NULL;
     if (terminated) {
         char *terminus;
         double number = strtod(top, &terminus);
         if (terminus != top) {
             *json_ptr = terminus;
-            result = Float64_new(number);
+            result = Float_new(number);
         }
     }
     if (!result) {
@@ -708,11 +708,11 @@ Json_obj_to_i64(Obj *obj) {
     if (!obj) {
         THROW(ERR, "Can't extract integer from NULL");
     }
-    else if (Obj_is_a(obj, INTEGER64)) {
-        retval = Int64_Get_Value((Integer64*)obj);
+    else if (Obj_is_a(obj, INTEGER)) {
+        retval = Int_Get_Value((Integer*)obj);
     }
-    else if (Obj_is_a(obj, FLOAT64)) {
-        retval = Float64_To_I64((Float64*)obj);
+    else if (Obj_is_a(obj, FLOAT)) {
+        retval = Float_To_I64((Float*)obj);
     }
     else if (Obj_is_a(obj, STRING)) {
         retval = Str_To_I64((String*)obj);
@@ -732,11 +732,11 @@ Json_obj_to_f64(Obj *obj) {
     if (!obj) {
         THROW(ERR, "Can't extract float from NULL");
     }
-    else if (Obj_is_a(obj, FLOAT64)) {
-        retval = Float64_Get_Value((Float64*)obj);
+    else if (Obj_is_a(obj, FLOAT)) {
+        retval = Float_Get_Value((Float*)obj);
     }
-    else if (Obj_is_a(obj, INTEGER64)) {
-        retval = Int64_To_F64((Integer64*)obj);
+    else if (Obj_is_a(obj, INTEGER)) {
+        retval = Int_To_F64((Integer*)obj);
     }
     else if (Obj_is_a(obj, STRING)) {
         retval = Str_To_F64((String*)obj);
@@ -759,11 +759,11 @@ Json_obj_to_bool(Obj *obj) {
     else if (Obj_is_a(obj, BOOLEAN)) {
         retval = Bool_Get_Value((Boolean*)obj);
     }
-    else if (Obj_is_a(obj, INTEGER64)) {
-        retval = Int64_To_Bool((Integer64*)obj);
+    else if (Obj_is_a(obj, INTEGER)) {
+        retval = Int_To_Bool((Integer*)obj);
     }
-    else if (Obj_is_a(obj, FLOAT64)) {
-        retval = Float64_To_Bool((Float64*)obj);
+    else if (Obj_is_a(obj, FLOAT)) {
+        retval = Float_To_Bool((Float*)obj);
     }
     else if (Obj_is_a(obj, STRING)) {
         retval = (Str_To_I64((String*)obj) != 0);

http://git-wip-us.apache.org/repos/asf/lucy/blob/1d2632f1/perl/xs/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c
index b470f3a..f2193bd 100644
--- a/perl/xs/Lucy/Index/Inverter.c
+++ b/perl/xs/Lucy/Index/Inverter.c
@@ -113,24 +113,24 @@ LUCY_Inverter_Invert_Doc_IMP(lucy_Inverter *self, lucy_Doc *doc) {
                     break;
                 }
             case lucy_FType_INT32: {
-                    cfish_Integer64* value = (cfish_Integer64*)entry_ivars->value;
-                    CFISH_Int64_Set_Value(value, SvIV(value_sv));
+                    cfish_Integer* value = (cfish_Integer*)entry_ivars->value;
+                    CFISH_Int_Set_Value(value, SvIV(value_sv));
                     break;
                 }
             case lucy_FType_INT64: {
-                    cfish_Integer64* value = (cfish_Integer64*)entry_ivars->value;
+                    cfish_Integer* value = (cfish_Integer*)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);
+                    CFISH_Int_Set_Value(value, val);
                     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));
+                    cfish_Float* value = (cfish_Float*)entry_ivars->value;
+                    CFISH_Float_Set_Value(value, SvNV(value_sv));
                     break;
                 }
             default:


[4/6] lucy git commit: Adjust for Float32/Int32 removal

Posted by nw...@apache.org.
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 <we...@aevum.de>
Authored: Thu Jul 9 14:46:15 2015 +0200
Committer: Nick Wellnhofer <we...@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));


[6/6] lucy git commit: Merge branch 'num_hierarchy'

Posted by nw...@apache.org.
Merge branch 'num_hierarchy'


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

Branch: refs/heads/master
Commit: a1d2e1c6d849f66463dffbee6b5f597a1c0b8aeb
Parents: 20dbfa3 4022324
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Jul 11 14:54:06 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jul 11 14:54:06 2015 +0200

----------------------------------------------------------------------
 c/src/Lucy/Index/DocReader.c                 | 12 ++--
 c/src/Lucy/Index/Inverter.c                  | 31 +++------
 core/Lucy/Analysis/Normalizer.c              |  4 +-
 core/Lucy/Index/DeletionsWriter.c            | 11 ++-
 core/Lucy/Index/DocWriter.c                  |  8 +--
 core/Lucy/Index/Inverter.c                   | 26 +------
 core/Lucy/Index/Segment.c                    | 10 +--
 core/Lucy/Index/SortCache/NumericSortCache.c |  8 +--
 core/Lucy/Index/SortFieldWriter.c            | 22 +++---
 core/Lucy/Test/Analysis/TestNormalizer.c     |  4 +-
 core/Lucy/Test/Search/TestSortSpec.c         | 14 ++--
 core/Lucy/Test/Util/TestFreezer.c            | 38 ++++------
 core/Lucy/Test/Util/TestJson.c               | 16 ++---
 core/Lucy/Test/Util/TestPriorityQueue.c      | 38 +++++-----
 core/Lucy/Util/Freezer.c                     | 84 ++++++++---------------
 core/Lucy/Util/Json.c                        | 46 ++++++++-----
 core/Lucy/Util/ToolSet.h                     |  1 +
 perl/xs/Lucy/Index/Inverter.c                | 31 ++++-----
 18 files changed, 168 insertions(+), 236 deletions(-)
----------------------------------------------------------------------



[5/6] lucy git commit: Adjust for immutable Float/Integer

Posted by nw...@apache.org.
Adjust for immutable Float/Integer


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

Branch: refs/heads/master
Commit: 40223249cbd7dd2cbf7cc0d983ca784dc1e5bae3
Parents: 1d2632f
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 17:44:28 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Jul 11 14:53:49 2015 +0200

----------------------------------------------------------------------
 c/src/Lucy/Index/Inverter.c   | 19 +++++++++----------
 core/Lucy/Index/Inverter.c    | 22 +---------------------
 perl/xs/Lucy/Index/Inverter.c | 23 ++++++++++-------------
 3 files changed, 20 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/40223249/c/src/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/Inverter.c b/c/src/Lucy/Index/Inverter.c
index 9f18761..dfebb94 100644
--- a/c/src/Lucy/Index/Inverter.c
+++ b/c/src/Lucy/Index/Inverter.c
@@ -80,33 +80,32 @@ Inverter_Invert_Doc_IMP(Inverter *self, Doc *doc) {
         // Get the field value.
         switch (FType_Primitive_ID(type) & FType_PRIMITIVE_ID_MASK) {
             case FType_TEXT: {
-                    String *string = (String*)CERTIFY(obj, STRING);
-                    DECREF(inventry_ivars->value);
-                    inventry_ivars->value = INCREF(string);
+                    CERTIFY(obj, STRING);
                     break;
                 }
             case FType_BLOB: {
-                    Blob *blob = (Blob*)CERTIFY(obj, BLOB);
-                    DECREF(inventry_ivars->value);
-                    inventry_ivars->value = INCREF(blob);
+                    CERTIFY(obj, BLOB);
                     break;
                 }
             case FType_INT32:
             case FType_INT64: {
-                    Integer* value = (Integer*)inventry_ivars->value;
-                    Int_Mimic(value, obj);
+                    CERTIFY(obj, INTEGER);
                     break;
                 }
             case FType_FLOAT32:
             case FType_FLOAT64: {
-                    Float* value = (Float*)inventry_ivars->value;
-                    Float_Mimic(value, obj);
+                    CERTIFY(obj, FLOAT);
                     break;
                 }
             default:
                 THROW(ERR, "Unrecognized type: %o", type);
         }
 
+        if (inventry_ivars->value != obj) {
+            DECREF(inventry_ivars->value);
+            inventry_ivars->value = INCREF(obj);
+        }
+
         Inverter_Add_Field(self, inventry);
     }
     DECREF(iter);

http://git-wip-us.apache.org/repos/asf/lucy/blob/40223249/core/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c
index 92f43ac..c6d1873 100644
--- a/core/Lucy/Index/Inverter.c
+++ b/core/Lucy/Index/Inverter.c
@@ -211,27 +211,7 @@ InvEntry_init(InverterEntry *self, Schema *schema, String *field,
         ivars->sim  = (Similarity*)INCREF(Schema_Fetch_Sim(schema, field));
         ivars->type = (FieldType*)INCREF(Schema_Fetch_Type(schema, field));
         if (!ivars->type) { THROW(ERR, "Unknown field: '%o'", field); }
-
-        uint8_t prim_id = FType_Primitive_ID(ivars->type);
-        switch (prim_id & FType_PRIMITIVE_ID_MASK) {
-            case FType_TEXT:
-                ivars->value = NULL;
-                break;
-            case FType_BLOB:
-                ivars->value = NULL;
-                break;
-            case FType_INT32:
-            case FType_INT64:
-                ivars->value = (Obj*)Int_new(0);
-                break;
-            case FType_FLOAT32:
-            case FType_FLOAT64:
-                ivars->value = (Obj*)Float_new(0);
-                break;
-            default:
-                THROW(ERR, "Unrecognized primitive id: %i8", prim_id);
-        }
-
+        ivars->value   = NULL;
         ivars->indexed = FType_Indexed(ivars->type);
         if (ivars->indexed && FType_is_a(ivars->type, NUMERICTYPE)) {
             THROW(ERR, "Field '%o' spec'd as indexed, but numerical types cannot "

http://git-wip-us.apache.org/repos/asf/lucy/blob/40223249/perl/xs/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c
index f2193bd..dfd436d 100644
--- a/perl/xs/Lucy/Index/Inverter.c
+++ b/perl/xs/Lucy/Index/Inverter.c
@@ -92,51 +92,48 @@ LUCY_Inverter_Invert_Doc_IMP(lucy_Inverter *self, lucy_Doc *doc) {
         lucy_InverterEntryIVARS *const entry_ivars
             = lucy_InvEntry_IVARS(inv_entry);
         lucy_FieldType *type = entry_ivars->type;
+        cfish_Obj *obj = NULL;
 
         // Get the field value, forcing text fields to UTF-8.
         switch (LUCY_FType_Primitive_ID(type) & lucy_FType_PRIMITIVE_ID_MASK) {
             case lucy_FType_TEXT: {
                     STRLEN val_len;
                     char *val_ptr = SvPVutf8(value_sv, val_len);
-                    CFISH_DECREF(entry_ivars->value);
-                    entry_ivars->value
-                        = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(
-                                val_ptr, val_len);
+                    obj = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(val_ptr,
+                                                                      val_len);
                     break;
                 }
             case lucy_FType_BLOB: {
                     STRLEN val_len;
                     char *val_ptr = SvPV(value_sv, val_len);
-                    CFISH_DECREF(entry_ivars->value);
-                    entry_ivars->value
-                        = (cfish_Obj*)cfish_Blob_new_wrap(val_ptr, val_len);
+                    obj = (cfish_Obj*)cfish_Blob_new_wrap(val_ptr, val_len);
                     break;
                 }
             case lucy_FType_INT32: {
-                    cfish_Integer* value = (cfish_Integer*)entry_ivars->value;
-                    CFISH_Int_Set_Value(value, SvIV(value_sv));
+                    obj = (cfish_Obj*)cfish_Int_new(SvIV(value_sv));
                     break;
                 }
             case lucy_FType_INT64: {
-                    cfish_Integer* value = (cfish_Integer*)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_Int_Set_Value(value, val);
+                    obj = (cfish_Obj*)cfish_Int_new(val);
                     break;
                 }
             case lucy_FType_FLOAT32:
             case lucy_FType_FLOAT64: {
-                    cfish_Float* value = (cfish_Float*)entry_ivars->value;
-                    CFISH_Float_Set_Value(value, SvNV(value_sv));
+                    obj = (cfish_Obj*)cfish_Float_new(SvNV(value_sv));
                     break;
                 }
             default:
                 THROW(CFISH_ERR, "Unrecognized type: %o", type);
         }
 
+        CFISH_DECREF(entry_ivars->value);
+        entry_ivars->value = obj;
+
         LUCY_Inverter_Add_Field(self, inv_entry);
     }
 }


[3/6] lucy git commit: Adjust for Num hierarchy changes

Posted by nw...@apache.org.
Adjust for Num hierarchy changes


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

Branch: refs/heads/master
Commit: 24df913d7de97d0f15aabcd8ebf243468231ab99
Parents: 8144f5c
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 15:53:47 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:38:43 2015 +0200

----------------------------------------------------------------------
 core/Lucy/Util/Freezer.c | 44 +++++++++++++++++--------------------------
 core/Lucy/Util/Json.c    | 33 ++++++++++++++++++++------------
 2 files changed, 38 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/24df913d/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index 29b2104..afb37e6 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -64,19 +64,13 @@ Freezer_serialize(Obj *obj, OutStream *outstream) {
     else if (Obj_is_a(obj, HASH)) {
         Freezer_serialize_hash((Hash*)obj, outstream);
     }
-    else if (Obj_is_a(obj, NUM)) {
-        if (Obj_is_a(obj, INTNUM)) {
-            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, FLOAT64)) {
-                double val = Float64_Get_Value((Float64*)obj);
-                OutStream_Write_F64(outstream, val);
-            }
-        }
+    else 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, FLOAT64)) {
+        double val = Float64_Get_Value((Float64*)obj);
+        OutStream_Write_F64(outstream, val);
     }
     else if (Obj_is_a(obj, BOOLEAN)) {
         bool val = Bool_Get_Value((Boolean*)obj);
@@ -129,19 +123,13 @@ Freezer_deserialize(Obj *obj, InStream *instream) {
     else if (Obj_is_a(obj, HASH)) {
         obj = (Obj*)Freezer_deserialize_hash((Hash*)obj, instream);
     }
-    else if (Obj_is_a(obj, NUM)) {
-        if (Obj_is_a(obj, INTNUM)) {
-            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, FLOAT64)) {
-                double value = InStream_Read_F64(instream);
-                obj = (Obj*)Float64_init((Float64*)obj, value);
-            }
-        }
+    else 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, FLOAT64)) {
+        double value = InStream_Read_F64(instream);
+        obj = (Obj*)Float64_init((Float64*)obj, value);
     }
     else if (Obj_is_a(obj, BOOLEAN)) {
         bool value = !!InStream_Read_U8(instream);
@@ -370,7 +358,9 @@ Freezer_dump(Obj *obj) {
     else if (Obj_is_a(obj, QUERY)) {
         return Query_Dump((Query*)obj);
     }
-    else if (Obj_is_a(obj, NUM) || Obj_is_a(obj, BOOLEAN)) {
+    else if (Obj_is_a(obj, FLOAT64)
+             || Obj_is_a(obj, INTEGER64)
+             || Obj_is_a(obj, BOOLEAN)) {
         return Obj_Clone(obj);
     }
     else {

http://git-wip-us.apache.org/repos/asf/lucy/blob/24df913d/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index d440fe9..4d5ad8a 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -281,11 +281,11 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
     else if (Obj_is_a(dump, STRING)) {
         S_append_json_string((String*)dump, buf);
     }
-    else if (Obj_is_a(dump, INTNUM)) {
-        CB_catf(buf, "%i64", IntNum_To_I64((IntNum*)dump));
+    else if (Obj_is_a(dump, INTEGER64)) {
+        CB_catf(buf, "%i64", Int64_Get_Value((Integer64*)dump));
     }
-    else if (Obj_is_a(dump, FLOATNUM)) {
-        CB_catf(buf, "%f64", FloatNum_To_F64((FloatNum*)dump));
+    else if (Obj_is_a(dump, FLOAT64)) {
+        CB_catf(buf, "%f64", Float64_Get_Value((Float64*)dump));
     }
     else if (Obj_is_a(dump, VECTOR)) {
         Vector *array = (Vector*)dump;
@@ -708,12 +708,15 @@ Json_obj_to_i64(Obj *obj) {
     if (!obj) {
         THROW(ERR, "Can't extract integer from NULL");
     }
+    else if (Obj_is_a(obj, INTEGER64)) {
+        retval = Int64_Get_Value((Integer64*)obj);
+    }
+    else if (Obj_is_a(obj, FLOAT64)) {
+        retval = Float64_To_I64((Float64*)obj);
+    }
     else if (Obj_is_a(obj, STRING)) {
         retval = Str_To_I64((String*)obj);
     }
-    else if (Obj_is_a(obj, NUM)) {
-        retval = Num_To_I64((Num*)obj);
-    }
     else {
         THROW(ERR, "Can't extract integer from object of type %o",
               Obj_get_class_name(obj));
@@ -729,12 +732,15 @@ Json_obj_to_f64(Obj *obj) {
     if (!obj) {
         THROW(ERR, "Can't extract float from NULL");
     }
+    else if (Obj_is_a(obj, FLOAT64)) {
+        retval = Float64_Get_Value((Float64*)obj);
+    }
+    else if (Obj_is_a(obj, INTEGER64)) {
+        retval = Int64_To_F64((Integer64*)obj);
+    }
     else if (Obj_is_a(obj, STRING)) {
         retval = Str_To_F64((String*)obj);
     }
-    else if (Obj_is_a(obj, NUM)) {
-        retval = Num_To_F64((Num*)obj);
-    }
     else {
         THROW(ERR, "Can't extract float from object of type %o",
               Obj_get_class_name(obj));
@@ -753,8 +759,11 @@ Json_obj_to_bool(Obj *obj) {
     else if (Obj_is_a(obj, BOOLEAN)) {
         retval = Bool_Get_Value((Boolean*)obj);
     }
-    else if (Obj_is_a(obj, NUM)) {
-        retval = Num_To_Bool((Num*)obj);
+    else if (Obj_is_a(obj, INTEGER64)) {
+        retval = Int64_To_Bool((Integer64*)obj);
+    }
+    else if (Obj_is_a(obj, FLOAT64)) {
+        retval = Float64_To_Bool((Float64*)obj);
     }
     else if (Obj_is_a(obj, STRING)) {
         retval = (Str_To_I64((String*)obj) != 0);


[2/6] lucy git commit: Adjust for Clownfish::Boolean changes

Posted by nw...@apache.org.
Adjust for Clownfish::Boolean changes


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

Branch: refs/heads/master
Commit: 957ae1e5c355f3b2bddfa0ed37d6063ed6f93cd6
Parents: 20dbfa3
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 13:44:51 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:38:43 2015 +0200

----------------------------------------------------------------------
 core/Lucy/Analysis/Normalizer.c          |  4 ++--
 core/Lucy/Test/Analysis/TestNormalizer.c |  4 ++--
 core/Lucy/Test/Util/TestFreezer.c        |  4 ++--
 core/Lucy/Util/Freezer.c                 | 30 +++++++++++++--------------
 core/Lucy/Util/Json.c                    |  7 +++++--
 core/Lucy/Util/ToolSet.h                 |  1 +
 6 files changed, 27 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Analysis/Normalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Normalizer.c b/core/Lucy/Analysis/Normalizer.c
index eea503e..6be0e96 100644
--- a/core/Lucy/Analysis/Normalizer.c
+++ b/core/Lucy/Analysis/Normalizer.c
@@ -136,10 +136,10 @@ Normalizer_Dump_IMP(Normalizer *self) {
 
     Hash_Store_Utf8(dump, "normalization_form", 18, (Obj*)form);
 
-    BoolNum *case_fold = Bool_singleton(!!(options & UTF8PROC_CASEFOLD));
+    Boolean *case_fold = Bool_singleton(!!(options & UTF8PROC_CASEFOLD));
     Hash_Store_Utf8(dump, "case_fold", 9, (Obj*)case_fold);
 
-    BoolNum *strip_accents = Bool_singleton(!!(options & UTF8PROC_STRIPMARK));
+    Boolean *strip_accents = Bool_singleton(!!(options & UTF8PROC_STRIPMARK));
     Hash_Store_Utf8(dump, "strip_accents", 13, (Obj*)strip_accents);
 
     return dump;

http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Test/Analysis/TestNormalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestNormalizer.c b/core/Lucy/Test/Analysis/TestNormalizer.c
index 0b8f85c..34bd173 100644
--- a/core/Lucy/Test/Analysis/TestNormalizer.c
+++ b/core/Lucy/Test/Analysis/TestNormalizer.c
@@ -81,9 +81,9 @@ test_normalization(TestBatchRunner *runner) {
         Hash *test = (Hash*)Vec_Fetch(tests, i);
         String *form = (String*)Hash_Fetch_Utf8(
                             test, "normalization_form", 18);
-        bool case_fold = Bool_Get_Value((BoolNum*)Hash_Fetch_Utf8(
+        bool case_fold = Bool_Get_Value((Boolean*)Hash_Fetch_Utf8(
                                               test, "case_fold", 9));
-        bool strip_accents = Bool_Get_Value((BoolNum*)Hash_Fetch_Utf8(
+        bool strip_accents = Bool_Get_Value((Boolean*)Hash_Fetch_Utf8(
                                                   test, "strip_accents", 13));
         Normalizer *normalizer = Normalizer_new(form, case_fold, strip_accents);
         Vector *words = (Vector*)Hash_Fetch_Utf8(test, "words", 5);

http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Test/Util/TestFreezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestFreezer.c b/core/Lucy/Test/Util/TestFreezer.c
index 01fb687..b77f20b 100644
--- a/core/Lucy/Test/Util/TestFreezer.c
+++ b/core/Lucy/Test/Util/TestFreezer.c
@@ -125,7 +125,7 @@ test_num(TestBatchRunner *runner) {
     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);
-    BoolNum   *true_thaw = (BoolNum*)S_freeze_thaw((Obj*)CFISH_TRUE);
+    Boolean   *true_thaw = (Boolean*)S_freeze_thaw((Obj*)CFISH_TRUE);
 
     TEST_TRUE(runner, Float32_Equals(f32, (Obj*)f32_thaw),
               "Float32 freeze/thaw");
@@ -136,7 +136,7 @@ test_num(TestBatchRunner *runner) {
     TEST_TRUE(runner, Int64_Equals(i64, (Obj*)i64_thaw),
               "Integer64 freeze/thaw");
     TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)true_thaw),
-              "BoolNum freeze/thaw");
+              "Boolean freeze/thaw");
 
     DECREF(i64_thaw);
     DECREF(i32_thaw);

http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index ed6e38c..4512017 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -66,11 +66,7 @@ Freezer_serialize(Obj *obj, OutStream *outstream) {
     }
     else if (Obj_is_a(obj, NUM)) {
         if (Obj_is_a(obj, INTNUM)) {
-            if (Obj_is_a(obj, BOOLNUM)) {
-                bool val = Bool_Get_Value((BoolNum*)obj);
-                OutStream_Write_U8(outstream, (uint8_t)val);
-            }
-            else if (Obj_is_a(obj, INTEGER32)) {
+            if (Obj_is_a(obj, INTEGER32)) {
                 int32_t val = Int32_Get_Value((Integer32*)obj);
                 OutStream_Write_C32(outstream, (uint32_t)val);
             }
@@ -90,6 +86,10 @@ Freezer_serialize(Obj *obj, OutStream *outstream) {
             }
         }
     }
+    else if (Obj_is_a(obj, BOOLEAN)) {
+        bool val = Bool_Get_Value((Boolean*)obj);
+        OutStream_Write_U8(outstream, (uint8_t)val);
+    }
     else if (Obj_is_a(obj, QUERY)) {
         Query_Serialize((Query*)obj, outstream);
     }
@@ -139,15 +139,7 @@ Freezer_deserialize(Obj *obj, InStream *instream) {
     }
     else if (Obj_is_a(obj, NUM)) {
         if (Obj_is_a(obj, INTNUM)) {
-            if (Obj_is_a(obj, BOOLNUM)) {
-                bool value = !!InStream_Read_U8(instream);
-                Obj *result = value ? INCREF(CFISH_TRUE) : INCREF(CFISH_FALSE);
-                // FIXME: This DECREF is essentially a no-op causing a
-                // memory leak.
-                DECREF(obj);
-                obj = result;
-            }
-            else if (Obj_is_a(obj, INTEGER32)) {
+            if (Obj_is_a(obj, INTEGER32)) {
                 int32_t value = (int32_t)InStream_Read_C32(instream);
                 obj = (Obj*)Int32_init((Integer32*)obj, value);
             }
@@ -167,6 +159,14 @@ Freezer_deserialize(Obj *obj, InStream *instream) {
             }
         }
     }
+    else if (Obj_is_a(obj, BOOLEAN)) {
+        bool value = !!InStream_Read_U8(instream);
+        Obj *result = value ? INCREF(CFISH_TRUE) : INCREF(CFISH_FALSE);
+        // FIXME: This DECREF is essentially a no-op causing a
+        // memory leak.
+        DECREF(obj);
+        obj = result;
+    }
     else if (Obj_is_a(obj, QUERY)) {
         obj = (Obj*)Query_Deserialize((Query*)obj, instream);
     }
@@ -386,7 +386,7 @@ Freezer_dump(Obj *obj) {
     else if (Obj_is_a(obj, QUERY)) {
         return Query_Dump((Query*)obj);
     }
-    else if (Obj_is_a(obj, NUM)) {
+    else if (Obj_is_a(obj, NUM) || Obj_is_a(obj, BOOLEAN)) {
         return Obj_Clone(obj);
     }
     else {

http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 740595c..d440fe9 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -750,12 +750,15 @@ Json_obj_to_bool(Obj *obj) {
     if (!obj) {
         THROW(ERR, "Can't extract bool from NULL");
     }
-    else if (Obj_is_a(obj, STRING)) {
-        retval = (Str_To_I64((String*)obj) != 0);
+    else if (Obj_is_a(obj, BOOLEAN)) {
+        retval = Bool_Get_Value((Boolean*)obj);
     }
     else if (Obj_is_a(obj, NUM)) {
         retval = Num_To_Bool((Num*)obj);
     }
+    else if (Obj_is_a(obj, STRING)) {
+        retval = (Str_To_I64((String*)obj) != 0);
+    }
     else {
         THROW(ERR, "Can't extract bool from object of type %o",
               Obj_get_class_name(obj));

http://git-wip-us.apache.org/repos/asf/lucy/blob/957ae1e5/core/Lucy/Util/ToolSet.h
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/ToolSet.h b/core/Lucy/Util/ToolSet.h
index ee1b810..23d321b 100644
--- a/core/Lucy/Util/ToolSet.h
+++ b/core/Lucy/Util/ToolSet.h
@@ -37,6 +37,7 @@ extern "C" {
 #include <string.h>
 #include "Clownfish/Obj.h"
 #include "Lucy/Object/BitVector.h"
+#include "Clownfish/Boolean.h"
 #include "Clownfish/ByteBuf.h"
 #include "Clownfish/String.h"
 #include "Clownfish/Err.h"