Mercurial > core / lisp/ffi/rocksdb/merge.lisp
changeset 599: |
fea71448569b |
parent: |
c7f9bfc9570f
|
child: |
6fc04c4d465c |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 16 Aug 2024 18:06:48 -0400 |
permissions: |
-rw-r--r-- |
description: |
more rocksdb gruntwork |
1 ;;; rocksdb/merge.lisp --- RocksDB Merge Operators 3 ;; RocksDB Lisp Merge Operator API 7 ;; When to use built-in ROCKSDB-MERGE: 9 ;; - You have data that needs to be incrementally updated. 11 ;; - You would usually need to read the data before knowing what the new value would be. 13 ;; Oterwise as far as the FFI is concerned - which doesn't support 14 ;; AssociateMerge, you should use the Generic Merge API. 16 ;; When to use Associative Merge (unavailable in C/LISP API): 18 ;; - merge operands are formatted the same as Put values AND 20 ;; - it is okay to combine multiple operands into one 22 ;; When to use Generic Merge (this API): 24 ;; - you are unable to use Associate Merge 26 ;; - it is possible to combine multiple operands 30 ;; impl: https://github.com/facebook/rocksdb/wiki/Merge-Operator-Implementation 32 ;; wiki: https://github.com/facebook/rocksdb/wiki/merge-operator 38 Gives the client a way to express the read -> modify -> write semantics 39 key: (IN) The key that's associated with this merge operation. 40 existing: (IN) null indicates that the key does not exist before this op 41 operand_list:(IN) the sequence of merge operations to apply, front() first. 42 new_value: (OUT) Client is responsible for filling the merge result here 43 logger: (IN) Client could use this to log errors during merge. 45 Return true on success. Return false failure / error / corruption. 47 ;; FullMerge() is used when a Put/Delete is the *existing_value (or null) 48 (define-alien-type rocksdb-full-merge-function 52 (array (array unsigned-char)) 59 This function performs merge(left_op, right_op) 60 when both the operands are themselves merge operation types. 61 Save the result in *new_value and return true. If it is impossible 62 or infeasible to combine the two operations, return false instead. 64 ;; PartialMerge() is used to combine two-merge operands (if possible) 65 (define-alien-type rocksdb-partial-merge-function 69 (array (array unsigned-char)) 75 (define-alien-type rocksdb-delete-value-function 80 (define-alien-type rocksdb-destructor-function 81 (function void (* t))) 84 The name of the MergeOperator. Used to check for MergeOperator 85 mismatches (i.e., a DB created with one MergeOperator is 86 accessed using a different MergeOperator) 88 (define-alien-type rocksdb-name-function 91 (deftype rocksdb-merge-operands () '(array (octet-vector))) 93 ;; (sb-alien::define-alien-callable mangle int () 0) 95 (define-alien-routine rocksdb-mergeoperator-create (* rocksdb-mergeoperator) 97 (destructor (* rocksdb-destructor-function)) 98 (full-merge (* rocksdb-full-merge-function)) 99 (partial-merge (* rocksdb-partial-merge-function)) 100 (delete-value (* rocksdb-delete-value-function)) 101 (name (* rocksdb-name-function))) 103 #| [[file:~/dev/comp/core/c/rocksdb.h::/* Merge Operator */]] |# 105 (define-alien-routine rocksdb-mergeoperator-destroy void (self (* rocksdb-mergeoperator))) 108 (deftype rocksdb-mergeoperator-function () 109 '(function (octet-vector (or octet-vector null) &rest t) (or null octet-vector))) 111 (define-alien-callable rocksdb-delete-value (* t) 112 ((val (array unsigned-char)) 114 (declare (ignore val vlen)) 117 (define-alien-callable rocksdb-destructor void ((self (* t))) 121 (define-alien-callable rocksdb-name c-string () (make-alien-string (symbol-name (gensym "rocksdb:")))) 123 (define-alien-callable rocksdb-concat-merge-name c-string () (make-alien-string "concat-merge")) 125 (define-alien-callable rocksdb-concat-full-merge boolean 126 ((key (array unsigned-char)) 128 (existing-val (array unsigned-char)) 129 (existing-vlen size-t) 130 (ops (array (array unsigned-char))) 131 (ops-length (* size-t)) 133 (success (array unsigned-char)) 134 (new-vlen (* size-t))) 135 (log:debug! (list key klen existing-val existing-vlen ops ops-length num-ops success new-vlen)) 138 (define-alien-callable rocksdb-concat-partial-merge boolean 139 ((key (array unsigned-char)) 141 (ops (array (array unsigned-char))) 142 (ops-length (* size-t)) 144 (success (array unsigned-char)) 145 (new-vlen (* size-t))) 146 (log:debug! (list key klen ops ops-length num-ops success new-vlen)) 149 (define-alien-callable rocksdb-concat-delete-value void 152 (value-length size-t))