Mailing List Archive

r3691 - in trunk: c_src/KinoSearch perl/lib perl/lib/KinoSearch
Author: creamyg
Date: 2008-08-02 13:25:44 -0700 (Sat, 02 Aug 2008)
New Revision: 3691

Modified:
trunk/c_src/KinoSearch/FieldSpec.bp
trunk/c_src/KinoSearch/FieldSpec.c
trunk/perl/lib/KinoSearch.pm
trunk/perl/lib/KinoSearch/FieldSpec.pm
Log:
Port FieldSpec docs to C. Kill some hand-rolled XS, but as a side effect,
several FieldSpec methods can no longer be called as class methods, only
instance methods.


Modified: trunk/c_src/KinoSearch/FieldSpec.bp
===================================================================
--- trunk/c_src/KinoSearch/FieldSpec.bp 2008-08-02 19:07:00 UTC (rev 3690)
+++ trunk/c_src/KinoSearch/FieldSpec.bp 2008-08-02 20:25:44 UTC (rev 3691)
@@ -1,6 +1,11 @@
parcel KinoSearch cnick Kino;

-class KinoSearch::FieldSpec cnick FSpec extends KinoSearch::Obj {
+/** Define a field's behavior.
+ *
+ * FieldSpec is an abstract class defining a set of traits and behaviors which
+ * may be associated with one or more field names.
+ */
+abstract class KinoSearch::FieldSpec cnick FSpec extends KinoSearch::Obj {

float boost;
bool_t indexed;
@@ -18,33 +23,76 @@
static incremented FieldSpec*
new(const CharBuf *class_name);

- abstract incremented Analyzer*
+ /** By default, Analyzer() returns NULL, which indicates that the Schema's
+ * default analyzer should be used for this field. If you want a given
+ * field to use a different analyzer, override this method and have it
+ * return a L<KinoSearch::Analysis::Analyzer>.
+ */
+ public incremented Analyzer*
Analyzer(FieldSpec *self);

- abstract incremented Similarity*
+ /** I<Expert API.> Returns NULL by default. Override if you want this
+ * field to use a custom subclass of L<KinoSearch::Search::Similarity>
+ * rather than the Schema's default.
+ */
+ public incremented Similarity*
Similarity(FieldSpec *self);

- abstract incremented Posting*
- Posting(FieldSpec *self, Similarity *sim);
+ /** Returns an object which isa L<Posting|KinoSearch::Posting>.
+ *
+ * EXPERIMENTAL, EXPERT API - the capacity to specify different posting
+ * types is not going away, but the interface is likely to change.
+ *
+ * @param similarity A L<KinoSearch::Search::Similarity>.
+ */
+ public abstract incremented Posting*
+ Posting(FieldSpec *self, Similarity *similarity);

+ /** Returns a multiplier which determines how much a field contributes to
+ * a document's score. Default 1.0.
+ */
public float
Boost(FieldSpec *self);

+ /** Indicate whether the field should be indexed (so that it can be
+ * searched).
+ */
public abstract bool_t
Indexed(FieldSpec *self);

+ /** Indicate whether to store the raw field value, so that it can be
+ * retrieved when a document turns up in a search.
+ */
public abstract bool_t
Stored(FieldSpec *self);

+ /** Indicate whether to analyze the field using the relevant
+ * L<Analyzer|KinoSearch::Analysis::Analyzer>.
+ *
+ * Fields such as "category" or "product_number" might be
+ * <code>indexed</code> but not <code>analyzed</code>.
+ */
public abstract bool_t
Analyzed(FieldSpec *self);

+ /** Indicate whether to store the field's "term vectors", which are
+ * required by L<KinoSearch::Highlight::Highlighter> for excerpt selection
+ * and search term highlighting.
+ *
+ * Term vectors require a fair amount of space, so you should turn this off if
+ * you don't need it.
+ */
public abstract bool_t
Vectorized(FieldSpec *self);

+ /** Indicate whether the field contains binary data (rather than text).
+ */
public abstract bool_t
Binary(FieldSpec *self);

+ /** Indicate whether to compress the stored field using the zlib
+ * compression algorithm.
+ */
public abstract bool_t
Compressed(FieldSpec *self);


Modified: trunk/c_src/KinoSearch/FieldSpec.c
===================================================================
--- trunk/c_src/KinoSearch/FieldSpec.c 2008-08-02 19:07:00 UTC (rev 3690)
+++ trunk/c_src/KinoSearch/FieldSpec.c 2008-08-02 20:25:44 UTC (rev 3691)
@@ -41,6 +41,20 @@
return 1.0f;
}

+Analyzer*
+FSpec_analyzer(FieldSpec *self)
+{
+ UNUSED_VAR(self);
+ return NULL;
+}
+
+Similarity*
+FSpec_similarity(FieldSpec *self)
+{
+ UNUSED_VAR(self);
+ return NULL;
+}
+
/* Copyright 2007-2008 Marvin Humphrey
*
* This program is free software; you can redistribute it and/or modify

Modified: trunk/perl/lib/KinoSearch/FieldSpec.pm
===================================================================
--- trunk/perl/lib/KinoSearch/FieldSpec.pm 2008-08-02 19:07:00 UTC (rev 3690)
+++ trunk/perl/lib/KinoSearch/FieldSpec.pm 2008-08-02 20:25:44 UTC (rev 3691)
@@ -6,92 +6,7 @@

__AUTO_XS__

-{ "KinoSearch::FieldSpec" => {
- bind_methods => [.
- qw(
- boost
- indexed
- stored
- analyzed
- vectorized
- binary
- compressed
- )
- ],
- make_constructors => ["new"],
- }
-}
-
-__XS__
-
-MODULE = KinoSearch PACKAGE = KinoSearch::FieldSpec
-
-SV*
-new(class_name)
- kino_ClassNameBuf class_name;
-CODE:
- KOBJ_TO_SV_NOINC( kino_FSpec_new((kino_CharBuf*)&class_name), RETVAL );
-OUTPUT: RETVAL
-
-SV*
-analyzer(either_sv)
- SV *either_sv;
-CODE:
-{
- kino_Analyzer *analyzer = NULL;
- if (SvROK(either_sv)) {
- kino_FieldSpec *self
- = (kino_FieldSpec*)SV_TO_KOBJ(either_sv, &KINO_FIELDSPEC);
- if (METHOD_OVERRIDDEN(self, FSpec, Analyzer, analyzer)) {
- analyzer = Kino_FSpec_Analyzer(self);
- }
- }
- KOBJ_TO_SV_NOINC(analyzer, RETVAL);
-}
-OUTPUT: RETVAL
-
-SV*
-similarity(either_sv)
- SV *either_sv;
-CODE:
-{
- kino_Similarity *sim = NULL;
- if (SvROK(either_sv)) {
- kino_FieldSpec *self
- = (kino_FieldSpec*)SV_TO_KOBJ(either_sv, &KINO_FIELDSPEC);
- if (METHOD_OVERRIDDEN(self, FSpec, Similarity, similarity)) {
- sim = Kino_FSpec_Similarity(self);
- }
- }
- KOBJ_TO_SV_NOINC(sim, RETVAL);
-}
-OUTPUT: RETVAL
-
-SV*
-posting(self_sv, ...)
- SV *self_sv;
-CODE:
-{
- kino_FieldSpec *self
- = (kino_FieldSpec*)MAYBE_SV_TO_KOBJ(self_sv, &KINO_FIELDSPEC);
- HV *const args_hash = build_args_hash( &(ST(0)), 1, items,
- "KinoSearch::FieldSpec::instance_vars");
- kino_Similarity *sim = (kino_Similarity*)extract_kobj(args_hash,
- SNL("similarity"), (kino_VirtualTable*)&KINO_SIMILARITY);
- if (self == NULL) CONFESS("Abstract method");
- ABSTRACT_METHOD_CHECK(self, FSpec, Posting, posting);
- KOBJ_TO_SV_NOINC( Kino_FSpec_Posting(self, sim), RETVAL );
-}
-OUTPUT: RETVAL
-
-__POD__
-
-=head1 NAME
-
-KinoSearch::FieldSpec - Define a field's behavior.
-
-=head1 SYNOPSIS
-
+my $synopis = <<'END_SYNOPSIS';
Define your custom subclass:

package MySchema::Price;
@@ -113,88 +28,48 @@
name => 'text',
price => 'MySchema::Price',
);
+END_SYNOPSIS

-=head1 DESCRIPTION
+{ "KinoSearch::FieldSpec" => {
+ bind_methods => [.
+ qw(
+ boost
+ analyzer
+ similarity
+ indexed
+ stored
+ analyzed
+ vectorized
+ binary
+ compressed
+ posting
+ )
+ ],
+ make_constructors => ["new"],
+ make_pod => {
+ synopsis => $synopis,
+ methods => [.
+ qw(
+ boost
+ analyzer
+ similarity
+ indexed
+ stored
+ analyzed
+ vectorized
+ binary
+ compressed
+ posting
+ )
+ ],
+ }
+ }
+}

-FieldSpec is an abstract class defining a set of traits and behaviors which
-may be associated with one or more field names.
+__COPYRIGHT__

-=head1 CLASS METHODS
-
-=head2 boost
-
-Returns a multiplier which determines how much a field contributes to a
-document's score. Default 1.0.
-
-=head2 analyzer
-
-By default, analyzer() has no return value, which indicates that the Schema's
-default analyzer should be used for this field. If you want a given field to
-use a different analyzer, override this method and have it return an object
-which isa L<KinoSearch::Analysis::Analyzer>.
-
-=head2 similarity
-
-I<Expert API.> Returns nothing by default. Override it if you want this
-field to use a custom subclass of L<KinoSearch::Search::Similarity>, rather
-than the Schema's default.
-
-=head1 ABSTRACT CLASS METHODS
-
-=head2 indexed
-
-Returns a boolean indicating whether the field should be indexed, so that it
-can be searched later.
-
-=head2 analyzed
-
-Returns a boolean indicating whether to analyze the field using the relevant
-L<Analyzer|KinoSearch::Analysis::Analyzer>.
-
-Fields such as "category" or "product_number" might be indexed but not analyzed.
-
-=head2 stored
-
-Returns a boolean indicating whether to store the raw field value, so that it
-can be retrieved when the document turns up in a search.
-
-=head2 compressed
-
-Returns a boolean indicating whether to compress the stored field, using the
-zlib compression algorithm.
-
-=head2 vectorized
-
-Returns a boolean indication whether to store the field's "term vectors",
-which are required by L<KinoSearch::Highlight::Highlighter> for excerpt
-selection and search term highlighting.
-
-Term vectors require a fair amount of space, so you should turn this off if
-you don't need it.
-
-=head2 posting
-
-EXPERIMENTAL - the capacity to specify different posting types is not going
-away, but the interface is likely to change.
-
-I<Expert API.>
-Abstract method. Returns an object which isa L<Posting|KinoSearch::Posting>.
-Takes one labeled parameter, which is required.
-
-=over
-
-=item *
-
-B<similarity> - An object which isa L<KinoSearch::Search::Similarity>.
-
-=back
-
-=head1 COPYRIGHT
-
Copyright 2005-2008 Marvin Humphrey

-=head1 LICENSE, DISCLAIMER, BUGS, etc.
+This program is free software; you can redistribute it and/or modify
+under the same terms as Perl itself.

-See L<KinoSearch> version 0.20.
-
-=cut

Modified: trunk/perl/lib/KinoSearch.pm
===================================================================
--- trunk/perl/lib/KinoSearch.pm 2008-08-02 19:07:00 UTC (rev 3690)
+++ trunk/perl/lib/KinoSearch.pm 2008-08-02 20:25:44 UTC (rev 3691)
@@ -329,19 +329,14 @@
package KinoSearch::FieldSpec::text;
BEGIN { our @ISA = 'KinoSearch::FieldSpec' }
use KinoSearch::Util::ToolSet qw( confess a_isa_b );
- use KinoSearch::Posting::ScorePosting;
- use KinoSearch::Search::Similarity;

- use constant TRUE => 1;
- use constant FALSE => 0;
+ sub indexed {1}
+ sub stored {1}
+ sub analyzed {1}
+ sub vectorized {1}
+ sub binary {0}
+ sub compressed {0}

- sub indexed {TRUE}
- sub stored {TRUE}
- sub analyzed {TRUE}
- sub vectorized {TRUE}
- sub binary {FALSE}
- sub compressed {FALSE}
-
sub posting {
shift;
my %args = @_ == 1 ? ( similarity => $_[0] ) : (@_);


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