r33840 - in /branches/upstream/libsearch-xapian-perl/current: Changes MANIFEST MANIFEST.SKIP META.yml Makefile.PL README XS/Database.xs XS/Enquire.xs Xapian.pm t/thread.t t/writabledatabase.t
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri Apr 24 02:53:39 UTC 2009
Author: ryan52-guest
Date: Fri Apr 24 02:53:34 2009
New Revision: 33840
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33840
Log:
[svn-upgrade] Integrating new upstream version, libsearch-xapian-perl (1.0.12.0)
Added:
branches/upstream/libsearch-xapian-perl/current/t/writabledatabase.t
Modified:
branches/upstream/libsearch-xapian-perl/current/Changes
branches/upstream/libsearch-xapian-perl/current/MANIFEST
branches/upstream/libsearch-xapian-perl/current/MANIFEST.SKIP
branches/upstream/libsearch-xapian-perl/current/META.yml
branches/upstream/libsearch-xapian-perl/current/Makefile.PL
branches/upstream/libsearch-xapian-perl/current/README
branches/upstream/libsearch-xapian-perl/current/XS/Database.xs
branches/upstream/libsearch-xapian-perl/current/XS/Enquire.xs
branches/upstream/libsearch-xapian-perl/current/Xapian.pm
branches/upstream/libsearch-xapian-perl/current/t/thread.t
Modified: branches/upstream/libsearch-xapian-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Changes?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Changes (original)
+++ branches/upstream/libsearch-xapian-perl/current/Changes Fri Apr 24 02:53:34 2009
@@ -1,6 +1,17 @@
Revision history for Perl extension Search::Xapian.
-1.0.11.0 Sun Mar 15 12:53:20 GMT 2008
+1.0.12.0 Sun Apr 19 11:18:04 GMT 2009
+ [Changes contributed by Olly Betts]
+ - Add handling of exceptions from Database::get_metadata() and methods
+ of Enquire which might throw DatabaseModifiedError to address
+ situation reported in ticket#284.
+ - Skip thread.t testcase if Perl is new enough, but wasn't built with
+ thread support (reported by Felix Antonius Wilhelm Ostmann).
+ - Fix "fake VPATH" mode to work better.
+ [Changes contributed by Kosei Moriyama]
+ - Add test coverage for more WritableDatabase methods.
+
+1.0.11.0 Sun Mar 15 12:53:20 GMT 2009
[Changes contributed by Olly Betts]
- Wrap the new FLAG_DEFAULT constant which gives the QueryParser
default flag settings, allowing you to easily add flags to the
Modified: branches/upstream/libsearch-xapian-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/MANIFEST?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/MANIFEST (original)
+++ branches/upstream/libsearch-xapian-perl/current/MANIFEST Fri Apr 24 02:53:34 2009
@@ -82,6 +82,7 @@
t/thread.t
t/tied.t
t/valuerange.t
+t/writabledatabase.t
examples/simplesearch.pl
META.yml Module meta-data (added by MakeMaker)
Modified: branches/upstream/libsearch-xapian-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/MANIFEST.SKIP?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/MANIFEST.SKIP (original)
+++ branches/upstream/libsearch-xapian-perl/current/MANIFEST.SKIP Fri Apr 24 02:53:34 2009
@@ -7,6 +7,7 @@
testdb
testdb-exception
testdb-spell
+testdb-writabledatabase
blib
pm_to_blib
.*\.o
Modified: branches/upstream/libsearch-xapian-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/META.yml?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/META.yml (original)
+++ branches/upstream/libsearch-xapian-perl/current/META.yml Fri Apr 24 02:53:34 2009
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Search-Xapian
-version: 1.0.11.0
+version: 1.0.12.0
version_from: Xapian.pm
installdirs: site
requires:
Modified: branches/upstream/libsearch-xapian-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Makefile.PL?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Makefile.PL (original)
+++ branches/upstream/libsearch-xapian-perl/current/Makefile.PL Fri Apr 24 02:53:34 2009
@@ -9,7 +9,7 @@
my $builddir;
my $srcdir = $0;
-if ($srcdir =~ s!/.*!!) {
+if ($srcdir =~ s!/[^/]*$!!) {
chomp($builddir = `pwd`);
chdir $srcdir;
}
@@ -74,9 +74,9 @@
my $libs = `$xapian_config --libs 2> /dev/null`;
chomp($libs);
my ($xapian_config_dir) = $xapian_config =~ /^(.*?)[^\/]*$/;
-if ($? || -f "$xapian_config_dir/Makefile") {
+if ($? || -f "${xapian_config_dir}Makefile") {
# Assume we're being asked to build against an uninstalled xapian-core.
- my $libtool = "$xapian_config_dir/libtool";
+ my $libtool = "${xapian_config_dir}libtool";
unless (-x $libtool) {
die "You've asked me to link against what appears to be an uninstalled xapian-core tree, but I can't find libtool in that tree\n";
}
@@ -187,10 +187,10 @@
if (defined $builddir) {
open M, '>', "$builddir/Makefile~" or die $!;
print M <<"EOF";
-.DEFAULT:
+all .DEFAULT:
\t\$(MAKE) -C "$srcdir" \$\@
-.PHONY: Search-Xapian-$VERSION.tar.gz
+.PHONY: all Search-Xapian-$VERSION.tar.gz
dist tardist Search-Xapian-$VERSION.tar.gz:
\t\$(MAKE) -C "$srcdir" \$\@
Modified: branches/upstream/libsearch-xapian-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/README?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/README (original)
+++ branches/upstream/libsearch-xapian-perl/current/README Fri Apr 24 02:53:34 2009
@@ -1,4 +1,4 @@
-Search::Xapian version 1.0.11.0
+Search::Xapian version 1.0.12.0
===============================
This is Search::Xapian, a Perl XS frontend to the Xapian C++ search library.
Modified: branches/upstream/libsearch-xapian-perl/current/XS/Database.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/XS/Database.xs?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/XS/Database.xs (original)
+++ branches/upstream/libsearch-xapian-perl/current/XS/Database.xs Fri Apr 24 02:53:34 2009
@@ -279,6 +279,15 @@
string
Database::get_metadata(string key)
+ CODE:
+ try {
+ RETVAL = THIS->get_metadata(key);
+ }
+ catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
+ OUTPUT:
+ RETVAL
void
Database::DESTROY()
Modified: branches/upstream/libsearch-xapian-perl/current/XS/Enquire.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/XS/Enquire.xs?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/XS/Enquire.xs (original)
+++ branches/upstream/libsearch-xapian-perl/current/XS/Enquire.xs Fri Apr 24 02:53:34 2009
@@ -139,26 +139,30 @@
RSet * rset
SV * func
CODE:
- MSet mset;
- switch (items) { /* items includes the hidden this pointer */
- case 3:
- mset = THIS->get_mset(first, maxitems);
- break;
- case 4:
- mset = THIS->get_mset(first, maxitems, checkatleast);
- break;
- case 5:
- mset = THIS->get_mset(first, maxitems, checkatleast, rset);
- break;
- case 6: {
- perlMatchDecider d = perlMatchDecider(func);
- mset = THIS->get_mset(first, maxitems, checkatleast, rset, &d);
- break;
+ try {
+ MSet mset;
+ switch (items) { /* items includes the hidden this pointer */
+ case 3:
+ mset = THIS->get_mset(first, maxitems);
+ break;
+ case 4:
+ mset = THIS->get_mset(first, maxitems, checkatleast);
+ break;
+ case 5:
+ mset = THIS->get_mset(first, maxitems, checkatleast, rset);
+ break;
+ case 6: {
+ perlMatchDecider d = perlMatchDecider(func);
+ mset = THIS->get_mset(first, maxitems, checkatleast, rset, &d);
+ break;
+ }
+ default:
+ croak("Bad parameter count for get_mset1");
}
- default:
- croak("Bad parameter count for get_mset1");
- }
- RETVAL = new MSet(mset);
+ RETVAL = new MSet(mset);
+ } catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
OUTPUT:
RETVAL
@@ -168,8 +172,12 @@
doccount maxitems
SV * func
CODE:
- perlMatchDecider d = perlMatchDecider(func);
- RETVAL = new MSet(THIS->get_mset(first, maxitems, 0, NULL, &d));
+ try {
+ perlMatchDecider d = perlMatchDecider(func);
+ RETVAL = new MSet(THIS->get_mset(first, maxitems, 0, NULL, &d));
+ } catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
OUTPUT:
RETVAL
@@ -178,14 +186,22 @@
doccount maxitems
RSet * rset
CODE:
- RETVAL = new ESet(THIS->get_eset(maxitems, *rset));
+ try {
+ RETVAL = new ESet(THIS->get_eset(maxitems, *rset));
+ } catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
OUTPUT:
RETVAL
TermIterator *
Enquire::get_matching_terms_begin1(docid did)
CODE:
- RETVAL = new TermIterator(THIS->get_matching_terms_begin(did));
+ try {
+ RETVAL = new TermIterator(THIS->get_matching_terms_begin(did));
+ } catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
OUTPUT:
RETVAL
@@ -193,7 +209,11 @@
Enquire::get_matching_terms_begin2(it)
MSetIterator * it
CODE:
- RETVAL = new TermIterator(THIS->get_matching_terms_begin(* it));
+ try {
+ RETVAL = new TermIterator(THIS->get_matching_terms_begin(* it));
+ } catch (const Error &error) {
+ croak( "Exception: %s", error.get_msg().c_str() );
+ }
OUTPUT:
RETVAL
Modified: branches/upstream/libsearch-xapian-perl/current/Xapian.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Xapian.pm?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Xapian.pm (original)
+++ branches/upstream/libsearch-xapian-perl/current/Xapian.pm Fri Apr 24 02:53:34 2009
@@ -4,7 +4,7 @@
use strict;
use warnings;
-our $VERSION = '1.0.11.0';
+our $VERSION = '1.0.12.0';
use Exporter 'import';
@@ -36,10 +36,6 @@
require DynaLoader;
our @ISA = qw(DynaLoader);
-
-# Items to export into caller's namespace by default. Note: do not export
-# names by default without a very good reason. Use EXPORT_OK instead.
-# Do not simply export all your public functions/methods/constants.
# This allows declaration use Search::Xapian ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
@@ -98,8 +94,10 @@
$EXPORT_TAGS{all} = [ @{ $EXPORT_TAGS{'standard'} }, @{ $EXPORT_TAGS{'enq_order'} } ];
+# Names which can be exported.
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+# Don't export any names by default.
our @EXPORT = qw( );
bootstrap Search::Xapian $VERSION;
Modified: branches/upstream/libsearch-xapian-perl/current/t/thread.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/t/thread.t?rev=33840&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/t/thread.t (original)
+++ branches/upstream/libsearch-xapian-perl/current/t/thread.t Fri Apr 24 02:53:34 2009
@@ -6,14 +6,21 @@
use Test::More;
if ($] < 5.008007) {
- plan skip_all => 'Test requires Perl >= 5.8.7';
-} else {
- # Number of test cases to run - increase this if you add more testcases.
- plan tests => 65;
+ # Perl 5.8.7 added CLONE_SKIP which is required to implement the behaviour
+ # which this test case tests.
+ plan skip_all => 'Test requires Perl >= 5.8.7 for CLONE_SKIP';
+}
+eval {
+ require threads;
+};
+if ($@) {
+ plan skip_all => 'Test requires Perl with thread support';
}
+# Number of test cases to run - increase this if you add more testcases.
+plan tests => 65;
+
use Search::Xapian qw(:standard);
-use threads;
# TODO: check these classes too:
# MSet/Tied.pm
Added: branches/upstream/libsearch-xapian-perl/current/t/writabledatabase.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/t/writabledatabase.t?rev=33840&op=file
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/t/writabledatabase.t (added)
+++ branches/upstream/libsearch-xapian-perl/current/t/writabledatabase.t Fri Apr 24 02:53:34 2009
@@ -1,0 +1,189 @@
+#!/usr/bin/perl -W
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+#########################
+
+use Test::More;
+# Number of test cases to run - increase this if you add more testcases.
+plan tests => 34;
+
+use Search::Xapian qw(:standard);
+
+my $db_dir = 'testdb-writabledatabase';
+
+# Delete contents of database dir, if it exists.
+if (opendir( DB_DIR, $db_dir )) {
+ while( defined( my $file = readdir( DB_DIR ) ) ) {
+ next if $file =~ /^\.+$/;
+ unlink( "$db_dir/$file" ) or die "Could not delete '$db_dir/$file': $!";
+ }
+ closedir( DB_DIR );
+}
+
+my $write = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE );
+
+# Let's try to index something.
+my $term = 'test';
+
+for my $num (1..1000) {
+ my $doc = Search::Xapian::Document->new();
+
+ $doc->set_data( "$term $num" );
+
+ $doc->add_posting( $term, 0 );
+ $doc->add_posting( $num, 1 );
+
+ $doc->add_value(0, $num);
+ $write->add_document( $doc );
+}
+
+for my $num qw (three four five) {
+ my $doc = Search::Xapian::Document->new();
+
+ $doc->set_data( "$term $num" );
+
+ $doc->add_posting( $term, 0 );
+ $doc->add_posting( $num, 1 );
+
+ $doc->add_value(0, $num);
+ $write->add_document( $doc );
+}
+$write->flush();
+
+my $doccount = $write->get_doccount();
+is($doccount, 1003, "check number of documents in WritableDatabase");
+
+# replace document by docid
+my $repdoc = Search::Xapian::Document->new();
+my $num = "six";
+$term = "test";
+my $docid = 500;
+$repdoc->set_data( "$term $num" );
+$repdoc->add_posting( $term, 0 );
+$repdoc->add_posting( $num, 1 );
+$repdoc->add_value(0, $num);
+
+ok(!$write->term_exists($num), "check term exists");
+is($write->get_document($docid)->get_data(), "$term $docid", "check document data");
+
+$write->replace_document($docid, $repdoc);
+$write->flush();
+
+ok($write->term_exists($num), "check term exists");
+is($write->get_document($docid)->get_data(), "$term $num", "check document data");
+
+# replace document by term
+$repdoc = Search::Xapian::Document->new();
+$term = "test";
+$num = "seven";
+$repdoc->set_data( "$term $num" );
+$repdoc->add_posting( $term, 0 );
+$repdoc->add_posting( $num, 1 );
+$repdoc->add_value(0, $num);
+$repterm = "five";
+
+ok(!$write->term_exists($num), "check term exists");
+ok($write->term_exists($repterm), "check term exists");
+is($write->get_termfreq($num), 0, "check term frequency");
+is($write->get_termfreq($repterm), 1, "check term frequency");
+
+$write->replace_document_by_term($repterm, $repdoc);
+$write->flush();
+
+ok($write->term_exists($num), "check term exists");
+ok(!$write->term_exists($repterm), "check term exists");
+is($write->get_termfreq($num), 1, "check term frequency");
+is($write->get_termfreq($repterm), 0, "check term frequency");
+
+# replace document by term, if term is new
+$repdoc = Search::Xapian::Document->new();
+$term = "test";
+$num = "eight";
+$repdoc->set_data( "$term $num" );
+$repdoc->add_posting( $term, 0 );
+$repdoc->add_posting( $num, 1 );
+$repdoc->add_value(0, $num);
+
+is($write->get_termfreq($term), $doccount, "check term frequency");
+is($write->get_termfreq($num), 0, "check term frequency");
+
+$write->replace_document_by_term($num, $repdoc);
+$write->flush();
+
+$doccount = $write->get_doccount();
+is($doccount, 1004, "check doccount");
+is($write->get_termfreq($term), $doccount, "check term frequency");
+is($write->get_termfreq($num), 1, "check term frequency");
+
+# replace document by term.
+# all documents indexed with the term are replaced; the replacement uses the
+# lowest docid if multiple documents are indexed by the term.
+$repdoc = Search::Xapian::Document->new();
+$term = "test";
+$num = "nine";
+$repdoc->set_data( "$term $num" );
+$repdoc->add_posting( $term, 0 );
+$repdoc->add_posting( $num, 1 );
+$repdoc->add_value(0, $num);
+
+$write->replace_document_by_term($term, $repdoc);
+$write->flush();
+my $doc = $write->get_document(1);
+
+is($write->get_doccount(), 1, "check document count");
+is($doc->get_data(), "$term $num", "check document data");
+
+# add documents for following tests
+for my $num qw (one two three four five) {
+ my $doc = Search::Xapian::Document->new();
+
+ $doc->set_data( "$term $num" );
+
+ $doc->add_posting( $term, 0 );
+ $doc->add_posting( $num, 1 );
+
+ $doc->add_value(0, $num);
+ $write->add_document( $doc );
+}
+$write->flush();
+
+$doccount = $write->get_doccount();
+is($doccount, 6, "check number of documents in WritableDatabase");
+
+# delete document by docid
+my $lastdocid = $write->get_lastdocid();
+my $lastdocterm = $write->get_document($lastdocid)->get_value(0);
+ok($write->term_exists($lastdocterm), "check term exists");
+
+$write->delete_document($lastdocid);
+$write->flush();
+
+is($write->get_doccount(), $doccount - 1, "check number of documents in WritableDatabase");
+ok(!$write->term_exists($lastdocterm), "check term exists");
+
+# delete document by term
+my $delterm = 'three';
+ok($write->term_exists($delterm), 'check term exists before deleting a document');
+is($write->get_termfreq($delterm), 1, 'check term frequency before deleting a document');
+
+$write->delete_document_by_term($delterm);
+$write->flush();
+
+is($write->get_doccount(), $doccount - 2, 'check WritableDatabase after deleting a document');
+ok(!$write->term_exists($delterm), 'check term exists after deleting a document');
+is($write->get_termfreq($delterm), 0, 'check term frequency after deleting a document');
+
+# delete documents by term
+$delterm = 'test';
+ok($write->term_exists($delterm), 'check term exists of documents which has term "test"');
+is($write->get_termfreq($delterm), $doccount - 2, 'check term frequency of term "test"');
+
+$write->delete_document_by_term($delterm);
+$write->flush();
+
+is($write->get_doccount(), 0, 'check WritableDatabase after deleting all documents');
+ok(!$write->term_exists($delterm), 'check term exists after deleting all documents');
+is($write->get_termfreq($delterm), 0, 'check term frequency after deleting all documents');
+
+1;
More information about the Pkg-perl-cvs-commits
mailing list