changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 698: 96958d3eb5b0
parent: fea71448569b
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 ;;; rocksdb/comparator.lisp --- RocksDB Comparators
2 
3 ;; RocksDB Lisp Comparator API
4 
5 ;;; Commentary:
6 
7 ;; ref: https://github.com/facebook/rocksdb/blob/main/include/rocksdb/comparator.h
8 #|
9 // Three-way comparison. Returns value:
10 // < 0 iff "a" < "b",
11 // == 0 iff "a" == "b",
12 // > 0 iff "a" > "b"
13 // Note that Compare(a, b) also compares timestamp if timestamp size is
14 // non-zero. For the same user key with different timestamps, larger (newer)
15 // timestamp comes first.
16 |#
17 ;;; Code:
18 (in-package :rocksdb)
19 
20 (define-alien-type rocksdb-compare-function
21  (function int
22  (* t)
23  c-string
24  size-t
25  c-string
26  size-t))
27 
28 (define-alien-type rocksdb-compare-with-ts-function
29  (function int
30  (* t)
31  c-string
32  size-t
33  c-string
34  size-t))
35 
36 (define-alien-type rocksdb-compare-without-ts-function
37  (function int
38  (* t)
39  c-string
40  size-t
41  unsigned-char
42  c-string
43  size-t
44  unsigned-char))
45 
46 (define-alien-routine rocksdb-comparator-create (* rocksdb-comparator)
47  (state (* t))
48  (destructor (* rocksdb-destructor-function))
49  (compare (* rocksdb-compare-function))
50  (name (* rocksdb-name-function)))
51 
52 ;; (rocksdb-comparator-create nil nil (make-alien int 1) (make-alien unsigned-char 10))
53 
54 (define-alien-routine rocksdb-comparator-destroy void (self (* rocksdb-comparator)))
55 
56 (define-alien-routine rocksdb-comparator-with-ts-create (* rocksdb-comparator)
57  (state (* t))
58  (destructor (* rocksdb-destructor-function))
59  (compare (* rocksdb-compare-function))
60  (compare-with-ts (* rocksdb-compare-with-ts-function))
61  (compare-without-ts (* rocksdb-compare-without-ts-function))
62  (name (* rocksdb-name-function)))
63 
64 (define-alien-callable rocksdb-compare-never-name c-string () (make-alien-string "compare-never"))
65 
66 (define-alien-callable rocksdb-compare-never int
67  ((state (* t))
68  (a c-string)
69  (alen size-t)
70  (b c-string)
71  (blen size-t))
72  (declare (ignore state a alen b blen))
73  0)
74 
75 (define-alien-callable rocksdb-compare-never-with-ts int
76  ((state (* t))
77  (a c-string)
78  (alen size-t)
79  (b c-string)
80  (blen size-t))
81  (declare (ignore state a alen b blen))
82  0)
83 
84 (define-alien-callable rocksdb-compare-never-without-ts int
85  ((state (* t))
86  (a c-string)
87  (alen size-t)
88  (a-ts unsigned-char)
89  (b c-string)
90  (blen size-t)
91  (b-ts unsigned-char))
92  (declare (ignore state a alen a-ts b blen b-ts))
93  0)
94 
95