lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r887022 - in /lucene/lucy/trunk: core/Lucy/Object/ByteBuf.bp core/Lucy/Object/ByteBuf.c perl/lib/Lucy.pm perl/lib/Lucy/Object/ByteBuf.pm perl/t/binding/022-bytebuf.t
Date Fri, 04 Dec 2009 01:00:03 GMT
Author: marvin
Date: Fri Dec  4 01:00:02 2009
New Revision: 887022

URL: http://svn.apache.org/viewvc?rev=887022&view=rev
Log:
Commit bytebuf_serialization.diff from LUCY-81.

Added:
    lucene/lucy/trunk/perl/t/binding/022-bytebuf.t   (with props)
Modified:
    lucene/lucy/trunk/core/Lucy/Object/ByteBuf.bp
    lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c
    lucene/lucy/trunk/perl/lib/Lucy.pm
    lucene/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm

Modified: lucene/lucy/trunk/core/Lucy/Object/ByteBuf.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Object/ByteBuf.bp?rev=887022&r1=887021&r2=887022&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Object/ByteBuf.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Object/ByteBuf.bp Fri Dec  4 01:00:02 2009
@@ -100,6 +100,12 @@
 
     public i32_t
     Hash_Code(ByteBuf *self);
+
+    public void
+    Serialize(ByteBuf *self, OutStream *outstream);
+
+    public incremented ByteBuf*
+    Deserialize(ByteBuf *self, InStream *instream);
 }
 
 /**

Modified: lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c?rev=887022&r1=887021&r2=887022&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c (original)
+++ lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c Fri Dec  4 01:00:02 2009
@@ -11,6 +11,8 @@
 #include "Lucy/Object/VTable.h"
 #include "Lucy/Object/ByteBuf.h"
 #include "Lucy/Object/Err.h"
+#include "Lucy/Store/InStream.h"
+#include "Lucy/Store/OutStream.h"
 #include "Lucy/Util/Memory.h"
 
 /* Reallocate if necessary. */
@@ -191,6 +193,27 @@
     return self->buf;
 }
 
+void
+BB_serialize(ByteBuf *self, OutStream *target)
+{
+    OutStream_Write_C32(target, self->size);
+    OutStream_Write_Bytes(target, self->buf, self->size);
+}
+
+ByteBuf*
+BB_deserialize(ByteBuf *self, InStream *instream)
+{
+    const size_t size = InStream_Read_C32(instream);
+    self = self ? self : (ByteBuf*)VTable_Make_Obj(BYTEBUF);
+    self->cap  = 0; 
+    self->size = 0;
+    self->buf  = NULL;
+    SI_maybe_grow(self, size);
+    self->size = size;
+    InStream_Read_Bytes(instream, self->buf, size);
+    return self;
+}
+
 int 
 BB_compare(const void *va, const void *vb) 
 {

Modified: lucene/lucy/trunk/perl/lib/Lucy.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/lib/Lucy.pm?rev=887022&r1=887021&r2=887022&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy.pm (original)
+++ lucene/lucy/trunk/perl/lib/Lucy.pm Fri Dec  4 01:00:02 2009
@@ -37,6 +37,15 @@
 }
 
 {
+    package KinoSearch::Object::ByteBuf;
+    {
+        # Override autogenerated deserialize binding.
+        no warnings 'redefine';
+        sub deserialize { shift->_deserialize(@_) }
+    }
+}
+
+{
     package Lucy::Object::CharBuf;
 
     {

Modified: lucene/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm?rev=887022&r1=887021&r2=887022&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm (original)
+++ lucene/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm Fri Dec  4 01:00:02 2009
@@ -23,6 +23,15 @@
     RETVAL = LUCY_OBJ_TO_SV_NOINC(self);
 }
 OUTPUT: RETVAL
+
+SV*
+_deserialize(either_sv, instream)
+    SV *either_sv;
+    lucy_InStream *instream;
+CODE:
+    CHY_UNUSED_VAR(either_sv);
+    RETVAL = LUCY_OBJ_TO_SV_NOINC(lucy_BB_deserialize(NULL, instream));
+OUTPUT: RETVAL
 END_XS_CODE
 
 Boilerplater::Binding::Perl::Class->register(

Added: lucene/lucy/trunk/perl/t/binding/022-bytebuf.t
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/t/binding/022-bytebuf.t?rev=887022&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/t/binding/022-bytebuf.t (added)
+++ lucene/lucy/trunk/perl/t/binding/022-bytebuf.t Fri Dec  4 01:00:02 2009
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+use Storable qw( freeze thaw );
+use Lucy;
+
+my $orig   = Lucy::Object::ByteBuf->new("foo");
+my $frozen = freeze($orig);
+my $thawed = thaw($frozen);
+is( $thawed->to_perl, $orig->to_perl, "freeze/thaw" );
+

Propchange: lucene/lucy/trunk/perl/t/binding/022-bytebuf.t
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message