From f3967897b0531bc73c72d936a77f24a6b94a2fac Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 6 Jun 2022 23:53:04 +0530 Subject: 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. --- xapian/xapian.scm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'xapian') 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 +;;; Copyright © 2020, 2022 Arun Isaac ;;; Copyright © 2021 Bob131 ;;; ;;; 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) -- cgit v1.2.3