lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [04/15] git commit: refs/heads/cfish-string-prep1 - Convert Search::Query subclasses to CharBuf
Date Mon, 02 Sep 2013 19:16:35 GMT
Convert Search::Query subclasses to CharBuf


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

Branch: refs/heads/cfish-string-prep1
Commit: b34f1000eb6b09e281bf033de336e92dd127daf6
Parents: 04e9f41
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Sep 2 19:32:28 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Sep 2 21:12:29 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Search/ANDQuery.c        | 12 ++++++++----
 core/Lucy/Search/ORQuery.c         | 12 ++++++++----
 core/Lucy/Search/PhraseQuery.c     | 16 ++++++++++------
 core/LucyX/Search/ProximityQuery.c | 16 ++++++++++------
 4 files changed, 36 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/b34f1000/core/Lucy/Search/ANDQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/ANDQuery.c b/core/Lucy/Search/ANDQuery.c
index b23f4f5..0ef378e 100644
--- a/core/Lucy/Search/ANDQuery.c
+++ b/core/Lucy/Search/ANDQuery.c
@@ -19,6 +19,8 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Search/ANDQuery.h"
+
+#include "Clownfish/CharBuf.h"
 #include "Lucy/Index/DocVector.h"
 #include "Lucy/Index/SegReader.h"
 #include "Lucy/Index/Similarity.h"
