changeset 597: |
5b2ca5b2a9db |
parent 596: |
46e9425cf3c2 |
child 598: |
c7f9bfc9570f |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Thu, 15 Aug 2024 23:36:34 -0400 |
files: |
lisp.sk lisp/ffi/rocksdb/merge.lisp lisp/ffi/rocksdb/pkg.lisp lisp/ffi/rocksdb/rocksdb.asd lisp/ffi/rocksdb/tests.lisp |
description: |
rocksdb merge-op progress |
1.1--- a/lisp.sk Thu Aug 15 21:54:36 2024 -0400
1.2+++ b/lisp.sk Thu Aug 15 23:36:34 2024 -0400
1.3@@ -2,4 +2,8 @@
1.4 :name "core/lisp"
1.5 :src "lisp"
1.6 :description "CC Lisp Core"
1.7-:components ((:lisp-system "prelude.asd") (:lisp-system "user.asd") (:lisp-system "core.asd"))
1.8+:components
1.9+((:lisp-system "prelude.asd")
1.10+ (:lisp-system "user.asd")
1.11+ (:lisp-system "core.asd")
1.12+ (:lisp-system "std/std.asd"))
2.1--- a/lisp/ffi/rocksdb/merge.lisp Thu Aug 15 21:54:36 2024 -0400
2.2+++ b/lisp/ffi/rocksdb/merge.lisp Thu Aug 15 23:36:34 2024 -0400
2.3@@ -34,6 +34,16 @@
2.4 ;;; Code:
2.5 (in-package :rocksdb)
2.6
2.7+#|
2.8+Gives the client a way to express the read -> modify -> write semantics
2.9+key: (IN) The key that's associated with this merge operation.
2.10+existing: (IN) null indicates that the key does not exist before this op
2.11+operand_list:(IN) the sequence of merge operations to apply, front() first.
2.12+new_value: (OUT) Client is responsible for filling the merge result here
2.13+logger: (IN) Client could use this to log errors during merge.
2.14+
2.15+Return true on success. Return false failure / error / corruption.
2.16+|#
2.17 ;; FullMerge() is used when a Put/Delete is the *existing_value (or null)
2.18 (define-alien-type rocksdb-full-merge-function
2.19 (function (* t)
2.20@@ -44,6 +54,13 @@
2.21 int
2.22 (array unsigned-char)
2.23 (* size-t)))
2.24+
2.25+#|
2.26+This function performs merge(left_op, right_op)
2.27+when both the operands are themselves merge operation types.
2.28+Save the result in *new_value and return true. If it is impossible
2.29+or infeasible to combine the two operations, return false instead.
2.30+|#
2.31 ;; PartialMerge() is used to combine two-merge operands (if possible)
2.32 (define-alien-type rocksdb-partial-merge-function
2.33 (function (* t)
2.34@@ -63,6 +80,11 @@
2.35 (define-alien-type rocksdb-destructor-function
2.36 (function void (* t)))
2.37
2.38+#|
2.39+The name of the MergeOperator. Used to check for MergeOperator
2.40+mismatches (i.e., a DB created with one MergeOperator is
2.41+accessed using a different MergeOperator)
2.42+|#
2.43 (define-alien-type rocksdb-name-function
2.44 (function c-string))
2.45
2.46@@ -76,7 +98,7 @@
2.47 (full-merge (* rocksdb-full-merge-function))
2.48 (partial-merge (* rocksdb-partial-merge-function))
2.49 (delete-value (* rocksdb-delete-value-function))
2.50- (name c-string))
2.51+ (name (* rocksdb-name-function)))
2.52
2.53 #| [[file:~/dev/comp/core/c/rocksdb.h::/* Merge Operator */]] |#
2.54
2.55@@ -101,7 +123,7 @@
2.56
2.57 (define-alien-callable rocksdb-name c-string () (make-alien-string (symbol-name (gensym "rocksdb:"))))
2.58
2.59-(define-alien-callable rocksdb-concat-full-merge (* t)
2.60+(define-alien-callable rocksdb-concat-full-merge boolean
2.61 ((key (array unsigned-char))
2.62 (klen size-t)
2.63 (existing-val (array unsigned-char))
2.64@@ -112,9 +134,9 @@
2.65 (success (array unsigned-char))
2.66 (new-vlen (* size-t)))
2.67 (log:debug! (list key klen existing-val existing-vlen ops ops-length num-ops success new-vlen))
2.68- nil)
2.69+ 1)
2.70
2.71-(define-alien-callable rocksdb-concat-partial-merge (* t)
2.72+(define-alien-callable rocksdb-concat-partial-merge boolean
2.73 ((key (array unsigned-char))
2.74 (klen size-t)
2.75 (ops (array (array unsigned-char)))
2.76@@ -123,4 +145,4 @@
2.77 (success (array unsigned-char))
2.78 (new-vlen (* size-t)))
2.79 (log:debug! (list key klen ops ops-length num-ops success new-vlen))
2.80- nil)
2.81+ 0)
3.1--- a/lisp/ffi/rocksdb/pkg.lisp Thu Aug 15 21:54:36 2024 -0400
3.2+++ b/lisp/ffi/rocksdb/pkg.lisp Thu Aug 15 23:36:34 2024 -0400
3.3@@ -77,7 +77,10 @@
3.4 :*rocksdb-properties*
3.5 :rocksdb-num-files-at-level
3.6 :rocksdb-compression-ratio-at-level
3.7- :rocksdb-aggregated-table-properties-at-level))
3.8+ :rocksdb-aggregated-table-properties-at-level
3.9+ :rocksdb-concat-partial-merge
3.10+ :rocksdb-concat-full-merge
3.11+ :rocksdb-name))
3.12
3.13 (in-package :rocksdb)
3.14
4.1--- a/lisp/ffi/rocksdb/rocksdb.asd Thu Aug 15 21:54:36 2024 -0400
4.2+++ b/lisp/ffi/rocksdb/rocksdb.asd Thu Aug 15 23:36:34 2024 -0400
4.3@@ -8,7 +8,7 @@
4.4
4.5 ;;; Code:
4.6 (defsystem "rocksdb"
4.7- :depends-on (:std)
4.8+ :depends-on (:std :log)
4.9 :serial t
4.10 :components ((:file "pkg")
4.11 (:file "macs")
5.1--- a/lisp/ffi/rocksdb/tests.lisp Thu Aug 15 21:54:36 2024 -0400
5.2+++ b/lisp/ffi/rocksdb/tests.lisp Thu Aug 15 23:36:34 2024 -0400
5.3@@ -373,4 +373,26 @@
5.4
5.5 (deftest merge ()
5.6 "Test low-level merge-operator functionality using ALIEN-CALLBACKs."
5.7- nil)
5.8+ (is (with-alien ((k (array unsigned-char))
5.9+ (v (array unsigned-char))
5.10+ (ops (array (array unsigned-char)))
5.11+ (s (array unsigned-char)))
5.12+ (alien-funcall
5.13+ (alien-callable-function
5.14+ 'rocksdb-concat-full-merge)
5.15+ k 0 v 0 ops (make-alien size-t 0) 0 s (make-alien size-t 0))))
5.16+ (is
5.17+ (not
5.18+ (with-alien ((k (array unsigned-char))
5.19+ (ops (array (array unsigned-char)))
5.20+ (s (array unsigned-char)))
5.21+ (alien-funcall
5.22+ (alien-callable-function
5.23+ 'rocksdb-concat-partial-merge)
5.24+ k 0 ops (make-alien size-t 0) 0 s (make-alien size-t 0)))))
5.25+ (alien-callable-function 'rocksdb-concat-full-merge)
5.26+ (alien-callable-function 'rocksdb-concat-partial-merge)
5.27+ (is (integerp
5.28+ (parse-integer
5.29+ (string-trim "rocksdb:" (alien-funcall (alien-callable-function 'rocksdb-name)))))))
5.30+