lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [2/6] git commit: refs/heads/move-dumpable - Remove VTable_Load_Obj.
Date Wed, 31 Jul 2013 01:11:14 GMT
Remove VTable_Load_Obj.

VTable_Load_Obj is an inefficiently implemented convenience method.  Zap
it.


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

Branch: refs/heads/move-dumpable
Commit: 2b10863c9536771b22305a231affcd0abf79b529
Parents: e3e1661
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Sun Jul 28 12:25:28 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 30 17:57:23 2013 -0700

----------------------------------------------------------------------
 clownfish/runtime/core/Clownfish/Hash.c     |  5 ++++-
 clownfish/runtime/core/Clownfish/VTable.c   | 12 ----------
 clownfish/runtime/core/Clownfish/VTable.cfh |  6 -----
 core/Lucy/Index/BackgroundMerger.c          |  6 ++---
 core/Lucy/Index/Indexer.c                   |  7 +++---
 core/Lucy/Index/PolyReader.c                |  6 ++---
 core/Lucy/Plan/Schema.c                     | 28 ++++++++++++++----------
 7 files changed, 30 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/clownfish/runtime/core/Clownfish/Hash.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Hash.c b/clownfish/runtime/core/Clownfish/Hash.c
index e18f512..a95485b 100644
--- a/clownfish/runtime/core/Clownfish/Hash.c
+++ b/clownfish/runtime/core/Clownfish/Hash.c
@@ -147,7 +147,10 @@ Hash_load(Hash *self, Obj *dump) {
                       VTable_Get_Name(vtable));
             }
             else if (load != (Obj_Load_t)Hash_load) { // stop inf loop
-                return VTable_Load_Obj(vtable, dump);
+                Obj *dummy = VTable_Make_Obj(vtable);
+                Obj *loaded = Obj_Load(dummy, dump);
+                DECREF(dummy);
+                return loaded;
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/clownfish/runtime/core/Clownfish/VTable.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.c b/clownfish/runtime/core/Clownfish/VTable.c
index 58391b2..0c9aedc 100644
--- a/clownfish/runtime/core/Clownfish/VTable.c
+++ b/clownfish/runtime/core/Clownfish/VTable.c
@@ -322,18 +322,6 @@ VTable_singleton(const CharBuf *class_name, VTable *parent) {
     return singleton;
 }
 
-Obj*
-VTable_load_obj(VTable *self, Obj *dump) {
-    Obj_Load_t load = METHOD_PTR(self, Cfish_Obj_Load);
-    if (load == Obj_load) {
-        THROW(ERR, "Abstract method Load() not defined for %o", self->name);
-    }
-    Obj *invoker = VTable_Make_Obj(self);
-    Obj *loaded = load(invoker, dump);
-    DECREF(invoker);
-    return loaded;
-}
-
 static void
 S_scrunch_charbuf(CharBuf *source, CharBuf *target) {
     ZombieCharBuf *iterator = ZCB_WRAP(source);

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/clownfish/runtime/core/Clownfish/VTable.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.cfh b/clownfish/runtime/core/Clownfish/VTable.cfh
index c065495..b1b0e97 100644
--- a/clownfish/runtime/core/Clownfish/VTable.cfh
+++ b/clownfish/runtime/core/Clownfish/VTable.cfh
@@ -108,12 +108,6 @@ class Clownfish::VTable inherits Clownfish::Obj {
     Obj*
     Init_Obj(VTable *self, void *allocation);
 
-    /** Create a new object using the supplied dump, assuming that Load() has
-     * been defined for the class.
-     */
-    Obj*
-    Load_Obj(VTable *self, Obj *dump);
-
     /** Create a new object to go with the supplied host object.
      */
     Obj*

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/core/Lucy/Index/BackgroundMerger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BackgroundMerger.c b/core/Lucy/Index/BackgroundMerger.c
index a32f215..5f219ce 100644
--- a/core/Lucy/Index/BackgroundMerger.c
+++ b/core/Lucy/Index/BackgroundMerger.c
@@ -33,6 +33,7 @@
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/FSFolder.h"
 #include "Lucy/Store/Lock.h"
+#include "Lucy/Util/Freezer.h"
 #include "Lucy/Util/IndexFileNames.h"
 #include "Lucy/Util/Json.h"
 
@@ -116,9 +117,8 @@ BGMerger_init(BackgroundMerger *self, Obj *index, IndexManager *manager)
{
     ivars->polyreader = PolyReader_open((Obj*)folder, NULL, ivars->manager);
 
     // Clone the PolyReader's schema.
-    Hash *dump = Schema_Dump(PolyReader_Get_Schema(ivars->polyreader));
-    ivars->schema = (Schema*)CERTIFY(VTable_Load_Obj(SCHEMA, (Obj*)dump),
-                                    SCHEMA);
+    Obj *dump = (Obj*)Schema_Dump(PolyReader_Get_Schema(ivars->polyreader));
+    ivars->schema = (Schema*)CERTIFY(Freezer_load(dump), SCHEMA);
     DECREF(dump);
 
     // Create new Segment.

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/core/Lucy/Index/Indexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Indexer.c b/core/Lucy/Index/Indexer.c
index 803b7db..ab61d02 100644
--- a/core/Lucy/Index/Indexer.c
+++ b/core/Lucy/Index/Indexer.c
@@ -38,6 +38,7 @@
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/FSFolder.h"
 #include "Lucy/Store/Lock.h"
+#include "Lucy/Util/Freezer.h"
 #include "Lucy/Util/IndexFileNames.h"
 #include "Lucy/Util/Json.h"
 
@@ -122,11 +123,9 @@ Indexer_init(Indexer *self, Schema *schema, Obj *index,
         }
         else {
             CharBuf *schema_file = S_find_schema_file(latest_snapshot);
-            Hash *dump = (Hash*)Json_slurp_json(folder, schema_file);
+            Obj *dump = Json_slurp_json(folder, schema_file);
             if (dump) { // read file successfully
-                ivars->schema = (Schema*)CERTIFY(
-                                   VTable_Load_Obj(SCHEMA, (Obj*)dump),
-                                   SCHEMA);
+                ivars->schema = (Schema*)CERTIFY(Freezer_load(dump), SCHEMA);
                 schema = ivars->schema;
                 DECREF(dump);
                 schema_file = NULL;

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/core/Lucy/Index/PolyReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PolyReader.c b/core/Lucy/Index/PolyReader.c
index 92f198b..d672fe9 100644
--- a/core/Lucy/Index/PolyReader.c
+++ b/core/Lucy/Index/PolyReader.c
@@ -30,6 +30,7 @@
 #include "Lucy/Store/FSFolder.h"
 #include "Lucy/Store/Lock.h"
 #include "Lucy/Util/Json.h"
+#include "Lucy/Util/Freezer.h"
 #include "Lucy/Util/IndexFileNames.h"
 #include "Clownfish/Util/StringHelper.h"
 
@@ -254,11 +255,10 @@ S_try_open_elements(void *context) {
         THROW(ERR, "Can't find a schema file.");
     }
     else {
-        Hash *dump = (Hash*)Json_slurp_json(folder, schema_file);
+        Obj *dump = Json_slurp_json(folder, schema_file);
         if (dump) { // read file successfully
             DECREF(ivars->schema);
-            ivars->schema = (Schema*)CERTIFY(
-                               VTable_Load_Obj(SCHEMA, (Obj*)dump), SCHEMA);
+            ivars->schema = (Schema*)CERTIFY(Freezer_load(dump), SCHEMA);
             DECREF(dump);
             DECREF(schema_file);
             schema_file = NULL;

http://git-wip-us.apache.org/repos/asf/lucy/blob/2b10863c/core/Lucy/Plan/Schema.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/Schema.c b/core/Lucy/Plan/Schema.c
index 4203543..9ddb230 100644
--- a/core/Lucy/Plan/Schema.c
+++ b/core/Lucy/Plan/Schema.c
@@ -29,6 +29,7 @@
 #include "Lucy/Plan/FullTextType.h"
 #include "Lucy/Plan/Architecture.h"
 #include "Lucy/Store/Folder.h"
+#include "Lucy/Util/Freezer.h"
 #include "Lucy/Util/Json.h"
 
 // Scan the array to see if an object testing as Equal is present.  If not,
@@ -292,6 +293,14 @@ Schema_dump(Schema *self) {
     return dump;
 }
 
+static FieldType*
+S_load_type(VTable *vtable, Obj *type_dump) {
+    FieldType *dummy = (FieldType*)VTable_Make_Obj(vtable);
+    FieldType *loaded = (FieldType*)FType_Load(dummy, type_dump);
+    DECREF(dummy);
+    return loaded;
+}
+
 Schema*
 Schema_load(Schema *self, Obj *dump) {
     Hash *source = (Hash*)CERTIFY(dump, HASH);
@@ -332,47 +341,44 @@ Schema_load(Schema *self, Obj *dump) {
                 }
                 Hash_Store_Str(type_dump, "analyzer", 8, INCREF(analyzer));
                 FullTextType *type
-                    = (FullTextType*)VTable_Load_Obj(FULLTEXTTYPE,
-                                                     (Obj*)type_dump);
+                    = (FullTextType*)S_load_type(FULLTEXTTYPE,
+                                                 (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "string", 6)) {
                 StringType *type
-                    = (StringType*)VTable_Load_Obj(STRINGTYPE,
-                                                   (Obj*)type_dump);
+                    = (StringType*)S_load_type(STRINGTYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "blob", 4)) {
                 BlobType *type
-                    = (BlobType*)VTable_Load_Obj(BLOBTYPE, (Obj*)type_dump);
+                    = (BlobType*)S_load_type(BLOBTYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "i32_t", 5)) {
                 Int32Type *type
-                    = (Int32Type*)VTable_Load_Obj(INT32TYPE, (Obj*)type_dump);
+                    = (Int32Type*)S_load_type(INT32TYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "i64_t", 5)) {
                 Int64Type *type
-                    = (Int64Type*)VTable_Load_Obj(INT64TYPE, (Obj*)type_dump);
+                    = (Int64Type*)S_load_type(INT64TYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "f32_t", 5)) {
                 Float32Type *type
-                    = (Float32Type*)VTable_Load_Obj(FLOAT32TYPE,
-                                                    (Obj*)type_dump);
+                    = (Float32Type*)S_load_type(FLOAT32TYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }
             else if (CB_Equals_Str(type_str, "f64_t", 5)) {
                 Float64Type *type
-                    = (Float64Type*)VTable_Load_Obj(FLOAT64TYPE,
-                                                    (Obj*)type_dump);
+                    = (Float64Type*)S_load_type(FLOAT64TYPE, (Obj*)type_dump);
                 Schema_Spec_Field(loaded, field, (FieldType*)type);
                 DECREF(type);
             }


Mime
View raw message