about summary refs log tree commit diff
path: root/xapian
diff options
context:
space:
mode:
authorArun Isaac2022-06-06 23:54:16 +0530
committerArun Isaac2022-06-07 00:00:01 +0530
commit77a9d0c99030f438f1025a08072ad185947b6066 (patch)
tree2e40ee480ffda5e256cda44f67a6833d7eba4081 /xapian
parentf3967897b0531bc73c72d936a77f24a6b94a2fac (diff)
downloadguile-xapian-77a9d0c99030f438f1025a08072ad185947b6066.tar.gz
guile-xapian-77a9d0c99030f438f1025a08072ad185947b6066.tar.lz
guile-xapian-77a9d0c99030f438f1025a08072ad185947b6066.zip
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.
Diffstat (limited to 'xapian')
-rw-r--r--xapian/xapian.scm24
1 files changed, 18 insertions, 6 deletions
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)