Mailing List Archive

r3708 - in trunk: c_src/KinoSearch/Index perl/lib perl/lib/KinoSearch/Index perl/t
Author: creamyg
Date: 2008-08-03 15:49:34 -0700 (Sun, 03 Aug 2008)
New Revision: 3708

Modified:
trunk/c_src/KinoSearch/Index/TermVector.bp
trunk/c_src/KinoSearch/Index/TermVector.c
trunk/perl/lib/KinoSearch.pm
trunk/perl/lib/KinoSearch/Index/TermVector.pm
trunk/perl/t/215-term_vectors.t
Log:
Replace hand-rolled XS accessors for TermVector members with C accessors.
Kill a few extra braces in KinoSearch.pm.


Modified: trunk/c_src/KinoSearch/Index/TermVector.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVector.bp 2008-08-03 22:12:07 UTC (rev 3707)
+++ trunk/c_src/KinoSearch/Index/TermVector.bp 2008-08-03 22:49:34 UTC (rev 3708)
@@ -24,6 +24,15 @@
init(TermVector *self, const CharBuf *field, const CharBuf *text,
IntMap *positions, IntMap *start_offsets, IntMap *end_offsets);

+ IntMap*
+ Get_Positions(TermVector *self);
+
+ IntMap*
+ Get_Start_Offsets(TermVector *self);
+
+ IntMap*
+ Get_End_Offsets(TermVector *self);
+
public incremented TermVector*
Deserialize(TermVector *self, InStream *instream);


Modified: trunk/c_src/KinoSearch/Index/TermVector.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-03 22:12:07 UTC (rev 3707)
+++ trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-03 22:49:34 UTC (rev 3708)
@@ -35,6 +35,13 @@
return self;
}

+IntMap*
+TV_get_positions(TermVector *self) { return self->positions; }
+IntMap*
+TV_get_start_offsets(TermVector *self) { return self->start_offsets; }
+IntMap*
+TV_get_end_offsets(TermVector *self) { return self->end_offsets; }
+
void
TV_serialize(TermVector *self, OutStream *target)
{

Modified: trunk/perl/lib/KinoSearch/Index/TermVector.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Index/TermVector.pm 2008-08-03 22:12:07 UTC (rev 3707)
+++ trunk/perl/lib/KinoSearch/Index/TermVector.pm 2008-08-03 22:49:34 UTC (rev 3708)
@@ -4,37 +4,11 @@

__END__

-__XS__
-
-MODULE = KinoSearch PACKAGE = KinoSearch::Index::TermVector
-
-void
-_set_or_get2(self, ...)
- kino_TermVector *self;
-ALIAS:
- _get_positions = 6
- _get_start_offsets = 8
- _get_end_offsets = 10
-PPCODE:
-{
- START_SET_OR_GET_SWITCH
-
- case 6: retval = Kino_Obj_To_Native(self->positions);
- break;
-
- case 8: retval = Kino_Obj_To_Native(self->start_offsets);
- break;
-
- case 10: retval = Kino_Obj_To_Native(self->end_offsets);
- break;
-
- END_SET_OR_GET_SWITCH
-}
-
__AUTO_XS__

{ "KinoSearch::Index::TermVector" => {
make_constructors => ["new"],
+ bind_methods => [qw( get_positions get_start_offsets get_end_offsets )],
make_getters => [qw( text field )],
}
}

Modified: trunk/perl/lib/KinoSearch.pm
===================================================================
--- trunk/perl/lib/KinoSearch.pm 2008-08-03 22:12:07 UTC (rev 3707)
+++ trunk/perl/lib/KinoSearch.pm 2008-08-03 22:49:34 UTC (rev 3708)
@@ -531,14 +531,6 @@
}

{
- package KinoSearch::Index::TermVector;
-
- sub get_positions { shift->_get_positions->to_arrayref }
- sub get_start_offsets { shift->_get_start_offsets->to_arrayref }
- sub get_end_offsets { shift->_get_end_offsets->to_arrayref }
-}
-
-{
package KinoSearch::Schema;
use KinoSearch::Util::ToolSet qw( confess blessed );

@@ -748,16 +740,12 @@
return $self->new( $self->to_string );
}
}
-}

-{
package KinoSearch::Util::ViewCharBuf;
use KinoSearch::Util::ToolSet qw( confess );

sub new { confess "ViewCharBuf has no public constructor." }
-}

-{
package KinoSearch::Util::ZombieCharBuf;
use KinoSearch::Util::ToolSet qw( confess );


Modified: trunk/perl/t/215-term_vectors.t
===================================================================
--- trunk/perl/t/215-term_vectors.t 2008-08-03 22:12:07 UTC (rev 3707)
+++ trunk/perl/t/215-term_vectors.t 2008-08-03 22:49:34 UTC (rev 3708)
@@ -57,7 +57,7 @@
$term_vector = $doc_vec->term_vector( field => 'content', term => 'mañana' );

ok( defined $term_vector, "utf-8 term vector retrieved" );
-is( $term_vector->get_end_offsets->[0],
+is( $term_vector->get_end_offsets->get(0),
length $hasta,
"end offset in utf8 characters, not bytes"
);


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits