changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/ffi/rocksdb/tests.lisp

changeset 616: c48704d7b06f
parent: 57813b8ee029
child: 5e57683a0c28
author: Richard Westhaver <ellis@rwest.io>
date: Tue, 20 Aug 2024 21:02:58 -0400
permissions: -rw-r--r--
description: writebatch callbacks and fixes
2
ellis <ellis@rwest.io>
parents:
diff changeset
1
 ;;; rocksdb/tests.lisp --- RocksDB tests
ellis <ellis@rwest.io>
parents:
diff changeset
2
 
ellis <ellis@rwest.io>
parents:
diff changeset
3
 ;;; Code:
7
05527b920c97 asd cleanups
ellis <ellis@rwest.io>
parents: 2
diff changeset
4
 (defpackage :rocksdb/tests
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
5
   (:use :cl :std :rt :rocksdb :sb-ext :sb-alien :log))
2
ellis <ellis@rwest.io>
parents:
diff changeset
6
 
7
05527b920c97 asd cleanups
ellis <ellis@rwest.io>
parents: 2
diff changeset
7
 (in-package :rocksdb/tests)
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
8
 
14
c953c2a35835 rocksdb symbols and macs
ellis <ellis@rwest.io>
parents: 7
diff changeset
9
 (defsuite :rocksdb)
c953c2a35835 rocksdb symbols and macs
ellis <ellis@rwest.io>
parents: 7
diff changeset
10
 (in-suite :rocksdb)
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
11
 
14
c953c2a35835 rocksdb symbols and macs
ellis <ellis@rwest.io>
parents: 7
diff changeset
12
 (load-rocksdb)
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
13
 (init-log-timestamp)
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
14
 
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
15
 (defun rocksdb-test-dir ()
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
16
   (format nil "/tmp/~A/" (gensym "rocksdb-tests-")))
2
ellis <ellis@rwest.io>
parents:
diff changeset
17
 
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
18
 (defun rocksdb-test-file ()
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
19
   (format nil "/tmp/~A" (gensym "rocksdb-test-")))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
20
 
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
21
 (defun test-opts () 
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
22
   (let ((default (rocksdb-options-create)))
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
23
     (rocksdb-options-set-create-if-missing default t)
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
24
     default))
2
ellis <ellis@rwest.io>
parents:
diff changeset
25
 
ellis <ellis@rwest.io>
parents:
diff changeset
26
 ;; not thread safe (gensym-counter)
ellis <ellis@rwest.io>
parents:
diff changeset
27
 (defun genkey (&optional prefix) (string-to-octets (symbol-name (gensym (or prefix "key")))))
ellis <ellis@rwest.io>
parents:
diff changeset
28
 (defun genval (&optional prefix) (string-to-octets (symbol-name (gensym (or prefix "val")))))
ellis <ellis@rwest.io>
parents:
diff changeset
29
 
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
30
 (defmacro with-opt ((var create destroy) &body body)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
31
   `(let ((,var ,create))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
32
      (unwind-protect (progn ,@body)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
33
        ,destroy)))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
34
 
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
35
 (deftest opts ()
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
36
   (with-opt (o (rocksdb-options-create) (rocksdb-options-destroy o))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
37
     ;; unsigned-char
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
38
     (rocksdb-options-set-create-if-missing o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
39
     (rocksdb-options-get-create-if-missing o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
40
     (rocksdb-options-set-create-missing-column-families o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
41
     (rocksdb-options-get-create-missing-column-families o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
42
     (rocksdb-options-set-error-if-exists o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
43
     (rocksdb-options-get-error-if-exists o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
44
     (rocksdb-options-set-paranoid-checks o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
45
     (rocksdb-options-get-paranoid-checks o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
46
     (rocksdb-options-set-compression-options-use-zstd-dict-trainer o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
47
     (rocksdb-options-get-compression-options-use-zstd-dict-trainer o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
48
     (rocksdb-options-set-enable-blob-gc o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
49
     (rocksdb-options-get-enable-blob-gc o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
50
     (rocksdb-options-set-allow-ingest-behind o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
51
     (rocksdb-options-get-allow-ingest-behind o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
52
     (rocksdb-options-set-skip-stats-update-on-db-open o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
53
     (rocksdb-options-get-skip-stats-update-on-db-open o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
54
     (rocksdb-options-set-skip-checking-sst-file-sizes-on-db-open o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
55
     (rocksdb-options-get-skip-checking-sst-file-sizes-on-db-open o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
56
     (rocksdb-options-set-enable-blob-files o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
57
     (rocksdb-options-get-enable-blob-files o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
58
     (rocksdb-options-set-enable-pipelined-write o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
59
     (rocksdb-options-get-enable-pipelined-write o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
60
     (rocksdb-options-set-unordered-write o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
61
     (rocksdb-options-get-unordered-write o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
62
     (rocksdb-options-set-allow-mmap-reads o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
63
     (rocksdb-options-get-allow-mmap-reads o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
64
     (rocksdb-options-set-allow-mmap-writes o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
65
     (rocksdb-options-get-allow-mmap-writes o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
66
     (rocksdb-options-set-use-direct-reads o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
67
     (rocksdb-options-get-use-direct-reads o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
68
     (rocksdb-options-set-use-direct-io-for-flush-and-compaction o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
69
     (rocksdb-options-get-use-direct-io-for-flush-and-compaction o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
70
     (rocksdb-options-set-is-fd-close-on-exec o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
71
     (rocksdb-options-get-is-fd-close-on-exec o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
72
     (rocksdb-options-set-inplace-update-support o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
73
     (rocksdb-options-get-inplace-update-support o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
74
     (rocksdb-options-set-advise-random-on-open o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
75
     (rocksdb-options-get-advise-random-on-open o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
76
     (rocksdb-options-set-atomic-flush o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
77
     (rocksdb-options-get-atomic-flush o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
78
     (rocksdb-options-set-manual-wal-flush o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
79
     (rocksdb-options-get-manual-wal-flush o)
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
80
     (rocksdb-options-set-avoid-unnecessary-blocking-io o t)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
81
     (rocksdb-options-get-avoid-unnecessary-blocking-io o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
82
     ;; this is full-width value 0-255, not boolean
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
83
     (rocksdb-options-set-level-compaction-dynamic-level-bytes o 20)
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
84
     (rocksdb-options-get-level-compaction-dynamic-level-bytes o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
85
     ;; int
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
86
     (rocksdb-options-set-compression-options-parallel-threads o 4)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
87
     (rocksdb-options-get-compression-options-parallel-threads o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
88
     (rocksdb-options-set-info-log-level o 1)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
89
     (rocksdb-options-get-info-log-level o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
90
     (rocksdb-options-set-max-open-files o 100)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
91
     (rocksdb-options-get-max-open-files o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
92
     (rocksdb-options-set-max-file-opening-threads o 4)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
93
     (rocksdb-options-get-max-file-opening-threads o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
94
     (rocksdb-options-set-compression-options-zstd-max-train-bytes o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
95
     (rocksdb-options-get-compression-options-zstd-max-train-bytes o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
96
     (rocksdb-options-set-num-levels o 4)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
97
     (rocksdb-options-get-num-levels o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
98
     (rocksdb-options-set-level0-file-num-compaction-trigger o 16)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
99
     (rocksdb-options-get-level0-file-num-compaction-trigger o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
100
     (rocksdb-options-set-level0-slowdown-writes-trigger o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
101
     (rocksdb-options-get-level0-slowdown-writes-trigger o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
102
     (rocksdb-options-set-level0-stop-writes-trigger o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
103
     (rocksdb-options-get-level0-stop-writes-trigger o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
104
     (rocksdb-options-set-target-file-size-multiplier o 4)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
105
     (rocksdb-options-get-target-file-size-multiplier o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
106
     ;; size-t
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
107
     (rocksdb-options-set-write-buffer-size o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
108
     (rocksdb-options-get-write-buffer-size o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
109
     (rocksdb-options-set-db-write-buffer-size o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
110
     (rocksdb-options-get-db-write-buffer-size o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
111
     ;; unsigned-long
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
112
     (rocksdb-options-set-compression-options-max-dict-buffer-bytes o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
113
     (rocksdb-options-get-compression-options-max-dict-buffer-bytes o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
114
     (rocksdb-options-set-max-total-wal-size o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
115
     (rocksdb-options-get-max-total-wal-size o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
116
     (rocksdb-options-set-target-file-size-base o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
117
     (rocksdb-options-get-target-file-size-base o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
118
     (rocksdb-options-set-max-bytes-for-level-base o 1024)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
119
     (rocksdb-options-get-max-bytes-for-level-base o)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
120
     ;; double
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
121
     ;; (rocksdb-options-set-max-bytes-for-level-multiplier o (the double-float (/ 1 3)))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
122
     )
2
ellis <ellis@rwest.io>
parents:
diff changeset
123
   (let ((opts (rocksdb-options-create))
ellis <ellis@rwest.io>
parents:
diff changeset
124
         (wopts (rocksdb-writeoptions-create))
ellis <ellis@rwest.io>
parents:
diff changeset
125
         (ropts (rocksdb-readoptions-create))
ellis <ellis@rwest.io>
parents:
diff changeset
126
         (bopts (rocksdb-block-based-options-create)))
284
597f34d43df7 x.lisp upgrades, skel upgrades, worked on shell reader macros
Richard Westhaver <ellis@rwest.io>
parents: 271
diff changeset
127
     (rocksdb-options-set-create-if-missing opts t)
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
128
     ;; cleanup
2
ellis <ellis@rwest.io>
parents:
diff changeset
129
     (rocksdb-options-destroy opts)
ellis <ellis@rwest.io>
parents:
diff changeset
130
     (rocksdb-writeoptions-destroy wopts)
ellis <ellis@rwest.io>
parents:
diff changeset
131
     (rocksdb-readoptions-destroy ropts)
ellis <ellis@rwest.io>
parents:
diff changeset
132
     (rocksdb-block-based-options-destroy bopts)))
ellis <ellis@rwest.io>
parents:
diff changeset
133
 
97
cc8100641c10 more rdb errptr manging
ellis <ellis@rwest.io>
parents: 96
diff changeset
134
 (defun make-errptr ()
cc8100641c10 more rdb errptr manging
ellis <ellis@rwest.io>
parents: 96
diff changeset
135
   (make-alien rocksdb-errptr))
cc8100641c10 more rdb errptr manging
ellis <ellis@rwest.io>
parents: 96
diff changeset
136
 
85
1088a94a6673 rocksdb opts
ellis <ellis@rwest.io>
parents: 82
diff changeset
137
 (deftest db-basic ()
82
a606978326c7 rocksdb ffi
ellis <ellis@rwest.io>
parents: 47
diff changeset
138
   "Test basic RocksDB functionality. Inserts KV pair into a temporary
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
139
 DB where K and V are both Lisp strings."
2
ellis <ellis@rwest.io>
parents:
diff changeset
140
   (let* ((opts (test-opts))
ellis <ellis@rwest.io>
parents:
diff changeset
141
          (path (rocksdb-test-dir))
47
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
142
          (db (rocksdb-open opts path nil))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
143
          (key (genkey))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
144
          (val (genval))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
145
 	 (klen (length key))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
146
 	 (vlen (length val))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
147
          (wopts (rocksdb-writeoptions-create))
01f7dc4d7a8e rocksdb macros
ellis <ellis@rwest.io>
parents: 46
diff changeset
148
          (ropts (rocksdb-readoptions-create)))
267
f3d814fb136a db upgrades, alik, ignoring c files (for now)
Richard Westhaver <ellis@rwest.io>
parents: 110
diff changeset
149
     (with-alien ((k (* unsigned-char) (make-alien unsigned-char klen))
f3d814fb136a db upgrades, alik, ignoring c files (for now)
Richard Westhaver <ellis@rwest.io>
parents: 110
diff changeset
150
                  (v (* unsigned-char) (make-alien unsigned-char vlen))
110
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
151
                  (errptr rocksdb-errptr nil))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
152
       ;; copy KEY to K
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
153
       (setfa k key)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
154
       ;; copy VAL to V
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
155
       (setfa v val)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
156
       ;; put K:V in DB
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
157
       (rocksdb-put db 
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
158
                    wopts
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
159
                    k
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
160
                    klen
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
161
                    v
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
162
                    vlen
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
163
                    errptr)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
164
       (is (null-alien errptr))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
165
       ;; get V from DB given K
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
166
       (rocksdb:rocksdb-cancel-all-background-work db t)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
167
       (rocksdb-get db ropts k klen (make-alien size-t vlen) errptr)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
168
       (is (null-alien errptr))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
169
       ;; copy V to RVAL and validate
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
170
       (let ((rval (make-array vlen :element-type 'unsigned-byte)))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
171
 	(loop for i from 0 below vlen do (let ((x (deref v i))) (setf (aref rval i) x)))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
172
 	(is (string= (octets-to-string val) (concatenate 'string (map 'vector #'code-char rval)))))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
173
       (rocksdb-delete db wopts k klen errptr)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
174
       (is (null-alien errptr))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
175
       (rocksdb-writeoptions-destroy wopts)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
176
       (rocksdb-readoptions-destroy ropts)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
177
       (rocksdb-cancel-all-background-work db nil)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
178
       (rocksdb-close db)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
179
       (rocksdb-destroy-db opts path errptr)
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
180
       (is (null-alien errptr))
cae8da4b1415 rocksdb macrofication, fixes for RDB (C Strings will be the death of me), removed PWN - quicklisp package conflict, smh.
ellis <ellis@rwest.io>
parents: 104
diff changeset
181
       (rocksdb-options-destroy opts))))
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
182
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
183
 (deftest sstfiles ()
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
184
   "Test SST file write/ingest functionality."
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
185
   (let* ((opts (test-opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
186
          (path (rocksdb-test-dir))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
187
          (file (rocksdb-test-file))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
188
          (db (rocksdb-open opts path nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
189
          (key (genkey))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
190
          (val (genval))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
191
          (klen (length key))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
192
          (vlen (length val))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
193
          (eopts (rocksdb-envoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
194
          (iopts (rocksdb-ingestexternalfileoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
195
          (ropts (rocksdb-readoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
196
          (writer (rocksdb-sstfilewriter-create eopts opts)))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
197
     (with-alien ((k (* unsigned-char) (make-alien unsigned-char klen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
198
                  (v (* unsigned-char) (make-alien unsigned-char vlen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
199
                  (flist (array c-string 1))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
200
                  (errptr rocksdb-errptr nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
201
       ;; copy KEY to K
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
202
       (setfa k key)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
203
       ;; copy VAL to V
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
204
       (setfa v val)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
205
       (setf (deref flist 0) file)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
206
       ;; create writer
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
207
       (rocksdb-sstfilewriter-open writer file errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
208
       ;; insert rows into sst file
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
209
       (rocksdb-sstfilewriter-put writer k klen v vlen errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
210
       (is (null-alien errptr))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
211
       (rocksdb-sstfilewriter-finish writer errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
212
       (is (null-alien errptr))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
213
       ;; ingest sst file
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
214
       (rocksdb-ingest-external-file db (cast flist (* c-string)) 1 iopts errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
215
       (is (null-alien errptr))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
216
       (let ((vres (make-array vlen :element-type 'octet :fill-pointer 0)))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
217
         (is (string= (octets-to-string val) (cast (rocksdb-get db ropts k klen (make-alien size-t vlen) errptr) c-string))))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
218
       
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
219
       ;; rocksdb-sstfilewriter-file-size
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
220
       (rocksdb-sstfilewriter-destroy writer)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
221
       (rocksdb-close db)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
222
       (rocksdb-destroy-db opts path errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
223
       (rocksdb-options-destroy opts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
224
       (rocksdb-envoptions-destroy eopts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
225
       (delete-file file)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
226
       (is (null-alien errptr)))))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
227
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
228
 (deftest stats ()
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
229
   "Test statistics and performance-context related functionality."
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
230
   (rocksdb-set-perf-level (rocksdb-perf-level "enable-time-except-for-mutex"))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
231
   (let* ((opts (test-opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
232
          (path (rocksdb-test-dir))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
233
          (db (rocksdb-open opts path nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
234
          (key (random-bytes 100))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
235
          (val (random-bytes 100000))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
236
          (klen (length key))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
237
          (vlen (length val))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
238
          (wopts (rocksdb-writeoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
239
          (ropts (rocksdb-readoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
240
          (ctx (rocksdb::rocksdb-perfcontext-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
241
          (hist (rocksdb-statistics-histogram-data-create)))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
242
     (with-alien ((k (* (unsigned 8)) (make-alien (unsigned 8) klen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
243
                  (v (* (unsigned 8)) (make-alien (unsigned 8) vlen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
244
                  (errptr rocksdb-errptr nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
245
       ;; copy KEY to K
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
246
       (setfa k key)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
247
       ;; copy VAL to V
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
248
       (setfa v val)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
249
       ;; put K:V in DB
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
250
       (rocksdb-put db 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
251
                    wopts
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
252
                    k
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
253
                    klen
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
254
                    v
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
255
                    vlen
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
256
                    errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
257
       
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
258
       (debug! "stats:" (rocksdb-options-statistics-get-string opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
259
       (rocksdb-options-statistics-get-histogram-data opts 5 hist) ;; histogram data types? uint64 somewhere
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
260
       (debug! "count:" (rocksdb-statistics-histogram-data-get-count hist))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
261
       (rocksdb-perfcontext-reset ctx)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
262
       ;; ...
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
263
       (rocksdb-set-perf-level (rocksdb-perf-level "disable"))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
264
       (rocksdb-statistics-histogram-data-destroy hist)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
265
       (rocksdb-close db)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
266
       (rocksdb-destroy-db opts path errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
267
       (rocksdb-options-destroy opts))))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
268
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
269
 ;; stats-dump-period-sec
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
270
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
271
 (deftest blob ()
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
272
   "Test BlobDB functionality."
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
273
   (let* ((opts (test-opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
274
          (path (rocksdb-test-dir))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
275
          db
270
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
276
          (key (random-bytes 8))
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
277
          (val (make-array 9999 :initial-element 36))
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
278
          (klen (length key))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
279
          (vlen (length val))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
280
          (wopts (rocksdb-writeoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
281
          (ropts (rocksdb-readoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
282
          (bcache (rocksdb-cache-create-lru 128)))
301
5b5d12253b8d test fix
Richard Westhaver <ellis@rwest.io>
parents: 284
diff changeset
283
     (rocksdb-options-set-enable-blob-files opts t)
5b5d12253b8d test fix
Richard Westhaver <ellis@rwest.io>
parents: 284
diff changeset
284
     (rocksdb-options-set-enable-blob-gc opts t)
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
285
     (rocksdb-options-set-blob-compression-type opts (rocksdb-compression-backend "zstd"))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
286
     (rocksdb-options-set-blob-cache opts bcache)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
287
     (setf db (rocksdb-open opts path nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
288
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
289
     (with-alien ((k (* (unsigned 8)) (make-alien (unsigned 8) klen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
290
                  (v (* (unsigned 8)) (make-alien (unsigned 8) vlen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
291
                  (errptr rocksdb-errptr nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
292
       (debug! "min blob file size: " (rocksdb-options-get-min-blob-size opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
293
       (debug! "max blob file size: " (rocksdb-options-get-blob-file-size opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
294
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
295
       ;; copy KEY to K
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
296
       (setfa k key)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
297
       ;; copy VAL to V
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
298
       (setfa v val)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
299
       ;; put K:V in DB - 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
300
       (rocksdb-put db 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
301
                    wopts
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
302
                    k
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
303
                    klen
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
304
                    v
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
305
                    vlen
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
306
                    errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
307
       (is (null-alien errptr))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
308
       (rocksdb:rocksdb-flush db (rocksdb-flushoptions-create) errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
309
       (is (null-alien errptr))
270
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
310
       (is (stringp
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
311
            (cast
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
312
             (rocksdb-get db
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
313
                          ropts
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
314
                          k
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
315
                          klen
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
316
                          (make-alien size-t vlen)
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
317
                          errptr)
Richard Westhaver <ellis@rwest.io>
parents: 269
diff changeset
318
             c-string)))
269
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
319
       (rocksdb-writeoptions-destroy wopts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
320
       (rocksdb-readoptions-destroy ropts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
321
       (rocksdb-close db)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
322
       (rocksdb-destroy-db opts path errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
323
       (is (null-alien errptr))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
324
       (rocksdb-options-destroy opts))))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
325
 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
326
 (deftest transaction ()
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
327
   "Test simple transactions using both TransactionDB and OptimisticTransactionDB."
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
328
   (let* ((opts (test-opts))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
329
          (path (rocksdb-test-dir))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
330
          (db (rocksdb-open opts path nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
331
          (key (genkey))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
332
          (val (genval))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
333
          (klen (length key))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
334
          (vlen (length val))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
335
          (wopts (rocksdb-writeoptions-create))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
336
          (ropts (rocksdb-readoptions-create)))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
337
     (with-alien ((k (* (unsigned 8)) (make-alien (unsigned 8) klen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
338
                  (v (* (unsigned 8)) (make-alien (unsigned 8) vlen))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
339
                  (errptr rocksdb-errptr nil))
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
340
       ;; copy KEY to K
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
341
       (setfa k key)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
342
       ;; copy VAL to V
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
343
       (setfa v val)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
344
       ;; put K:V in DB - 
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
345
       (rocksdb-writeoptions-destroy wopts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
346
       (rocksdb-readoptions-destroy ropts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
347
       (rocksdb-close db)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
348
       (rocksdb-destroy-db opts path errptr)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
349
       (rocksdb-options-destroy opts)
87f503c7a365 more rocksdb
Richard Westhaver <ellis@rwest.io>
parents: 267
diff changeset
350
       (is (null-alien errptr)))))
271
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
351
 
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
352
 (deftest metadata ()
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
353
   "Test metadata functionality :: cf-meta -> level-meta -> sst-file-meta"
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
354
   nil)
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
355
 
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
356
 (deftest properties ()
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
357
   "Test the ROCKSDB-GET-PROPERTY-* functions."
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
358
   ;; *rocksdb-properties*
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
359
   (let* ((opts (test-opts))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
360
          (path (rocksdb-test-dir))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
361
          (db (rocksdb-open opts path nil))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
362
          (key (genkey))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
363
          (val (genval))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
364
          (klen (length key))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
365
          (vlen (length val))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
366
          (wopts (rocksdb-writeoptions-create))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
367
          (ropts (rocksdb-readoptions-create)))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
368
     (is (stringp (debug! (rocksdb-property-value db (make-alien-string "rocksdb.stats")))))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
369
     (is (zerop (parse-integer (rocksdb-property-value db (make-alien-string "rocksdb.num-files-at-level3")))))))
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
370
 
4a1a21ff46ee metadata,props,merge-ops
Richard Westhaver <ellis@rwest.io>
parents: 270
diff changeset
371
 (deftest merge ()
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
372
   "Test low-level merge-operator functionality using Alien Callbacks."
597
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
373
   (is (with-alien ((k (array unsigned-char))
598
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
374
                    (v (array unsigned-char))
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
375
                    (ops (array (array unsigned-char)))
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
376
                    (s (array unsigned-char)))
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
377
         (alien-funcall
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
378
          (alien-callable-function
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
379
           'rocksdb-concat-full-merge)
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
380
          k 0 v 0 ops (make-alien size-t 0) 0 s (make-alien size-t 0))))
597
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
381
   (is
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
382
    (not
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
383
     (with-alien ((k (array unsigned-char))
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
384
                  (ops (array (array unsigned-char)))
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
385
                  (s (array unsigned-char)))
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
386
       (alien-funcall
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
387
        (alien-callable-function
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
388
         'rocksdb-concat-partial-merge)
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
389
        k 0 ops (make-alien size-t 0) 0 s (make-alien size-t 0)))))
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
390
   (alien-callable-function 'rocksdb-concat-full-merge)
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
391
   (alien-callable-function 'rocksdb-concat-partial-merge)
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
392
   (is (integerp
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
393
        (parse-integer
598
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
394
         (string-trim "rocksdb:" (alien-funcall (alien-callable-function 'rocksdb-name))))))
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
395
   ;; returns No Value
606
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
396
   (with-alien ((str c-string (make-alien-string ""))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
397
                (state (* t)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
398
     (is (null (alien-funcall (alien-callable-function 'rocksdb-delete-value) state str 1))))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
399
 
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
400
   (is (null (alien-funcall (alien-callable-function 'rocksdb-destructor) (make-alien (* t)))))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
401
 
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
402
   ;; null merge op
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
403
   (with-alien ((state (* t))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
404
                (destructor (* rocksdb-destructor-function))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
405
                (full-merge (* rocksdb-full-merge-function))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
406
                (partial-merge (* rocksdb-partial-merge-function))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
407
                (delete-value (* rocksdb-delete-value-function))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
408
                (name (* rocksdb-name-function)))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
409
     (is (typep (rocksdb-mergeoperator-create state destructor full-merge partial-merge delete-value name)
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
410
                '(alien (* rocksdb-mergeoperator)))))
597
5b2ca5b2a9db rocksdb merge-op progress
Richard Westhaver <ellis@rwest.io>
parents: 513
diff changeset
411
 
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
412
   ;; concat merge op
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
413
   (with-alien ((state (* t))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
414
                (destructor (* rocksdb-destructor-function) (alien-sap (alien-callable-function 'rocksdb-destructor)))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
415
                (full-merge (* rocksdb-full-merge-function) (alien-sap (alien-callable-function 'rocksdb-concat-full-merge)))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
416
                (partial-merge (* rocksdb-partial-merge-function) (alien-sap (alien-callable-function 'rocksdb-concat-partial-merge)))
616
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
417
                (delete-value (* rocksdb-delete-value-function) (alien-sap (alien-callable-function 'rocksdb-delete-value)))
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
418
                (name (* rocksdb-name-function) (alien-sap (alien-callable-function 'rocksdb-concat-merge-name))))
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
419
     (is (typep (rocksdb-mergeoperator-create state destructor full-merge partial-merge delete-value name)
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
420
                '(alien (* rocksdb-mergeoperator))))))
598
c7f9bfc9570f rm duplicate files, add rocksdb batch and logger files
Richard Westhaver <ellis@rwest.io>
parents: 597
diff changeset
421
 
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
422
 (deftest comparator ()
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
423
   "Test low-level comparator API."
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
424
   (with-alien ((state (* t))
606
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
425
                (destructor (* rocksdb-destructor-function) (alien-sap (alien-callable-function 'rocksdb-destructor)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
426
                (compare (* rocksdb-compare-function) (alien-sap (alien-callable-function 'rocksdb-compare-never)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
427
                (compare-with-ts (* rocksdb-compare-with-ts-function))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
428
                (compare-without-ts (* rocksdb-compare-without-ts-function))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
429
                (name (* rocksdb-name-function) (alien-sap (alien-callable-function 'rocksdb-name))))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
430
     (is (typep (rocksdb-comparator-create state destructor compare name)
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
431
                '(alien (* rocksdb-comparator))))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
432
     (is (typep (rocksdb-comparator-with-ts-create state destructor compare compare-with-ts compare-without-ts name)
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
433
                '(alien (* rocksdb-comparator))))))
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
434
 
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
435
 (deftest compaction ()
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
436
   "Test low-level compactionfilter API."
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
437
   (with-alien ((state (* t))
606
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
438
                (context (* rocksdb-compactionfiltercontext)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
439
     (is (typep
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
440
          (rocksdb-compactionfilter-create state
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
441
                                           (alien-sap (alien-callable-function 'rocksdb-destructor))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
442
 (alien-sap (alien-callable-function 'rocksdb-filter-never))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
443
                                           (alien-sap (alien-callable-function 'rocksdb-name)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
444
          '(alien (* rocksdb-compactionfilter))))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
445
     (is (typep
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
446
          (rocksdb-compactionfilterfactory-create state
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
447
                                                  (alien-sap (alien-callable-function 'rocksdb-destructor))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
448
                                                  (alien-sap (alien-callable-function
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
449
                                                              'rocksdb-create-compaction-filter-never))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
450
                                                  (alien-sap (alien-callable-function 'rocksdb-name)))
6fc04c4d465c emacs and rocksdb upgrades
Richard Westhaver <ellis@rwest.io>
parents: 599
diff changeset
451
          '(alien (* rocksdb-compactionfilterfactory))))))
599
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
452
     
fea71448569b more rocksdb gruntwork
Richard Westhaver <ellis@rwest.io>
parents: 598
diff changeset
453
 (deftest logger ()
608
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
454
   "Test logging functionality."
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
455
   (with-alien ((state (* t))
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
456
                (lev unsigned 0)
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
457
                (msg c-string)
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
458
                (log (* rocksdb-log-function) (alien-sap (alien-callable-function 'rocksdb-log-default))))
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
459
     (is (typep
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
460
          (rocksdb-logger-create-stderr-logger lev msg)
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
461
          '(alien (* rocksdb-logger))))
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
462
     (is (typep
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
463
          (rocksdb-logger-create-callback-logger lev log state)
d91556aa3dae logger tests
Richard Westhaver <ellis@rwest.io>
parents: 606
diff changeset
464
          '(alien (* rocksdb-logger))))))
610
3dc5c63cdba7 init writebatch
Richard Westhaver <ellis@rwest.io>
parents: 608
diff changeset
465
 
3dc5c63cdba7 init writebatch
Richard Westhaver <ellis@rwest.io>
parents: 608
diff changeset
466
 (deftest writebatch ()
3dc5c63cdba7 init writebatch
Richard Westhaver <ellis@rwest.io>
parents: 608
diff changeset
467
   "Test writebatch functionality."
616
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
468
   (with-alien ((fput (* rocksdb-put-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
469
                (fdeleted (* rocksdb-deleted-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
470
                (fdeleted-cf (* rocksdb-deleted-cf-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
471
                (fput-cf (* rocksdb-put-cf-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
472
                (fmerge-cf (* rocksdb-merge-cf-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
473
                (fget-ts (* rocksdb-get-ts-size-function)))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
474
     (is (typep
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
475
          (rocksdb-writebatch-create)
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
476
          '(alien (* rocksdb-writebatch))))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
477
     (is (typep
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
478
          (rocksdb-writebatch-wi-create 0 0)
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
479
          '(alien (* rocksdb-writebatch-wi))))))
611
57813b8ee029 more rocksdb work, slice -> slicetransform
Richard Westhaver <ellis@rwest.io>
parents: 610
diff changeset
480
 
616
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
481
 (deftest slicetransform (:skip t)
611
57813b8ee029 more rocksdb work, slice -> slicetransform
Richard Westhaver <ellis@rwest.io>
parents: 610
diff changeset
482
   "Test slicetransform functionality."
616
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
483
   (with-alien ((state (* t))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
484
                (destructor (* rocksdb-destructor-function) (alien-sap (alien-callable-function 'rocksdb-destructor)))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
485
                (transform (* t) (* rocksdb-transform-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
486
                (in-domain (* rocksdb-in-domain-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
487
                (in-range (* rocksdb-in-range-function))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
488
                (name (* rocksdb-name-function) (alien-sap (alien-callable-function 'rocksdb-name))))
c48704d7b06f writebatch callbacks and fixes
Richard Westhaver <ellis@rwest.io>
parents: 611
diff changeset
489
     (rocksdb-slicetransform-create state destructor transform in-domain in-range name)))