sop4py 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sop/__init__.py +3 -0
- sop/btree.py +612 -0
- sop/call_go.py +304 -0
- sop/context.py +33 -0
- sop/libjsondb_amd64darwin.dylib +0 -0
- sop/libjsondb_amd64darwin.h +120 -0
- sop/libjsondb_amd64linux.h +120 -0
- sop/libjsondb_amd64linux.so +0 -0
- sop/libjsondb_amd64windows.dll +0 -0
- sop/libjsondb_amd64windows.h +120 -0
- sop/libjsondb_arm64darwin.dylib +0 -0
- sop/libjsondb_arm64darwin.h +120 -0
- sop/libjsondb_arm64linux.h +120 -0
- sop/libjsondb_arm64linux.so +0 -0
- sop/redis.py +40 -0
- sop/test_btree.py +479 -0
- sop/test_btree_idx.py +86 -0
- sop/transaction.py +167 -0
- sop4py-2.0.0.dist-info/METADATA +124 -0
- sop4py-2.0.0.dist-info/RECORD +22 -0
- sop4py-2.0.0.dist-info/WHEEL +5 -0
- sop4py-2.0.0.dist-info/top_level.txt +1 -0
sop/call_go.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
|
|
5
|
+
# Determine the shared library extension based on the architecture & operating system
|
|
6
|
+
architecture = platform.machine()
|
|
7
|
+
if architecture == 'arm64' or architecture == 'aarch64':
|
|
8
|
+
arch = "arm64"
|
|
9
|
+
elif architecture == 'x86_64' or architecture == 'AMD64':
|
|
10
|
+
arch = "amd64"
|
|
11
|
+
|
|
12
|
+
uname = os.uname().sysname
|
|
13
|
+
print(uname)
|
|
14
|
+
if uname == "Darwin":
|
|
15
|
+
ext = f"{arch}darwin.dylib"
|
|
16
|
+
elif uname == "Windows":
|
|
17
|
+
ext = f"{arch}windows.dll"
|
|
18
|
+
else:
|
|
19
|
+
ext = f"{arch}linux.so"
|
|
20
|
+
|
|
21
|
+
# Load the shared library
|
|
22
|
+
try:
|
|
23
|
+
lib = ctypes.CDLL(f"./libjsondb_{ext}")
|
|
24
|
+
except OSError as e:
|
|
25
|
+
print(f"Error loading library: {e}")
|
|
26
|
+
print("Ensure 'libjsondb_<arch><os>.so' (or .dll/.dylib) is in the same directory.")
|
|
27
|
+
exit()
|
|
28
|
+
|
|
29
|
+
# Call the 'hello' function (no arguments, no return value)
|
|
30
|
+
print("Calling Go's open_redis_connection() function:")
|
|
31
|
+
_open_redis_conn = lib.openRedisConnection
|
|
32
|
+
|
|
33
|
+
# Call the 'open+_redis_connection' function with arguments and set argument/return types
|
|
34
|
+
_open_redis_conn.argtypes = [
|
|
35
|
+
ctypes.c_char_p,
|
|
36
|
+
ctypes.c_int,
|
|
37
|
+
ctypes.c_char_p,
|
|
38
|
+
] # Specify argument types
|
|
39
|
+
_open_redis_conn.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
40
|
+
|
|
41
|
+
_close_redis_conn = lib.closeRedisConnection
|
|
42
|
+
_close_redis_conn.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
43
|
+
|
|
44
|
+
# De-allocate backing memory for a string.
|
|
45
|
+
_free_string = lib.freeString
|
|
46
|
+
_free_string.argtypes = [ctypes.c_char_p]
|
|
47
|
+
_free_string.restype = None
|
|
48
|
+
|
|
49
|
+
_create_context = lib.createContext
|
|
50
|
+
_create_context.argtypes = None
|
|
51
|
+
_create_context.restype = ctypes.c_int64 # Specify return type
|
|
52
|
+
_remove_context = lib.removeContext
|
|
53
|
+
_remove_context.argtypes = [ctypes.c_int64] # Specify return type
|
|
54
|
+
_remove_context.restype = None
|
|
55
|
+
_cancel_context = lib.cancelContext
|
|
56
|
+
_cancel_context.argtypes = [ctypes.c_int64] # Specify return type
|
|
57
|
+
_cancel_context.restype = None
|
|
58
|
+
|
|
59
|
+
_manage_transaction = lib.manageTransaction
|
|
60
|
+
|
|
61
|
+
_manage_transaction.argtypes = [
|
|
62
|
+
ctypes.c_int64,
|
|
63
|
+
ctypes.c_int,
|
|
64
|
+
ctypes.c_char_p,
|
|
65
|
+
] # Specify argument types
|
|
66
|
+
_manage_transaction.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
67
|
+
|
|
68
|
+
_manage_btree = lib.manageBtree
|
|
69
|
+
_manage_btree.argtypes = [
|
|
70
|
+
ctypes.c_int64,
|
|
71
|
+
ctypes.c_int,
|
|
72
|
+
ctypes.c_char_p,
|
|
73
|
+
ctypes.c_char_p,
|
|
74
|
+
] # Specify argument types
|
|
75
|
+
_manage_btree.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# Define the structure for return values
|
|
79
|
+
class ResultStruct(ctypes.Structure):
|
|
80
|
+
_fields_ = [
|
|
81
|
+
("payload", ctypes.POINTER(ctypes.c_char)), # First return value (C string)
|
|
82
|
+
("error", ctypes.POINTER(ctypes.c_char)), # Second return value (C string)
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
_get_from_btree = lib.getFromBtree
|
|
87
|
+
_get_from_btree.argtypes = [
|
|
88
|
+
ctypes.c_int64,
|
|
89
|
+
ctypes.c_int,
|
|
90
|
+
ctypes.c_char_p,
|
|
91
|
+
ctypes.c_char_p,
|
|
92
|
+
] # Specify argument types
|
|
93
|
+
_get_from_btree.restype = ResultStruct # Specify return type
|
|
94
|
+
|
|
95
|
+
_navigate_btree = lib.navigateBtree
|
|
96
|
+
_navigate_btree.argtypes = [
|
|
97
|
+
ctypes.c_int64,
|
|
98
|
+
ctypes.c_int,
|
|
99
|
+
ctypes.c_char_p,
|
|
100
|
+
ctypes.c_char_p,
|
|
101
|
+
] # Specify argument types
|
|
102
|
+
_navigate_btree.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
103
|
+
|
|
104
|
+
_is_unique_btree = lib.isUniqueBtree
|
|
105
|
+
_is_unique_btree.argtypes = [
|
|
106
|
+
ctypes.c_char_p,
|
|
107
|
+
] # Specify argument types
|
|
108
|
+
_is_unique_btree.restype = ctypes.POINTER(ctypes.c_char) # Specify return type
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class getBtreeCountResult(ctypes.Structure):
|
|
112
|
+
_fields_ = [
|
|
113
|
+
("count", ctypes.c_int64), # First return value (C long)
|
|
114
|
+
("error", ctypes.POINTER(ctypes.c_char)), # Second return value (C string)
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
_get_btree_item_count = lib.getBtreeItemCount
|
|
119
|
+
_get_btree_item_count.argtypes = [
|
|
120
|
+
ctypes.c_char_p,
|
|
121
|
+
] # Specify argument types
|
|
122
|
+
_get_btree_item_count.restype = getBtreeCountResult # Specify return type
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def create_context() -> int:
|
|
126
|
+
return ctypes.c_int64(_create_context()).value
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def remove_context(ctxid: int):
|
|
130
|
+
_remove_context(ctypes.c_int64(ctxid).value)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def cancel_context(ctxid: int):
|
|
134
|
+
_cancel_context(ctypes.c_int64(ctxid).value)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def open_redis_connection(host: str, port: int, password: str) -> str:
|
|
138
|
+
"""
|
|
139
|
+
Open the Redis connection.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
res = _open_redis_conn(to_cstring(host), to_cint(port), to_cstring(password))
|
|
143
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
144
|
+
return None
|
|
145
|
+
|
|
146
|
+
s = to_str(res)
|
|
147
|
+
# free the string allocated in C heap using malloc.
|
|
148
|
+
_free_string(res)
|
|
149
|
+
return s
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def close_redis_connection() -> str:
|
|
153
|
+
"""
|
|
154
|
+
Close the Redis connection.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
res = _close_redis_conn()
|
|
158
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
159
|
+
return None
|
|
160
|
+
|
|
161
|
+
s = to_str(res)
|
|
162
|
+
# free the string allocated in C heap using malloc.
|
|
163
|
+
_free_string(res)
|
|
164
|
+
return s
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def manage_transaction(ctxID: int, action: int, payload: str) -> str:
|
|
168
|
+
"""
|
|
169
|
+
Manage a SOP transaction.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
res = _manage_transaction(
|
|
173
|
+
ctypes.c_int64(ctxID).value, to_cint(action), to_cstring(payload)
|
|
174
|
+
)
|
|
175
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
176
|
+
return None
|
|
177
|
+
|
|
178
|
+
s = to_str(res)
|
|
179
|
+
# free the string allocated in C heap using malloc.
|
|
180
|
+
_free_string(res)
|
|
181
|
+
|
|
182
|
+
return s
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def manage_btree(ctxID: int, action: int, payload: str, payload2: str) -> str:
|
|
186
|
+
"""
|
|
187
|
+
Manage a SOP btree.
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
p2 = None
|
|
191
|
+
if payload2 is not None:
|
|
192
|
+
p2 = to_cstring(payload2)
|
|
193
|
+
res = _manage_btree(
|
|
194
|
+
ctypes.c_int64(ctxID).value, to_cint(action), to_cstring(payload), p2
|
|
195
|
+
)
|
|
196
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
197
|
+
return None
|
|
198
|
+
|
|
199
|
+
s = to_str(res)
|
|
200
|
+
# free the string allocated in C heap using malloc.
|
|
201
|
+
_free_string(res)
|
|
202
|
+
|
|
203
|
+
return s
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def navigate_btree(ctxID: int, action: int, payload: str, payload2: str) -> str:
|
|
207
|
+
"""
|
|
208
|
+
Navigate a SOP btree.
|
|
209
|
+
"""
|
|
210
|
+
|
|
211
|
+
p2 = None
|
|
212
|
+
if payload2 is not None:
|
|
213
|
+
p2 = to_cstring(payload2)
|
|
214
|
+
res = _navigate_btree(
|
|
215
|
+
ctypes.c_int64(ctxID).value, to_cint(action), to_cstring(payload), p2
|
|
216
|
+
)
|
|
217
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
218
|
+
return None
|
|
219
|
+
|
|
220
|
+
s = to_str(res)
|
|
221
|
+
# free the string allocated in C heap using malloc.
|
|
222
|
+
_free_string(res)
|
|
223
|
+
|
|
224
|
+
return s
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def get_from_btree(ctxID: int, action: int, payload: str, payload2: str):
|
|
228
|
+
"""
|
|
229
|
+
Fetch/Navigate from SOP btree.
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
p2 = None
|
|
233
|
+
if payload2 is not None:
|
|
234
|
+
p2 = to_cstring(payload2)
|
|
235
|
+
result = _get_from_btree(
|
|
236
|
+
ctypes.c_int64(ctxID).value, to_cint(action), to_cstring(payload), p2
|
|
237
|
+
)
|
|
238
|
+
if (
|
|
239
|
+
result.error is not None
|
|
240
|
+
and ctypes.cast(result.error, ctypes.c_char_p).value is not None
|
|
241
|
+
):
|
|
242
|
+
se = to_str(result.error)
|
|
243
|
+
# free the string allocated in C heap using malloc.
|
|
244
|
+
_free_string(result.error)
|
|
245
|
+
if (
|
|
246
|
+
result.payload is not None
|
|
247
|
+
and ctypes.cast(result.payload, ctypes.c_char_p).value is not None
|
|
248
|
+
):
|
|
249
|
+
sp = to_str(result.payload)
|
|
250
|
+
_free_string(result.payload)
|
|
251
|
+
return sp, se
|
|
252
|
+
return None, se
|
|
253
|
+
|
|
254
|
+
s = to_str(result.payload)
|
|
255
|
+
# free the string allocated in C heap using malloc.
|
|
256
|
+
_free_string(result.payload)
|
|
257
|
+
|
|
258
|
+
return s, None
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def is_unique_btree(payload: str) -> str:
|
|
262
|
+
"""
|
|
263
|
+
IsUnique btree.
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
res = _is_unique_btree(to_cstring(payload))
|
|
267
|
+
if res is None or ctypes.cast(res, ctypes.c_char_p).value is None:
|
|
268
|
+
return None
|
|
269
|
+
|
|
270
|
+
s = to_str(res)
|
|
271
|
+
# free the string allocated in C heap using malloc.
|
|
272
|
+
_free_string(res)
|
|
273
|
+
|
|
274
|
+
return s
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def get_btree_item_count(payload: str):
|
|
278
|
+
"""
|
|
279
|
+
Get btree item count.
|
|
280
|
+
"""
|
|
281
|
+
|
|
282
|
+
result = _get_btree_item_count(to_cstring(payload))
|
|
283
|
+
if (
|
|
284
|
+
result.error is not None
|
|
285
|
+
and ctypes.cast(result.error, ctypes.c_char_p).value is not None
|
|
286
|
+
):
|
|
287
|
+
se = to_str(result.error)
|
|
288
|
+
# free the string allocated in C heap using malloc.
|
|
289
|
+
_free_string(result.error)
|
|
290
|
+
return 0, se
|
|
291
|
+
|
|
292
|
+
return result.count, None
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def to_str(s: ctypes.c_char_p) -> str:
|
|
296
|
+
return ctypes.cast(s, ctypes.c_char_p).value.decode("utf-8")
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def to_cstring(s: str) -> ctypes.c_char_p:
|
|
300
|
+
return ctypes.c_char_p(s.encode("utf-8"))
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def to_cint(i: int) -> ctypes.c_int:
|
|
304
|
+
return ctypes.c_int(i)
|
sop/context.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import call_go
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Context:
|
|
5
|
+
"""
|
|
6
|
+
Use context as parameter when calling SOP Transaction & Btree methods. And if your code needs to, use
|
|
7
|
+
it to cancel any ongoing method, e.g. transaction commit. While your code is running on another thread and commit
|
|
8
|
+
is happening, your code can call the context's cancel method to tell the commit to abort.
|
|
9
|
+
|
|
10
|
+
That is what a context is for coming from the Python side, option for execution abortion if/when necessary.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self):
|
|
14
|
+
"""
|
|
15
|
+
Constructor auto creates a constructor on the other side and keep the 'id' so it can get "managed" later on.
|
|
16
|
+
"""
|
|
17
|
+
self._removed = False
|
|
18
|
+
self.id = call_go.create_context()
|
|
19
|
+
|
|
20
|
+
def __del__(self):
|
|
21
|
+
"""
|
|
22
|
+
Destructor auto removes the context from the other side.
|
|
23
|
+
"""
|
|
24
|
+
if not self._removed:
|
|
25
|
+
self._removed = True
|
|
26
|
+
call_go.remove_context(self.id)
|
|
27
|
+
|
|
28
|
+
def cancel(self):
|
|
29
|
+
"""
|
|
30
|
+
cancel or abort any running function within a context.
|
|
31
|
+
"""
|
|
32
|
+
call_go.cancel_context(self.id)
|
|
33
|
+
self._removed = True
|
|
Binary file
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package command-line-arguments */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/* Start of preamble from import "C" comments. */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#line 3 "jsondb_main.go"
|
|
24
|
+
|
|
25
|
+
#include <stdio.h> // C.longlong
|
|
26
|
+
#include <stdlib.h> // For free
|
|
27
|
+
|
|
28
|
+
#line 1 "cgo-generated-wrapper"
|
|
29
|
+
|
|
30
|
+
#line 3 "jsondb_manage_btree.go"
|
|
31
|
+
|
|
32
|
+
#include <stdlib.h> // For free
|
|
33
|
+
|
|
34
|
+
#line 1 "cgo-generated-wrapper"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* End of preamble from import "C" comments. */
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* Start of boilerplate cgo prologue. */
|
|
41
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
42
|
+
|
|
43
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
44
|
+
#define GO_CGO_PROLOGUE_H
|
|
45
|
+
|
|
46
|
+
typedef signed char GoInt8;
|
|
47
|
+
typedef unsigned char GoUint8;
|
|
48
|
+
typedef short GoInt16;
|
|
49
|
+
typedef unsigned short GoUint16;
|
|
50
|
+
typedef int GoInt32;
|
|
51
|
+
typedef unsigned int GoUint32;
|
|
52
|
+
typedef long long GoInt64;
|
|
53
|
+
typedef unsigned long long GoUint64;
|
|
54
|
+
typedef GoInt64 GoInt;
|
|
55
|
+
typedef GoUint64 GoUint;
|
|
56
|
+
typedef size_t GoUintptr;
|
|
57
|
+
typedef float GoFloat32;
|
|
58
|
+
typedef double GoFloat64;
|
|
59
|
+
#ifdef _MSC_VER
|
|
60
|
+
#include <complex.h>
|
|
61
|
+
typedef _Fcomplex GoComplex64;
|
|
62
|
+
typedef _Dcomplex GoComplex128;
|
|
63
|
+
#else
|
|
64
|
+
typedef float _Complex GoComplex64;
|
|
65
|
+
typedef double _Complex GoComplex128;
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
static assertion to make sure the file is being used on architecture
|
|
70
|
+
at least with matching size of GoInt.
|
|
71
|
+
*/
|
|
72
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
73
|
+
|
|
74
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
75
|
+
typedef _GoString_ GoString;
|
|
76
|
+
#endif
|
|
77
|
+
typedef void *GoMap;
|
|
78
|
+
typedef void *GoChan;
|
|
79
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
80
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
81
|
+
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
/* End of boilerplate cgo prologue. */
|
|
85
|
+
|
|
86
|
+
#ifdef __cplusplus
|
|
87
|
+
extern "C" {
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
extern char* navigateBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
91
|
+
extern char* isUniqueBtree(char* payload);
|
|
92
|
+
|
|
93
|
+
/* Return type for getFromBtree */
|
|
94
|
+
struct getFromBtree_return {
|
|
95
|
+
char* r0;
|
|
96
|
+
char* r1;
|
|
97
|
+
};
|
|
98
|
+
extern struct getFromBtree_return getFromBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
99
|
+
|
|
100
|
+
/* Return type for getBtreeItemCount */
|
|
101
|
+
struct getBtreeItemCount_return {
|
|
102
|
+
long long r0;
|
|
103
|
+
char* r1;
|
|
104
|
+
};
|
|
105
|
+
extern struct getBtreeItemCount_return getBtreeItemCount(char* payload);
|
|
106
|
+
extern long long createContext();
|
|
107
|
+
extern void cancelContext(long long ctxID);
|
|
108
|
+
extern void removeContext(long long ctxID);
|
|
109
|
+
|
|
110
|
+
// Redis global connection management related.
|
|
111
|
+
//
|
|
112
|
+
extern char* openRedisConnection(char* host, int port, char* password);
|
|
113
|
+
extern char* closeRedisConnection();
|
|
114
|
+
extern char* manageTransaction(long long ctxID, int action, char* payload);
|
|
115
|
+
extern void freeString(char* cString);
|
|
116
|
+
extern char* manageBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
117
|
+
|
|
118
|
+
#ifdef __cplusplus
|
|
119
|
+
}
|
|
120
|
+
#endif
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package command-line-arguments */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/* Start of preamble from import "C" comments. */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#line 3 "jsondb_main.go"
|
|
24
|
+
|
|
25
|
+
#include <stdio.h> // C.longlong
|
|
26
|
+
#include <stdlib.h> // For free
|
|
27
|
+
|
|
28
|
+
#line 1 "cgo-generated-wrapper"
|
|
29
|
+
|
|
30
|
+
#line 3 "jsondb_manage_btree.go"
|
|
31
|
+
|
|
32
|
+
#include <stdlib.h> // For free
|
|
33
|
+
|
|
34
|
+
#line 1 "cgo-generated-wrapper"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* End of preamble from import "C" comments. */
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* Start of boilerplate cgo prologue. */
|
|
41
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
42
|
+
|
|
43
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
44
|
+
#define GO_CGO_PROLOGUE_H
|
|
45
|
+
|
|
46
|
+
typedef signed char GoInt8;
|
|
47
|
+
typedef unsigned char GoUint8;
|
|
48
|
+
typedef short GoInt16;
|
|
49
|
+
typedef unsigned short GoUint16;
|
|
50
|
+
typedef int GoInt32;
|
|
51
|
+
typedef unsigned int GoUint32;
|
|
52
|
+
typedef long long GoInt64;
|
|
53
|
+
typedef unsigned long long GoUint64;
|
|
54
|
+
typedef GoInt64 GoInt;
|
|
55
|
+
typedef GoUint64 GoUint;
|
|
56
|
+
typedef size_t GoUintptr;
|
|
57
|
+
typedef float GoFloat32;
|
|
58
|
+
typedef double GoFloat64;
|
|
59
|
+
#ifdef _MSC_VER
|
|
60
|
+
#include <complex.h>
|
|
61
|
+
typedef _Fcomplex GoComplex64;
|
|
62
|
+
typedef _Dcomplex GoComplex128;
|
|
63
|
+
#else
|
|
64
|
+
typedef float _Complex GoComplex64;
|
|
65
|
+
typedef double _Complex GoComplex128;
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
static assertion to make sure the file is being used on architecture
|
|
70
|
+
at least with matching size of GoInt.
|
|
71
|
+
*/
|
|
72
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
73
|
+
|
|
74
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
75
|
+
typedef _GoString_ GoString;
|
|
76
|
+
#endif
|
|
77
|
+
typedef void *GoMap;
|
|
78
|
+
typedef void *GoChan;
|
|
79
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
80
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
81
|
+
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
/* End of boilerplate cgo prologue. */
|
|
85
|
+
|
|
86
|
+
#ifdef __cplusplus
|
|
87
|
+
extern "C" {
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
extern char* navigateBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
91
|
+
extern char* isUniqueBtree(char* payload);
|
|
92
|
+
|
|
93
|
+
/* Return type for getFromBtree */
|
|
94
|
+
struct getFromBtree_return {
|
|
95
|
+
char* r0;
|
|
96
|
+
char* r1;
|
|
97
|
+
};
|
|
98
|
+
extern struct getFromBtree_return getFromBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
99
|
+
|
|
100
|
+
/* Return type for getBtreeItemCount */
|
|
101
|
+
struct getBtreeItemCount_return {
|
|
102
|
+
long long r0;
|
|
103
|
+
char* r1;
|
|
104
|
+
};
|
|
105
|
+
extern struct getBtreeItemCount_return getBtreeItemCount(char* payload);
|
|
106
|
+
extern long long createContext();
|
|
107
|
+
extern void cancelContext(long long ctxID);
|
|
108
|
+
extern void removeContext(long long ctxID);
|
|
109
|
+
|
|
110
|
+
// Redis global connection management related.
|
|
111
|
+
//
|
|
112
|
+
extern char* openRedisConnection(char* host, int port, char* password);
|
|
113
|
+
extern char* closeRedisConnection();
|
|
114
|
+
extern char* manageTransaction(long long ctxID, int action, char* payload);
|
|
115
|
+
extern void freeString(char* cString);
|
|
116
|
+
extern char* manageBtree(long long ctxID, int action, char* payload, char* payload2);
|
|
117
|
+
|
|
118
|
+
#ifdef __cplusplus
|
|
119
|
+
}
|
|
120
|
+
#endif
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package command-line-arguments */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/* Start of preamble from import "C" comments. */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#line 3 "jsondb_main.go"
|
|
24
|
+
|
|
25
|
+
#include <stdio.h> // C.longlong
|
|
26
|
+
#include <stdlib.h> // For free
|
|
27
|
+
|
|
28
|
+
#line 1 "cgo-generated-wrapper"
|
|
29
|
+
|
|
30
|
+
#line 3 "jsondb_manage_btree.go"
|
|
31
|
+
|
|
32
|
+
#include <stdlib.h> // For free
|
|
33
|
+
|
|
34
|
+
#line 1 "cgo-generated-wrapper"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* End of preamble from import "C" comments. */
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/* Start of boilerplate cgo prologue. */
|
|
41
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
42
|
+
|
|
43
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
44
|
+
#define GO_CGO_PROLOGUE_H
|
|
45
|
+
|
|
46
|
+
typedef signed char GoInt8;
|
|
47
|
+
typedef unsigned char GoUint8;
|
|
48
|
+
typedef short GoInt16;
|
|
49
|
+
typedef unsigned short GoUint16;
|
|
50
|
+
typedef int GoInt32;
|
|
51
|
+
typedef unsigned int GoUint32;
|
|
52
|
+
typedef long long GoInt64;
|
|
53
|
+
typedef unsigned long long GoUint64;
|
|
54
|
+
typedef GoInt64 GoInt;
|
|
55
|
+
typedef GoUint64 GoUint;
|
|
56
|
+
typedef size_t GoUintptr;
|
|
57
|
+
typedef float GoFloat32;
|
|
58
|
+
typedef double GoFloat64;
|
|
59
|
+
#ifdef _MSC_VER
|
|
60
|
+
#include <complex.h>
|
|
61
|
+
typedef _Fcomplex GoComplex64;
|
|
62
|
+
typedef _Dcomplex GoComplex128;
|
|
63
|
+
#else
|
|
64
|
+
typedef float _Complex GoComplex64;
|
|
65
|
+
typedef double _Complex GoComplex128;
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
static assertion to make sure the file is being used on architecture
|
|
70
|
+
at least with matching size of GoInt.
|
|
71
|
+
*/
|
|
72
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
73
|
+
|
|
74
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
75
|
+
typedef _GoString_ GoString;
|
|
76
|
+
#endif
|
|
77
|
+
typedef void *GoMap;
|
|
78
|
+
typedef void *GoChan;
|
|
79
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
80
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
81
|
+
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
/* End of boilerplate cgo prologue. */
|
|
85
|
+
|
|
86
|
+
#ifdef __cplusplus
|
|
87
|
+
extern "C" {
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
extern __declspec(dllexport) char* navigateBtree(long long int ctxID, int action, char* payload, char* payload2);
|
|
91
|
+
extern __declspec(dllexport) char* isUniqueBtree(char* payload);
|
|
92
|
+
|
|
93
|
+
/* Return type for getFromBtree */
|
|
94
|
+
struct getFromBtree_return {
|
|
95
|
+
char* r0;
|
|
96
|
+
char* r1;
|
|
97
|
+
};
|
|
98
|
+
extern __declspec(dllexport) struct getFromBtree_return getFromBtree(long long int ctxID, int action, char* payload, char* payload2);
|
|
99
|
+
|
|
100
|
+
/* Return type for getBtreeItemCount */
|
|
101
|
+
struct getBtreeItemCount_return {
|
|
102
|
+
long long int r0;
|
|
103
|
+
char* r1;
|
|
104
|
+
};
|
|
105
|
+
extern __declspec(dllexport) struct getBtreeItemCount_return getBtreeItemCount(char* payload);
|
|
106
|
+
extern __declspec(dllexport) long long int createContext();
|
|
107
|
+
extern __declspec(dllexport) void cancelContext(long long int ctxID);
|
|
108
|
+
extern __declspec(dllexport) void removeContext(long long int ctxID);
|
|
109
|
+
|
|
110
|
+
// Redis global connection management related.
|
|
111
|
+
//
|
|
112
|
+
extern __declspec(dllexport) char* openRedisConnection(char* host, int port, char* password);
|
|
113
|
+
extern __declspec(dllexport) char* closeRedisConnection();
|
|
114
|
+
extern __declspec(dllexport) char* manageTransaction(long long int ctxID, int action, char* payload);
|
|
115
|
+
extern __declspec(dllexport) void freeString(char* cString);
|
|
116
|
+
extern __declspec(dllexport) char* manageBtree(long long int ctxID, int action, char* payload, char* payload2);
|
|
117
|
+
|
|
118
|
+
#ifdef __cplusplus
|
|
119
|
+
}
|
|
120
|
+
#endif
|
|
Binary file
|