--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, May 28, 2004 at 12:46:26AM +0100, Francis Irving
wrote:> I'm doing some incremental indexing (using Perl) and want to check for
> existing documents so I can replace them.  Looking at Omega's source
> code, it uses Xapian::Document::postlist_begin and postlist_end to do
> this.
Wrong class - postlist_begin is a method of Xapian::Database, not
Xapian::Document.  But from what you say below, that's just a mistake
in this message.
> In Perl I can't work out how to call this function.  From the Xapian.c
> file in the XS bindings, the function seems to be called values_begin
> rather than postlist_begin (I've tried both).
No, values_begin() returns a Xapian::ValueIterator, and it's a method of
Xapian::Document anyway.
But it looks like postlist_begin() isn't wrapped yet.  Since
PostingIterator is now wrapped (as of 0.8.0.2) that's easy - patch
attached.  I've not tested this beyond it compiling, but it's pretty
trivial (famous last words...)
There's also a bonus patch hunk to fix a warning from GCC 3.3 (mostly
for Alex's benefit).
Cheers,
    Olly
--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="Search-Xapian-0.8.0.2.patch"
diff -ru Search-Xapian-0.8.0.2-orig/XS/Database.xs
Search-Xapian-0.8.0.2/XS/Database.xs
--- Search-Xapian-0.8.0.2-orig/XS/Database.xs	2004-05-13 11:06:40.000000000
+0100
+++ Search-Xapian-0.8.0.2/XS/Database.xs	2004-05-28 01:13:41.000000000 +0100
@@ -114,6 +114,34 @@
     OUTPUT:
         RETVAL
 
+PostingIterator *
+Database::postlist_begin(term)
+    string	term
+    CODE:
+        RETVAL = new PostingIterator();
+	try {
+	    *RETVAL = THIS->postlist_begin(term);
+        }
+        catch (const Error &error) {
+            croak( "Exception: %s", error.get_msg().c_str() );
+        }
+    OUTPUT:
+        RETVAL
+
+PostingIterator *
+Database::postlist_end(term)
+    string	term
+    CODE:
+        RETVAL = new PostingIterator();
+	try {
+	    *RETVAL = THIS->postlist_end(term);
+        }
+        catch (const Error &error) {
+            croak( "Exception: %s", error.get_msg().c_str() );
+        }
+    OUTPUT:
+        RETVAL
+
 doccount
 Database::get_doccount()
     CODE:
diff -ru Search-Xapian-0.8.0.2-orig/Xapian.xs Search-Xapian-0.8.0.2/Xapian.xs
--- Search-Xapian-0.8.0.2-orig/Xapian.xs	2004-05-13 17:32:53.000000000 +0100
+++ Search-Xapian-0.8.0.2/Xapian.xs	2004-05-28 01:13:48.000000000 +0100
@@ -1,6 +1,6 @@
 #include <xapian.h>
-#include <string.h>
-#include <vector.h>
+#include <string>
+#include <vector>
 
 #ifdef __cplusplus
 extern "C" {
--rwEMma7ioTxnRzrJ--