lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [44/54] [abbrv] git commit: refs/heads/sortex_ptr_only - Change return type for Peek() and Fetch().
Date Sat, 26 Apr 2014 23:12:14 GMT
Change return type for Peek() and Fetch().

Modify SortExternal and subclasses so that Peek() and Fetch return Obj*
rather than a void* which was actually Obj**.


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

Branch: refs/heads/sortex_ptr_only
Commit: 9ed7692cf8be7707ec892911b5a8949b4063d064
Parents: d477115
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Fri Jan 4 16:16:14 2013 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sat Apr 26 11:52:22 2014 -0700

----------------------------------------------------------------------
 core/Lucy/Index/PostingPool.c            | 10 ++-----
 core/Lucy/Index/SortFieldWriter.c        |  6 ++--
 core/Lucy/Util/SortExternal.c            | 13 +++++----
 core/Lucy/Util/SortExternal.cfh          |  4 +--
 perl/buildlib/Lucy/Build/Binding/Util.pm | 42 ---------------------------
 5 files changed, 14 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/9ed7692c/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 57067f2..6628fc3 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -374,9 +374,8 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
         = Arch_Skip_Interval(Schema_Get_Architecture(ivars->schema));
 
     // Prime heldover variables.
-    RawPosting *posting = (RawPosting*)CERTIFY(
-                              (*(RawPosting**)PostPool_Fetch(self)),
-                              RAWPOSTING);
+    RawPosting *posting
+        = (RawPosting*)CERTIFY(PostPool_Fetch(self), RAWPOSTING);
     RawPostingIVARS *post_ivars = RawPost_IVARS(posting);
     CharBuf *last_term_text
         = CB_new_from_trusted_utf8(post_ivars->blob, post_ivars->content_len);
@@ -465,10 +464,7 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
         // Retrieve the next posting from the sort pool.
         // DECREF(posting);  // No!!  DON'T destroy!!!
 
-        void *address = PostPool_Fetch(self);
-        posting = address
-                  ? *(RawPosting**)address
-                  : NULL;
+        posting = (RawPosting*)PostPool_Fetch(self);
         post_ivars = RawPost_IVARS(posting);
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/9ed7692c/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 34aa84d..2e55a39 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -558,8 +558,7 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out,
 
     // Grab the first item and record its ord.  Add a dummy ord for invalid
     // doc id 0.
-    SFWriterElem **elem_ptr = (SFWriterElem**)SortFieldWriter_Fetch(self);
-    SFWriterElem *elem = *elem_ptr;
+    SFWriterElem *elem = (SFWriterElem*)SortFieldWriter_Fetch(self);
     SFWriterElemIVARS *elem_ivars = SFWriterElem_IVARS(elem);
     ords[elem_ivars->doc_id] = ord;
     ords[0] = 0;
@@ -568,8 +567,7 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out,
     ivars->last_val = INCREF(elem_ivars->value);
     Obj *last_val_address = elem_ivars->value;
     S_write_val(elem_ivars->value, prim_id, ix_out, dat_out, dat_start);
-    while (NULL != (elem_ptr = (SFWriterElem**)SortFieldWriter_Fetch(self))) {
-        elem = *elem_ptr;
+    while (NULL != (elem = (SFWriterElem*)SortFieldWriter_Fetch(self))) {
         elem_ivars = SFWriterElem_IVARS(elem);
         if (elem_ivars->value != last_val_address) {
             int32_t comparison

http://git-wip-us.apache.org/repos/asf/lucy/blob/9ed7692c/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index 98158b9..9f0c30e 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -94,29 +94,30 @@ SortEx_Feed_IMP(SortExternal *self, Obj *item) {
     ivars->cache_max++;
 }
 
-static CFISH_INLINE void*
+static CFISH_INLINE Obj*
 SI_peek(SortExternal *self, SortExternalIVARS *ivars) {
     if (ivars->cache_tick >= ivars->cache_max) {
         S_refill_cache(self, ivars);
     }
 
     if (ivars->cache_max > 0) {
-        return ivars->cache + ivars->cache_tick * sizeof(Obj*);
+        Obj **elems = (Obj**)ivars->cache;
+        return elems[ivars->cache_tick];
     }
     else {
         return NULL;
     }
 }
 
-void*
+Obj*
 SortEx_Fetch_IMP(SortExternal *self) {
     SortExternalIVARS *const ivars = SortEx_IVARS(self);
-    void *address = SI_peek(self, ivars);
+    Obj *item = SI_peek(self, ivars);
     ivars->cache_tick++;
-    return address;
+    return item;
 }
 
-void*
+Obj*
 SortEx_Peek_IMP(SortExternal *self) {
     SortExternalIVARS *const ivars = SortEx_IVARS(self);
     return SI_peek(self, ivars);

http://git-wip-us.apache.org/repos/asf/lucy/blob/9ed7692c/core/Lucy/Util/SortExternal.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.cfh b/core/Lucy/Util/SortExternal.cfh
index a6a7313..a27f2c2 100644
--- a/core/Lucy/Util/SortExternal.cfh
+++ b/core/Lucy/Util/SortExternal.cfh
@@ -92,13 +92,13 @@ abstract class Lucy::Util::SortExternal nickname SortEx
     /** Fetch the next sorted item from the sort pool.  Invalid prior to
      * calling Flip(). Returns NULL when all elements have been exhausted.
      */
-    nullable void*
+    incremented nullable Obj*
     Fetch(SortExternal *self);
 
     /** Preview the next item that Fetch will return, but don't pop it.
      * Invalid prior to calling Flip().
      */
-    nullable void*
+    nullable Obj*
     Peek(SortExternal *self);
 
     /** Add a run to the sortex's collection.

http://git-wip-us.apache.org/repos/asf/lucy/blob/9ed7692c/perl/buildlib/Lucy/Build/Binding/Util.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build/Binding/Util.pm b/perl/buildlib/Lucy/Build/Binding/Util.pm
index a0de3ed..5bd6ed9 100644
--- a/perl/buildlib/Lucy/Build/Binding/Util.pm
+++ b/perl/buildlib/Lucy/Build/Binding/Util.pm
@@ -29,52 +29,10 @@ sub bind_all {
 }
 
 sub bind_bbsortex {
-    my @hand_rolled = qw(
-        Fetch
-        Peek
-    );
-    my $xs_code = <<'END_XS_CODE';
-MODULE = Lucy    PACKAGE = Lucy::Util::BBSortEx
-
-SV*
-fetch(self)
-    lucy_BBSortEx *self;
-CODE:
-{
-    void *address = LUCY_BBSortEx_Fetch(self);
-    if (address) {
-        RETVAL = XSBind_cfish_to_perl(*(cfish_Obj**)address);
-        CFISH_DECREF(*(cfish_Obj**)address);
-    }
-    else {
-        RETVAL = newSV(0);
-    }
-}
-OUTPUT: RETVAL
-
-SV*
-peek(self)
-    lucy_BBSortEx *self;
-CODE:
-{
-    void *address = LUCY_BBSortEx_Peek(self);
-    if (address) {
-        RETVAL = XSBind_cfish_to_perl(*(cfish_Obj**)address);
-    }
-    else {
-        RETVAL = newSV(0);
-    }
-}
-OUTPUT: RETVAL
-
-END_XS_CODE
-
     my $binding = Clownfish::CFC::Binding::Perl::Class->new(
         parcel     => "Lucy",
         class_name => "Lucy::Util::BBSortEx",
     );
-    $binding->append_xs($xs_code);
-
     Clownfish::CFC::Binding::Perl::Class->register($binding);
 }
 


Mime
View raw message