@@ -47,18 +49,20 @@ ANDQuery_To_String_IMP(ANDQuery *self) {
     uint32_t num_kids = VA_Get_Size(ivars->children);
     if (!num_kids) { return Str_new_from_trusted_utf8("()", 2); }
     else {
-        String *retval = Str_new_from_trusted_utf8("(", 1);
+        CharBuf *buf = CB_new_from_trusted_utf8("(", 1);
         for (uint32_t i = 0; i < num_kids; i++) {
             String *kid_string = Obj_To_String(VA_Fetch(ivars->children, i));
-            Str_Cat(retval, kid_string);
+            CB_Cat(buf, kid_string);
             DECREF(kid_string);
             if (i == num_kids - 1) {
-                Str_Cat_Trusted_Str(retval, ")", 1);
+                CB_Cat_Trusted_UTF8(buf, ")", 1);
             }
             else {
-                Str_Cat_Trusted_Str(retval, " AND ", 5);
+                CB_Cat_Trusted_UTF8(buf, " AND ", 5);
             }
         }
+        String *retval = CB_Yield_String(buf);
+        DECREF(buf);
         return retval;
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b34f1000/core/Lucy/Search/ORQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/ORQuery.c b/core/Lucy/Search/ORQuery.c
index 9d15704..3ee0cfd 100644
--- a/core/Lucy/Search/ORQuery.c
+++ b/core/Lucy/Search/ORQuery.c
@@ -19,6 +19,8 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Search/ORQuery.h"
+
+#include "Clownfish/CharBuf.h"
 #include "Lucy/Index/SegReader.h"
 #include "Lucy/Index/Similarity.h"
 #include "Lucy/Search/ORMatcher.h"
@@ -62,19 +64,21 @@ ORQuery_To_String_IMP(ORQuery *self) {
     uint32_t num_kids = VA_Get_Size(ivars->children);
     if (!num_kids) { return Str_new_from_trusted_utf8("()", 2); }
     else {
-        String *retval = Str_new_from_trusted_utf8("(", 1);
+        CharBuf *buf = CB_new_from_trusted_utf8("(", 1);
         uint32_t last_kid = num_kids - 1;
         for (uint32_t i = 0; i < num_kids; i++) {
             String *kid_string = Obj_To_String(VA_Fetch(ivars->children, i));
-            Str_Cat(retval, kid_string);
+            CB_Cat(buf, kid_string);
             DECREF(kid_string);
             if (i == last_kid) {
-                Str_Cat_Trusted_Str(retval, ")", 1);
+                CB_Cat_Trusted_UTF8(buf, ")", 1);
             }
             else {
-                Str_Cat_Trusted_Str(retval, " OR ", 4);
+                CB_Cat_Trusted_UTF8(buf, " OR ", 4);
             }
         }
+        String *retval = CB_Yield_String(buf);
+        DECREF(buf);
         return retval;
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b34f1000/core/Lucy/Search/PhraseQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/PhraseQuery.c b/core/Lucy/Search/PhraseQuery.c
index 5bc3edb..4f02f61 100644
--- a/core/Lucy/Search/PhraseQuery.c
+++ b/core/Lucy/Search/PhraseQuery.c
@@ -20,6 +20,8 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Search/PhraseQuery.h"
+
+#include "Clownfish/CharBuf.h"
 #include "Lucy/Index/DocVector.h"
 #include "Lucy/Index/Posting.h"
 #include "Lucy/Index/Posting/ScorePosting.h"
@@ -137,18 +139,20 @@ String*
 PhraseQuery_To_String_IMP(PhraseQuery *self) {
     PhraseQueryIVARS *const ivars = PhraseQuery_IVARS(self);
     uint32_t  num_terms = VA_Get_Size(ivars->terms);
-    String   *retval    = Str_Clone(ivars->field);
-    Str_Cat_Trusted_Str(retval, ":\"", 2);
+    CharBuf  *buf       = CB_new_from_str(ivars->field);
+    CB_Cat_Trusted_UTF8(buf, ":\"", 2);
     for (uint32_t i = 0; i < num_terms; i++) {
-        Obj     *term        = VA_Fetch(ivars->terms, i);
+        Obj    *term        = VA_Fetch(ivars->terms, i);
         String *term_string = Obj_To_String(term);
-        Str_Cat(retval, term_string);
+        CB_Cat(buf, term_string);
         DECREF(term_string);
         if (i < num_terms - 1) {
-            Str_Cat_Trusted_Str(retval, " ",  1);
+            CB_Cat_Trusted_UTF8(buf, " ",  1);
         }
     }
-    Str_Cat_Trusted_Str(retval, "\"", 1);
+    CB_Cat_Trusted_UTF8(buf, "\"", 1);
+    String *retval = CB_Yield_String(buf);
+    DECREF(buf);
     return retval;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b34f1000/core/LucyX/Search/ProximityQuery.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/ProximityQuery.c b/core/LucyX/Search/ProximityQuery.c
index 33e4865..903995a 100644
--- a/core/LucyX/Search/ProximityQuery.c
+++ b/core/LucyX/Search/ProximityQuery.c
@@ -20,6 +20,8 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "LucyX/Search/ProximityQuery.h"
+
+#include "Clownfish/CharBuf.h"
 #include "Lucy/Index/DocVector.h"
 #include "Lucy/Index/Posting.h"
 #include "Lucy/Index/Posting/ScorePosting.h"
@@ -148,19 +150,21 @@ String*
 ProximityQuery_To_String_IMP(ProximityQuery *self) {
     ProximityQueryIVARS *const ivars = ProximityQuery_IVARS(self);
     uint32_t num_terms = VA_Get_Size(ivars->terms);
-    String *retval = Str_Clone(ivars->field);
-    Str_Cat_Trusted_Str(retval, ":\"", 2);
+    CharBuf *buf = CB_new_from_str(ivars->field);
+    CB_Cat_Trusted_UTF8(buf, ":\"", 2);
     for (uint32_t i = 0; i < num_terms; i++) {
         Obj *term = VA_Fetch(ivars->terms, i);
         String *term_string = Obj_To_String(term);
-        Str_Cat(retval, term_string);
+        CB_Cat(buf, term_string);
         DECREF(term_string);
         if (i < num_terms - 1) {
-            Str_Cat_Trusted_Str(retval, " ",  1);
+            CB_Cat_Trusted_UTF8(buf, " ",  1);
         }
     }
-    Str_Cat_Trusted_Str(retval, "\"", 1);
-    Str_catf(retval, "~%u32", ivars->within);
+    CB_Cat_Trusted_UTF8(buf, "\"", 1);
+    CB_catf(buf, "~%u32", ivars->within);
+    String *retval = CB_Yield_String(buf);
+    DECREF(buf);
     return retval;
 }
 


Mime
View raw message