summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-06 23:53:04 +0530
committerArun Isaac2022-06-06 23:59:52 +0530
commitf3967897b0531bc73c72d936a77f24a6b94a2fac (patch)
treec68639a9dbd5b9ee5adfa950b22a23f76ddd3de4
parent58de551deffd89b76d27d802942c7f804d9f86c6 (diff)
downloadguile-xapian-f3967897b0531bc73c72d936a77f24a6b94a2fac.tar.gz
guile-xapian-f3967897b0531bc73c72d936a77f24a6b94a2fac.tar.lz
guile-xapian-f3967897b0531bc73c72d936a77f24a6b94a2fac.zip
xapian: Accept bytevector data with document-set-data!.
* xapian/xapian.scm (make-document): Call document-set-data! regardless of data type. (document-set-data!): Accept bytevector data. (document-set-bytes!): Deprecate.
-rw-r--r--xapian/xapian.scm26
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)