1.1--- a/lisp/ffi/rocksdb/merge.lisp Thu Aug 15 21:54:36 2024 -0400
1.2+++ b/lisp/ffi/rocksdb/merge.lisp Thu Aug 15 23:36:34 2024 -0400
1.3@@ -34,6 +34,16 @@
1.4 ;;; Code:
1.5 (in-package :rocksdb)
1.6
1.7+#|
1.8+Gives the client a way to express the read -> modify -> write semantics
1.9+key: (IN) The key that's associated with this merge operation.
1.10+existing: (IN) null indicates that the key does not exist before this op
1.11+operand_list:(IN) the sequence of merge operations to apply, front() first.
1.12+new_value: (OUT) Client is responsible for filling the merge result here
1.13+logger: (IN) Client could use this to log errors during merge.
1.14+
1.15+Return true on success. Return false failure / error / corruption.
1.16+|#
1.17 ;; FullMerge() is used when a Put/Delete is the *existing_value (or null)
1.18 (define-alien-type rocksdb-full-merge-function
1.19 (function (* t)
1.20@@ -44,6 +54,13 @@
1.21 int
1.22 (array unsigned-char)
1.23 (* size-t)))
1.24+
1.25+#|
1.26+This function performs merge(left_op, right_op)
1.27+when both the operands are themselves merge operation types.
1.28+Save the result in *new_value and return true. If it is impossible
1.29+or infeasible to combine the two operations, return false instead.
1.30+|#
1.31 ;; PartialMerge() is used to combine two-merge operands (if possible)
1.32 (define-alien-type rocksdb-partial-merge-function
1.33 (function (* t)
1.34@@ -63,6 +80,11 @@
1.35 (define-alien-type rocksdb-destructor-function
1.36 (function void (* t)))
1.37
1.38+#|
1.39+The name of the MergeOperator. Used to check for MergeOperator
1.40+mismatches (i.e., a DB created with one MergeOperator is
1.41+accessed using a different MergeOperator)
1.42+|#
1.43 (define-alien-type rocksdb-name-function
1.44 (function c-string))
1.45
1.46@@ -76,7 +98,7 @@
1.47 (full-merge (* rocksdb-full-merge-function))
1.48 (partial-merge (* rocksdb-partial-merge-function))
1.49 (delete-value (* rocksdb-delete-value-function))
1.50- (name c-string))
1.51+ (name (* rocksdb-name-function)))
1.52
1.53 #| [[file:~/dev/comp/core/c/rocksdb.h::/* Merge Operator */]] |#
1.54
1.55@@ -101,7 +123,7 @@
1.56
1.57 (define-alien-callable rocksdb-name c-string () (make-alien-string (symbol-name (gensym "rocksdb:"))))
1.58
1.59-(define-alien-callable rocksdb-concat-full-merge (* t)
1.60+(define-alien-callable rocksdb-concat-full-merge boolean
1.61 ((key (array unsigned-char))
1.62 (klen size-t)
1.63 (existing-val (array unsigned-char))
1.64@@ -112,9 +134,9 @@
1.65 (success (array unsigned-char))
1.66 (new-vlen (* size-t)))
1.67 (log:debug! (list key klen existing-val existing-vlen ops ops-length num-ops success new-vlen))
1.68- nil)
1.69+ 1)
1.70
1.71-(define-alien-callable rocksdb-concat-partial-merge (* t)
1.72+(define-alien-callable rocksdb-concat-partial-merge boolean
1.73 ((key (array unsigned-char))
1.74 (klen size-t)
1.75 (ops (array (array unsigned-char)))
1.76@@ -123,4 +145,4 @@
1.77 (success (array unsigned-char))
1.78 (new-vlen (* size-t)))
1.79 (log:debug! (list key klen ops ops-length num-ops success new-vlen))
1.80- nil)
1.81+ 0)