From 77a9d0c99030f438f1025a08072ad185947b6066 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 6 Jun 2022 23:54:16 +0530 Subject: xapian: Accept bytevector slot values with document-slot-set!. * xapian/xapian.scm (make-document): Call document-slot-set! regardless of slot value type. (document-slot-set!): Accept bytevector slot values. (document-slot-set-bytes!): Deprecate. --- xapian/xapian.scm | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'xapian') diff --git a/xapian/xapian.scm b/xapian/xapian.scm index 39461fc..75924ae 100644 --- a/xapian/xapian.scm +++ b/xapian/xapian.scm @@ -92,10 +92,8 @@ in-memory database would always remain empty and is of little use." (Document-add-term doc term wdf-increment))) terms) (for-each (match-lambda - ((slot . (? string? value)) - (Document-add-value doc slot value)) - ((slot . (? bytevector? value)) - (Document-add-value-bytes doc slot value))) + ((slot . value) + (document-slot-set! doc slot value))) values) doc)) @@ -119,8 +117,22 @@ in-memory database would always remain empty and is of little use." (define document-slot-ref Document-get-value) (define document-slot-ref-bytes Document-get-value-bytes) -(define document-slot-set! Document-add-value) -(define document-slot-set-bytes! Document-add-value-bytes) + +(define (document-slot-set! document slot value) + "Set SLOT of DOCUMENT to VALUE. VALUE may be a string or a +bytevector." + (cond + ((string? value) + (Document-add-value document slot value)) + ((bytevector? value) + (Document-add-value-bytes document slot value)) + (else + (error "Invalid document slot value" value)))) + +(define (document-slot-set-bytes! document slot value) + (display "document-slot-set-bytes! is deprecated. document-slot-set! now supports setting bytevectors as slot value. Please use that instead." + (current-error-port)) + (Document-add-value-bytes document slot value)) (define make-stem new-Stem) -- cgit v1.2.3