diff options
-rw-r--r-- | xapian/xapian.scm | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/xapian/xapian.scm b/xapian/xapian.scm index bde52a1..39461fc 100644 --- a/xapian/xapian.scm +++ b/xapian/xapian.scm @@ -1,5 +1,5 @@ ;;; guile-xapian --- Guile bindings for Xapian -;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2020, 2022 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2021 Bob131 <bob@bob131.so> ;;; ;;; This file is part of guile-xapian. @@ -86,12 +86,7 @@ in-memory database would always remain empty and is of little use." (define* (make-document #:key data (terms '()) (values '())) (let ((doc (new-Document))) (when data - (cond - ((string? data) - (Document-set-data doc data)) - ((bytevector? data) - (Document-set-data-bytes doc data)) - (else (error "Invalid document data" data)))) + (document-set-data! doc data)) (for-each (match-lambda ((term . wdf-increment) (Document-add-term doc term wdf-increment))) @@ -106,8 +101,21 @@ in-memory database would always remain empty and is of little use." (define document-data Document-get-data) (define document-bytes Document-get-data-bytes) -(define document-set-data! Document-set-data) -(define document-set-bytes! Document-set-data-bytes) + +(define (document-set-data! document data) + "Set data of DOCUMENT to DATA. DATA may be a string or a bytevector." + (cond + ((string? data) + (Document-set-data document data)) + ((bytevector? data) + (Document-set-data-bytes document data)) + (else + (error "Invalid document data" data)))) + +(define (document-set-bytes! doc data) + (display "document-set-bytes! is deprecated. document-set-data! now supports setting bytevectors as data. Please use that instead." + (current-error-port)) + (Document-set-data-bytes doc data)) (define document-slot-ref Document-get-value) (define document-slot-ref-bytes Document-get-value-bytes) |