Mailing List Archive

r3650 - in trunk/perl: lib lib/KinoSearch lib/KinoSearch/Highlight lib/KinoSearch/Index t
Author: creamyg
Date: 2008-07-27 18:29:11 -0700 (Sun, 27 Jul 2008)
New Revision: 3650

Modified:
trunk/perl/lib/KinoSearch.pm
trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm
trunk/perl/lib/KinoSearch/Index/IndexFileNames.pm
trunk/perl/lib/KinoSearch/Schema.pm
trunk/perl/t/107-index_file_names.t
trunk/perl/t/216-schema.t
Log:
Be more consistent about always returning arrayrefs and avoiding array
context for return values in the KinoSearch API.


Modified: trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/lib/KinoSearch/Highlight/HeatMap.pm 2008-07-28 01:29:11 UTC (rev 3650)
@@ -35,7 +35,7 @@
}

sub hot_to_cold {
- return reverse @{ $sorted_loc{ ${ +shift } } };
+ return [ reverse @{ $sorted_loc{ ${ +shift } } } ];
}

sub flatten_spans {
@@ -106,6 +106,8 @@

=head2 hot_to_cold

+ my $ordered = $heat_map->hot_to_cold;
+
Returns the locations of the highlight spans, from hottest to coldest.

=head1 COPYRIGHT

Modified: trunk/perl/lib/KinoSearch/Index/IndexFileNames.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Index/IndexFileNames.pm 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/lib/KinoSearch/Index/IndexFileNames.pm 2008-07-28 01:29:11 UTC (rev 3650)
@@ -31,8 +31,7 @@
# Leave non-KS files alone.
sub unused_files {
my ( $files, @snapshots ) = @_;
- my $unused = _unused_files( to_kino($files), to_kino( \@snapshots ) );
- return @{ $unused->to_perl };
+ return _unused_files( to_kino($files), to_kino( \@snapshots ) );
}

sub latest_gen {
@@ -73,7 +72,11 @@
kino_VArray *files;
kino_VArray *snapshots;
CODE:
- KOBJ_TO_SV_NOINC( kino_IxFileNames_unused_files(files, snapshots), RETVAL );
+{
+ kino_VArray *unused = kino_IxFileNames_unused_files(files, snapshots);
+ RETVAL = kobj_to_pobj(unused);
+ REFCOUNT_DEC(unused);
+}
OUTPUT:RETVAL

IV

Modified: trunk/perl/lib/KinoSearch/Schema.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Schema.pm 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/lib/KinoSearch/Schema.pm 2008-07-28 01:29:11 UTC (rev 3650)
@@ -74,7 +74,7 @@
# INSTANCE METHODS
#-----------------------------------------------------------------------

-sub all_fields { @{ shift->_all_fields->to_perl } }
+sub all_fields { shift->_all_fields->to_perl }

1;


Modified: trunk/perl/lib/KinoSearch.pm
===================================================================
--- trunk/perl/lib/KinoSearch.pm 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/lib/KinoSearch.pm 2008-07-28 01:29:11 UTC (rev 3650)
@@ -457,7 +457,7 @@

sub highlight_spans {
my $self = shift;
- return @{ $self->_highlight_spans(@_)->to_perl };
+ return $self->_highlight_spans(@_)->to_perl;
}
}


Modified: trunk/perl/t/107-index_file_names.t
===================================================================
--- trunk/perl/t/107-index_file_names.t 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/t/107-index_file_names.t 2008-07-28 01:29:11 UTC (rev 3650)
@@ -22,13 +22,13 @@

touch( $folder, "seg_2b4-25.p" );
my $files = $folder->list;
-my @unused = unused_files( $files, $snapshot );
-is_deeply( \@unused, ['seg_2b4-25.p'], "unused file" );
+my $unused = unused_files( $files, $snapshot );
+is_deeply( $unused, ['seg_2b4-25.p'], "unused file" );

touch( $folder, "foo" );
$files = $folder->list;
-@unused = unused_files( $files, $snapshot );
-is_deeply( \@unused, ['seg_2b4-25.p'], "non ks file ignored" );
+$unused = unused_files( $files, $snapshot );
+is_deeply( $unused, ['seg_2b4-25.p'], "non ks file ignored" );

$folder->delete_file("seg_2b4-25.p");
my @expected = ();
@@ -40,7 +40,7 @@
@expected = sort @expected;
touch( $folder, "seg_1-999.del" );
$files = $folder->list;
-@unused = unused_files( $files, $snapshot );
-@unused = sort @unused;
-is_deeply( \@unused, \@expected,
+$unused = unused_files( $files, $snapshot );
+@$unused = sort @$unused;
+is_deeply( $unused, \@expected,
"unused_files handles generational files correctly" );

Modified: trunk/perl/t/216-schema.t
===================================================================
--- trunk/perl/t/216-schema.t 2008-07-28 00:55:12 UTC (rev 3649)
+++ trunk/perl/t/216-schema.t 2008-07-28 01:29:11 UTC (rev 3650)
@@ -43,7 +43,7 @@

$schema = TestSchema->new;
$schema->add_field( field => 'new_field', spec => 'text' );
-my $got = grep { $_ eq 'new_field' } $schema->all_fields;
+my $got = grep { $_ eq 'new_field' } @{ $schema->all_fields };
ok( $got, 'add_field works' );
is( $schema->field_num('content'), 0, "field_num" );
is( $schema->field_num('new_field'), 1, "new field_num" );


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