changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/ffi/rocksdb/pkg.lisp

changeset 82: a606978326c7
parent: 763fe90be2e6
child: dcab745f42ba
author: ellis <ellis@rwest.io>
date: Thu, 07 Dec 2023 22:40:32 -0500
permissions: -rw-r--r--
description: rocksdb ffi
1 ;;; rocksdb.lisp --- low-level bindings to the RocksDB C API
2 
3 ;; for the high-level interface, see rdb.lisp.
4 
5 ;;; Commentary:
6 
7 ;; if ur on archlinux and installed rocksdb via AUR you may receive an error from
8 ;; jemalloc: cannot allocate memory in static TLS block:
9 
10 ;; https://github.com/veer66/cl-rocksdb/issues/1
11 
12 ;; for best results, you should compile rocksdb from source - use j0ni's snippet as a
13 ;; starting point.
14 
15 ;; make shared_lib DISABLE_JEMALLOC=1 &&
16 ;; sudo cp librocksdb.so.* /usr/local/lib/ &&
17 ;; sudo cp -rf include/* /usr/local/include/
18 
19 ;; https://github.com/facebook/rocksdb/blob/main/Makefile
20 
21 ;; check /usr/local/include/rocksdb/c.h for the C API header, the source is under
22 ;; db/c.cc
23 
24 ;; here are some important notes to keepin mind (from the API header):
25 #|
26 C bindings for rocksdb. May be useful as a stable ABI that can be
27 used by programs that keep rocksdb in a shared library, or for
28 a JNI api.
29 
30 Does not support:
31 . getters for the option types
32 . custom comparators that implement key shortening
33 . capturing post-write-snapshot
34 . custom iter, db, env, cache implementations using just the C bindings
35 
36 Some conventions:
37 
38 (1) We expose just opaque struct pointers and functions to clients.
39 This allows us to change internal representations without having to
40 recompile clients.
41 
42 (2) For simplicity, there is no equivalent to the Slice type. Instead,
43 the caller has to pass the pointer and length as separate
44 arguments.
45 
46 (3) Errors are represented by a null-terminated c string. NULL
47 means no error. All operations that can raise an error are passed
48 a "char** errptr" as the last argument. One of the following must
49 be true on entry:
50 *errptr == NULL
51 *errptr points to a malloc()ed null-terminated error message
52 On success, a leveldb routine leaves *errptr unchanged.
53 On failure, leveldb frees the old value of *errptr and
54 set *errptr to a malloc()ed error message.
55 
56 (4) Bools have the type unsigned char (0 == false; rest == true)
57 
58 (5) All of the pointer arguments must be non-NULL.|#
59 
60 ;;; Code:
61 (defpackage :rocksdb/pkg
62  (:nicknames :rocksdb)
63  (:use :cl :std/base :std/alien :std/fu :std/sym)
64  (:import-from :std/fu :symb)
65  (:export
66  :load-rocksdb
67  ;; ERR
68  :rocksdb-errptr
69  ;; DB
70  :rocksdb
71  :rocksdb-open
72  :rocksdb-close
73  :rocksdb-destroy-db
74  :rocksdb-repair-db
75  :rocksdb-checkpoint-object-create
76  :rocksdb-checkpoint-create
77  :rocksdb-open-column-families
78  :rocksdb-list-column-families-destroy
79  :rocksdb-list-column-families
80  :rocksdb-create-column-family
81  :rocksdb-create-column-families
82  :rocksdb-create-column-families-destroy
83  :rocksdb-drop-column-family
84  :rocksdb-column-family-handle-destroy
85  :rocksdb-column-family-handle-get-id
86  :rocksdb-column-family-handle-get-name
87  :rocksdb-put
88  :rocksdb-put-cf
89  :rocksdb-get
90  :rocksdb-get-with-ts
91  :rocksdb-get-cf
92  :rocksdb-get-cf-with-ts
93  :rocksdb-merge
94  :rocksdb-merge-cf
95  :rocksdb-write
96  :rocksdb-delete
97  :rocksdb-delete-cf
98  :rocksdb-delete-range-cf
99  :rocksdb-multi-get
100  :rocksdb-multi-get-with-ts
101  :rocksdb-multi-get-cf
102  :rocksdb-multi-get-cf-with-ts
103  :rocksdb-batched-multi-get-cf
104  :rocksdb-cancel-all-background-work
105  ;; writebatch
106  :rocksdb-writebatch-create
107  :rocksdb-writebatch-create-from
108  :rocksdb-writebatch-destroy
109  :rocksdb-writebatch-clear
110  :rocksdb-writebatch-count
111  :rocksdb-writebatch-put
112  :rocksdb-writebatch-put-cf
113  :rocksdb-writebatch-put-cf-with-ts
114  :rocksdb-writebatch-putv
115  :rocksdb-writebatch-putv-cf
116  :rocksdb-writebatch-merge
117  :rocksdb-writebatch-mergev-cf
118  :rocksdb-writebatch-delete
119  :rocksdb-writebatch-delete-cf
120  :rocksdb-writebatch-delete-cf-with-ts
121  :rocksdb-writebatch-singledelete-cf
122  :rocksdb-writebatch-singledelete-cf-with-ts
123  :rocksdb-writebatch-deletev
124  :rocksdb-writebatch-deletev-cf
125  :rocksdb-writebatch-deletev-cf-with-ts
126  :rocksdb-writebatch-delete-range
127  :rocksdb-writebatch-delete-range-cf
128  :rocksdb-writebatch-delete-rangev
129  :rocksdb-writebatch-delete-rangev-cf
130  :rocksdb-writebatch-put-log-data
131  :rocksdb-writebatch-iterate
132  :rocksdb-writebatch-data
133  :rocksdb-writebatch-set-save-point
134  :rocksdb-writebatch-rollback-to-save-point
135  :rocksdb-writebatch-pop-save-point
136  ;; flush
137  :rocksdb-flush
138  :rocksdb-flushoptions-create
139  :rocksdb-flushoptions-destroy
140  :rocksdb-flushoptions-get-wait
141  :rocksdb-flushoptions-set-wait
142  :rocksdb-flush-cf
143  :rocksdb-flush-cfs
144  :rocksdb-flush-wal
145  ;; CACHE
146  :rocksdb-cache
147  :rocksdb-cache-create-lru
148  ;; BLOCK-BASED OPTIONS
149  :rocksdb-block-based-table-options
150  :rocksdb-block-based-options-create
151  :rocksdb-block-based-options-destroy
152  :rocksdb-block-based-options-set-block-cache
153  ;; OPTIONS
154  ;; opt-utils
155  :rocksdb-load-latest-options
156  :rocksdb-load-latest-options-destroy
157  :rocksdb-set-options
158  :rocksdb-set-options-cf
159  :rocksdb-options
160  :rocksdb-options-create
161  :rocksdb-options-destroy
162  :rocksdb-options-increase-parallelism
163  :rocksdb-options-optimize-for-point-lookup
164  :rocksdb-options-optimize-level-style-compaction
165  :rocksdb-options-optimize-universal-style-compaction
166  :rocksdb-options-set-allow-ingest-behind
167  :rocksdb-options-get-allow-ingest-behind
168  :rocksdb-options-set-compaction-filter
169  :rocksdb-options-set-compaction-filter-factory
170  :rocksdb-options-compaction-readahead-size
171  :rocksdb-options-get-compaction-readahead-size
172  :rocksdb-options-set-comparator
173  :rocksdb-options-set-merge-operator
174  :rocksdb-options-set-uint64add-merge-operator
175  :rocksdb-options-set-compression-per-level
176  :rocksdb-options-set-create-if-missing
177  :rocksdb-options-get-create-if-missing
178  :rocksdb-options-set-create-missing-column-families
179  :rocksdb-options-get-create-missing-column-families
180  :rocksdb-options-set-error-if-exists
181  :rocksdb-options-get-error-if-exists
182  :rocksdb-options-set-paranoid-checks
183  :rocksdb-options-get-paranoid-checks
184  :rocksdb-options-set-db-paths
185  :rocksdb-options-set-env
186  :rocksdb-options-set-info-log
187  :rocksdb-options-set-info-log-level
188  :rocksdb-options-get-info-log-level
189  :rocksdb-options-set-write-buffer-size
190  :rocksdb-options-get-write-buffer-size
191  :rocksdb-options-set-db-write-buffer-size
192  :rocksdb-options-get-db-write-buffer-size
193  :rocksdb-options-set-max-open-files
194  :rocksdb-options-get-max-open-files
195  :rocksdb-options-set-max-total-wal-size
196  :rocksdb-options-get-max-total-wal-size
197  :rocksdb-options-set-compression-options
198  :rocksdb-options-set-compression-options-zstd-max-train-bytes
199  :rocksdb-options-get-compression-options-zstd-max-train-bytes
200  :rocksdb-options-set-compression-options-use-zstd-dict-trainer
201  :rocksdb-options-get-compression-options-use-zstd-dict-trainer
202  :rocksdb-options-set-compression-options-parallel-threads
203  :rocksdb-options-get-compression-options-parallel-threads
204  :rocksdb-options-set-compression-options-max-dict-buffer-bytes
205  :rocksdb-options-get-compression-options-max-dict-buffer-bytes
206  :rocksdb-options-set-block-based-table-factory
207  ;; blob
208  :rocksdb-options-set-enable-blob-files
209  :rocksdb-options-get-enable-blob-files
210  :rocksdb-options-set-min-blob-size
211  :rocksdb-options-set-blob-file-size
212  :rocksdb-options-set-blob-compression-type
213  :rocksdb-options-get-blob-compression-type
214  :rocksdb-options-set-enable-blob-gc
215  :rocksdb-options-get-enable-blob-gc
216  :rocksdb-options-set-blob-gc-age-cutoff
217  :rocksdb-options-get-blob-gc-age-cutoff
218  :rocksdb-options-set-blob-gc-force-threshold
219  :rocksdb-options-get-blob-gc-force-threshold
220  :rocksdb-options-set-blob-compaction-readahead-size
221  :rocksdb-options-get-blob-compaction-readahead-size
222  :rocksdb-options-set-blob-file-starting-level
223  :rocksdb-options-set-blob-cache
224  :rocksdb-options-set-prepopulate-blob-cache
225  :rocksdb-options-get-prepopulate-blob-cache
226  ;; read
227  :rocksdb-readoptions
228  :rocksdb-readoptions-create
229  :rocksdb-readoptions-destroy
230  ;; write
231  :rocksdb-writeoptions
232  :rocksdb-writeoptions-create
233  :rocksdb-writeoptions-destroy
234  ;; compact
235  :rocksdb-compactoptions
236  :rocksdb-compact-range-cf
237  :rocksdb-suggest-compact-range
238  :rocksdb-suggest-compact-range-cf
239  :rocksdb-compact-range-opt
240  :rocksdb-compact-range-cf-opt
241  ;; ITERATOR
242  :rocksdb-iterator
243  :rocksdb-iter-seek-to-first
244  :rocksdb-iter-seek-to-last
245  :rocksdb-iter-seek
246  :rocksdb-iter-seek-for-prev
247  :rocksdb-iter-next
248  :rocksdb-iter-prev
249  :rocksdb-create-iterator
250  :rocksdb-iter-key
251  :rocksdb-iter-value
252  :rocksdb-iter-timestamp
253  :rocksdb-iter-destroy
254  :rocksdb-iter-valid
255  :rocksdb-iter-get-error
256  :rocksdb-get-updates-since
257  :rocksdb-create-iterator-cf
258  :rocksdb-create-iterators
259  :rocksdb-create-snapshot
260  :rocksdb-release-snapshot
261  :rocksdb-property-value
262  :rocksdb-property-int
263  :rocksdb-property-int-cf
264  :rocksdb-property-value-cf
265  :rocksdb-approximate-sizes
266  :rocksdb-approximate-sizes-cf
267  :rocksdb-wal-iter-next
268  :rocksdb-wal-iter-valid
269  :rocksdb-wal-iter-status
270  :rocksdb-wal-iter-get-batch
271  :rocksdb-wal-iter-destroy))
272 
273 (in-package :rocksdb)
274 
275 (defun load-rocksdb ()
276  (unless (member :rocksdb *features*)
277  (sb-alien:load-shared-object "librocksdb.so" :dont-save t)
278  (push :rocksdb *features*)))
279 
280 (load-rocksdb)
281 
282 ;;; Macros
283 (defmacro with-errptr (name result-type &rest args)
284  `(define-alien-routine ,name ,result-type ,@args (errptr rocksdb-errptr)))
285 
286 (defmacro define-opt (name &rest fields)
287  `(progn
288  (define-alien-type ,name (struct ,(symbolicate name '-t)))
289  (define-alien-routine ,(symbolicate name '-create) (* ,name))
290  (define-alien-routine ,(symbolicate name '-destroy) void
291  (opt (* ,name)))
292  ,@(dolist (f fields)
293  (if (listp f)
294  (eval
295  (nconc
296  (list
297  'define-alien-routine
298  (symbolicate name '-set- (car f))
299  'void
300  `(opt (* ,name)))
301  (cdr f)))
302  (eval
303  (list
304  'define-alien-routine
305  (symbolicate name '-set- f)
306  'void
307  `(opt (* ,name))
308  '(val boolean)))))))
309 
310 (defmacro define-opaque (ty) `(define-alien-type ,ty (struct ,(symbolicate ty '-t))))
311 
312 ;;; Exported Types
313 (define-alien-type rocksdb-errptr (* t))
314 
315 (define-opaque rocksdb)
316 (define-opaque rocksdb)
317 (define-opaque rocksdb-iterator)
318 (define-opaque rocksdb-backup-engine)
319 (define-opaque rocksdb-backup-engine-info)
320 (define-opaque rocksdb-backup-engine-options)
321 (define-opaque rocksdb-restore-options)
322 (define-opaque rocksdb-memory-allocator)
323 (define-opaque rocksdb-lru-cache-options)
324 (define-opaque rocksdb-hyper-clock-cache-options)
325 (define-opaque rocksdb-cache)
326 (define-opaque rocksdb-compactionfilter)
327 (define-opaque rocksdb-compactionfiltercontext)
328 (define-opaque rocksdb-compactionfilterfactory)
329 (define-opaque rocksdb-comparator)
330 (define-opaque rocksdb-dbpath)
331 (define-opaque rocksdb-env)
332 (define-opaque rocksdb-fifo-compaction-options)
333 (define-opaque rocksdb-filelock)
334 (define-opaque rocksdb-filterpolicy)
335 (define-opaque rocksdb-logger)
336 (define-opaque rocksdb-mergeoperator)
337 (define-opaque rocksdb-compactoptions)
338 (define-opaque rocksdb-cuckoo-table-options)
339 (define-opaque rocksdb-randomfile)
340 (define-opaque rocksdb-seqfile)
341 (define-opaque rocksdb-slicetransform)
342 (define-opaque rocksdb-snapshot)
343 (define-opaque rocksdb-writeablefile)
344 (define-opaque rocksdb-writebatch)
345 (define-opaque rocksdb-livefiles)
346 (define-opaque rocksdb-column-family-handle)
347 (define-opaque rocksdb-column-family-metadata)
348 (define-opaque rocksdb-level-metadata)
349 (define-opaque rocksdb-sst-file-metadata)
350 (define-opaque rocksdb-envoptions)
351 (define-opaque rocksdb-ingestexternalfileoptions)
352 (define-opaque rocksdb-sstfilewriter)
353 (define-opaque rocksdb-ratelimiter)
354 (define-opaque rocksdb-perfcontext)
355 (define-opaque rocksdb-pinnableslice)
356 (define-opaque rocksdb-transactiondb-options)
357 (define-opaque rocksdb-transactiondb)
358 (define-opaque rocksdb-transaction-options)
359 (define-opaque rocksdb-optimistictransactiondb)
360 (define-opaque rocksdb-optimistictransaction-options)
361 (define-opaque rocksdb-transaction)
362 (define-opaque rocksdb-checkpoint)
363 (define-opaque rocksdb-wal-iterator)
364 (define-opaque rocksdb-wal-readoptions)
365 (define-opaque rocksdb-memory-comsumers)
366 (define-opaque rocksdb-memory-usage)
367 (define-opaque rocksdb-universal-compaction-options)
368 (define-opaque rocksdb-statistics-histogram-data)
369 
370 ;;; Opts
371 (define-opt rocksdb-block-based-options
372  (block-cache
373  (* rocksdb-cache))
374  (cache-index-and-filter-blocks
375  (val c-string)))
376 
377 (define-opt rocksdb-options
378  create-if-missing
379  (block-based-table-factory
380  (table-options (* rocksdb-block-based-table-options)))
381  (allow-ingest-behind (val unsigned-char))
382  (merge-operator (comparator (* rocksdb-comparator))))
383 
384 (define-opt rocksdb-writeoptions)
385 (define-opt rocksdb-readoptions)
386 (define-opt rocksdb-flushoptions
387  (wait (val unsigned-char)))
388 
389 (define-alien-routine rocksdb-options-increase-parallelism void
390  (opt (* rocksdb-options)) (total-threads int))
391 
392 (define-alien-routine rocksdb-options-optimize-level-style-compaction void
393  (opt (* rocksdb-options))
394  (memtable-memory-budget unsigned-long))
395 
396 (define-alien-routine rocksdb-flushoptions-get-wait unsigned-char (* rocksdb-flushoptions))
397 
398 (with-errptr rocksdb-load-latest-options
399  void
400  (db-path c-string)
401  (env (* rocksdb-env))
402  (ignore-unknown-options boolean)
403  (cache (* rocksdb-cache))
404  (db-options (* (* rocksdb-options)))
405  (num-column-families (* size-t))
406  (column-family-names (* (* c-string)))
407  (column-family-options (* (* (* rocksdb-options)))))
408 
409 (define-alien-routine rocksdb-load-latest-options-destroy void
410  (db-options (* (* rocksdb-options)))
411  (list-column-family-names (* c-string))
412  (list-column-family-options (* (* rocksdb-options)))
413  (len size-t))
414 
415 (with-errptr
416  rocksdb-set-options
417  void
418  (db (* rocksdb))
419  (count int)
420  (keys (array c-string))
421  (values (array c-string)))
422 
423 (with-errptr rocksdb-set-options-cf
424  void
425  (db (* rocksdb))
426  (handle (* rocksdb-column-family-handle))
427  (count int)
428  (keys (array c-string))
429  (values (array c-string)))
430 
431 ;;; DB
432 (with-errptr rocksdb-open (* rocksdb)
433  (opt (* rocksdb-options))
434  (name c-string))
435 
436 (define-alien-routine rocksdb-close void
437  (db (* rocksdb)))
438 
439 (define-alien-routine rocksdb-cancel-all-background-work void
440  (db (* rocksdb))
441  (wait boolean))
442 
443 (with-errptr rocksdb-put
444  void
445  (db (* rocksdb))
446  (options (* rocksdb-writeoptions))
447  (key (* char))
448  (keylen size-t)
449  (val (* char))
450  (vallen size-t))
451 
452 (with-errptr rocksdb-get
453  (* char)
454  (db (* rocksdb))
455  (options (* rocksdb-readoptions))
456  (key (* char))
457  (keylen size-t)
458  (vallen (* size-t)))
459 
460 (with-errptr rocksdb-delete
461  void
462  (db (* rocksdb))
463  (options (* rocksdb-writeoptions))
464  (key (* char))
465  (keylen size-t))
466 
467 (with-errptr rocksdb-merge
468  void
469  (db (* rocksdb))
470  (opt (* rocksdb-writeoptions))
471  (key (* char))
472  (keylen size-t)
473  (val (* char))
474  (vallen size-t))
475 
476 (with-errptr rocksdb-merge-cf
477  void
478  (db (* rocksdb))
479  (opt (* rocksdb-writeoptions))
480  (cf (* rocksdb-column-family-handle))
481  (key (* char))
482  (keylen size-t)
483  (val (* char))
484  (vallen size-t))
485 
486 (with-errptr rocksdb-write
487  void
488  (db (* rocksdb))
489  (opt (* rocksdb-writeoptions))
490  (batch (* rocksdb-writebatch)))
491 
492 (with-errptr rocksdb-get-cf
493  (* char)
494  (db (* rocksdb))
495  (opt (* rocksdb-readoptions))
496  (key (* char))
497  (keylen size-t)
498  (vallen (* size-t)))
499 
500 (define-alien-routine rocksdb-multi-get void
501  (db (* rocksdb))
502  (opt (* rocksdb-readoptions))
503  (num-keys size-t)
504  (keys-list (array c-string))
505  (keys-list-sizes (array size-t))
506  (values-list (array c-string))
507  (values-list-sizes (array size-t))
508  (errs (array rocksdb-errptr)))
509 
510 (define-alien-routine rocksdb-multi-get-cf void
511  (db (* rocksdb))
512  (opt (* rocksdb-readoptions))
513  (cfs (array rocksdb-column-family-handle))
514  (num-keys size-t)
515  (keys-list (array c-string))
516  (keys-list-sizes (array size-t))
517  (values-list (array c-string))
518  (values-list-sizes (array size-t))
519  (errs (array rocksdb-errptr)))
520 
521 (define-alien-routine rocksdb-cache-create-lru (* rocksdb) (capacity unsigned-int))
522 
523 (with-errptr rocksdb-flush void
524  (db (* rocksdb))
525  (options (* rocksdb-flushoptions)))
526 
527 ;;; CF
528 (with-errptr rocksdb-create-column-family
529  (* rocksdb-column-family-handle)
530  (db (* rocksdb))
531  (column-family-options (* rocksdb-options))
532  (column-family-name c-string))
533 
534 (with-errptr rocksdb-create-column-families
535  (array rocksdb-column-family-handle)
536  (db (* rocksdb))
537  (column-family-options (* rocksdb-options))
538  (num-column-familes int)
539  (column-family-names (array c-string))
540  (lencfs (* size-t)))
541 
542 (define-alien-routine rocksdb-create-column-families-destroy void
543  (list (array rocksdb-column-family-handle)))
544 
545 (define-alien-routine rocksdb-column-family-handle-destroy void
546  (* rocksdb-column-family-handle))
547 
548 (define-alien-routine rocksdb-column-family-handle-get-id unsigned-int
549  (* rocksdb-column-family-handle))
550 
551 (define-alien-routine rocksdb-column-family-handle-get-name c-string
552  (handle (* rocksdb-column-family-handle))
553  (name-len (* size-t)))
554 
555 (with-errptr rocksdb-drop-column-family
556  void
557  (db (* rocksdb))
558  (handle (* rocksdb-column-family-handle)))
559 
560 (with-errptr rocksdb-open-column-families
561  (* rocksdb)
562  (options (* rocksdb-options))
563  (name c-string)
564  (num-column-families int)
565  (column-family-names (array c-string))
566  (column-family-options (array rocksdb-options))
567  (column-family-handles (array rocksdb-column-family-handle)))
568 
569 (with-errptr rocksdb-list-column-families
570  (array c-string)
571  (opt (* rocksdb-options))
572  (name c-string)
573  (lencf (* size-t)))
574 
575 (define-alien-routine rocksdb-list-column-families-destroy void
576  (list (array c-string))
577  (len size-t))
578 
579 (with-errptr rocksdb-put-cf
580  void
581  (db (* rocksdb))
582  (opt (* rocksdb-writeoptions))
583  (cf (* rocksdb-column-family-handle))
584  (key (* char))
585  (keylen size-t)
586  (val (* char))
587  (vallen size-t))
588 
589 (with-errptr rocksdb-delete-cf
590  void
591  (db (* rocksdb))
592  (options (* rocksdb-writeoptions))
593  (cf (* rocksdb-column-family-handle))
594  (key (* char))
595  (keylen size-t))
596 
597 (with-errptr rocksdb-delete-range-cf
598  void
599  (db (* rocksdb))
600  (options (* rocksdb-writeoptions))
601  (cf (* rocksdb-column-family-handle))
602  (start-key (* char))
603  (start-key-len size-t)
604  (end-key (* char))
605  (end-key-len size-t))
606 
607 (with-errptr rocksdb-destroy-db void
608  (opts (* rocksdb-options))
609  (path c-string))
610 
611 ;;; Iterators
612 (define-alien-routine rocksdb-create-iterator (* rocksdb-iterator)
613  (db (* rocksdb))
614  (opt (* rocksdb-readoptions)))
615 (define-alien-routine rocksdb-iter-destroy void
616  (iter (* rocksdb-iterator)))
617 (define-alien-routine rocksdb-iter-seek-to-first void
618  (iter (* rocksdb-iterator)))
619 (define-alien-routine rocksdb-iter-valid boolean
620  (iter (* rocksdb-iterator)))
621 (define-alien-routine rocksdb-iter-next void
622  (iter (* rocksdb-iterator)))
623 (define-alien-routine rocksdb-iter-prev void
624  (iter (* rocksdb-iterator)))
625 (define-alien-routine rocksdb-iter-key (* char)
626  (iter (* rocksdb-iterator))
627  (klen-ptr (* size-t)))
628 (define-alien-routine rocksdb-iter-value (* char)
629  (iter (* rocksdb-iterator))
630  (vlen-ptr (* size-t)))