isomorfeus-hamster 0.6.0
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.
- checksums.yaml +7 -0
- data/LICENSE +98 -0
- data/README.md +7 -0
- data/ext/isomorfeus_hamster_ext/cursor_delete_flags.h +1 -0
- data/ext/isomorfeus_hamster_ext/cursor_put_flags.h +2 -0
- data/ext/isomorfeus_hamster_ext/dbi_flags.h +7 -0
- data/ext/isomorfeus_hamster_ext/env_flags.h +11 -0
- data/ext/isomorfeus_hamster_ext/errors.h +21 -0
- data/ext/isomorfeus_hamster_ext/extconf.rb +22 -0
- data/ext/isomorfeus_hamster_ext/flag_parser.h +14 -0
- data/ext/isomorfeus_hamster_ext/isomorfeus_hamster.c +1598 -0
- data/ext/isomorfeus_hamster_ext/isomorfeus_hamster.h +164 -0
- data/ext/isomorfeus_hamster_ext/lmdb/.gitignore +16 -0
- data/ext/isomorfeus_hamster_ext/lmdb/COPYRIGHT +20 -0
- data/ext/isomorfeus_hamster_ext/lmdb/LICENSE +47 -0
- data/ext/isomorfeus_hamster_ext/lmdb/lmdb.h +1653 -0
- data/ext/isomorfeus_hamster_ext/lmdb/mdb.c +11349 -0
- data/ext/isomorfeus_hamster_ext/lmdb/midl.c +421 -0
- data/ext/isomorfeus_hamster_ext/lmdb/midl.h +200 -0
- data/ext/isomorfeus_hamster_ext/prototypes.sh +4 -0
- data/ext/isomorfeus_hamster_ext/put_flags.h +5 -0
- data/lib/isomorfeus/hamster/database.rb +137 -0
- data/lib/isomorfeus/hamster/marshal.rb +63 -0
- data/lib/isomorfeus/hamster/version.rb +5 -0
- data/lib/isomorfeus-hamster.rb +4 -0
- metadata +125 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
#ifndef _LMDB_EXT_H
|
2
|
+
#define _LMDB_EXT_H
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
#include "lmdb.h"
|
6
|
+
|
7
|
+
// Ruby 1.8 compatibility
|
8
|
+
#ifndef SIZET2NUM
|
9
|
+
# if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
|
10
|
+
# define SIZET2NUM(v) ULL2NUM(v)
|
11
|
+
# elif SIZEOF_SIZE_T == SIZEOF_LONG
|
12
|
+
# define SIZET2NUM(v) ULONG2NUM(v)
|
13
|
+
# else
|
14
|
+
# define SIZET2NUM(v) UINT2NUM(v)
|
15
|
+
# endif
|
16
|
+
#endif
|
17
|
+
|
18
|
+
// Ruby 1.8 compatibility
|
19
|
+
#ifndef NUM2SSIZET
|
20
|
+
# if defined(HAVE_LONG_LONG) && SIZEOF_SIZE_T > SIZEOF_LONG
|
21
|
+
# define NUM2SSIZET(x) ((ssize_t)NUM2LL(x))
|
22
|
+
#else
|
23
|
+
# define NUM2SSIZET(x) NUM2LONG(x)
|
24
|
+
# endif
|
25
|
+
#endif
|
26
|
+
|
27
|
+
// Ruby 2.0 compatibility
|
28
|
+
#ifndef RARRAY_AREF
|
29
|
+
# define RARRAY_AREF(ary,n) (RARRAY_PTR(ary)[n])
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#define ENVIRONMENT(var, var_env) \
|
33
|
+
Environment* var_env; \
|
34
|
+
Data_Get_Struct(var, Environment, var_env); \
|
35
|
+
environment_check(var_env)
|
36
|
+
|
37
|
+
#define DATABASE(var, var_db) \
|
38
|
+
Database* var_db; \
|
39
|
+
Data_Get_Struct(var, Database, var_db);
|
40
|
+
|
41
|
+
#define TRANSACTION(var, var_txn) \
|
42
|
+
Transaction* var_txn; \
|
43
|
+
Data_Get_Struct(var, Transaction, var_txn)
|
44
|
+
|
45
|
+
#define CURSOR(var, var_cur) \
|
46
|
+
Cursor* var_cur; \
|
47
|
+
Data_Get_Struct(var, Cursor, var_cur); \
|
48
|
+
cursor_check(var_cur)
|
49
|
+
|
50
|
+
typedef struct {
|
51
|
+
VALUE env;
|
52
|
+
VALUE parent;
|
53
|
+
VALUE thread;
|
54
|
+
VALUE cursors;
|
55
|
+
MDB_txn* txn;
|
56
|
+
} Transaction;
|
57
|
+
|
58
|
+
typedef struct {
|
59
|
+
MDB_env* env;
|
60
|
+
VALUE thread_txn_hash;
|
61
|
+
VALUE txn_thread_hash;
|
62
|
+
} Environment;
|
63
|
+
|
64
|
+
typedef struct {
|
65
|
+
VALUE env;
|
66
|
+
MDB_dbi dbi;
|
67
|
+
} Database;
|
68
|
+
|
69
|
+
typedef struct {
|
70
|
+
VALUE db;
|
71
|
+
MDB_cursor* cur;
|
72
|
+
} Cursor;
|
73
|
+
|
74
|
+
typedef struct {
|
75
|
+
VALUE self;
|
76
|
+
const char* name;
|
77
|
+
int argc;
|
78
|
+
const VALUE* argv;
|
79
|
+
} HelperArgs;
|
80
|
+
|
81
|
+
typedef struct {
|
82
|
+
mode_t mode;
|
83
|
+
int flags;
|
84
|
+
int maxreaders;
|
85
|
+
int maxdbs;
|
86
|
+
size_t mapsize;
|
87
|
+
} EnvironmentOptions;
|
88
|
+
|
89
|
+
typedef struct {
|
90
|
+
MDB_env *env;
|
91
|
+
MDB_txn *parent;
|
92
|
+
unsigned int flags;
|
93
|
+
MDB_txn **htxn;
|
94
|
+
int result;
|
95
|
+
int stop;
|
96
|
+
} TxnArgs;
|
97
|
+
|
98
|
+
static VALUE cEnvironment, cDatabase, cTransaction, cCursor, cError;
|
99
|
+
|
100
|
+
#define OB_ERROR(name) static VALUE cError_##name;
|
101
|
+
#include "errors.h"
|
102
|
+
#undef OB_ERROR
|
103
|
+
|
104
|
+
// BEGIN PROTOTYPES
|
105
|
+
void Init_lmdb_ext();
|
106
|
+
static MDB_txn* active_txn(VALUE self);
|
107
|
+
static VALUE call_with_transaction(VALUE venv, VALUE self, const char* name, int argc, const VALUE* argv, int flags);
|
108
|
+
static VALUE call_with_transaction_helper(VALUE arg);
|
109
|
+
static void check(int code);
|
110
|
+
static void cursor_check(Cursor* cursor);
|
111
|
+
static VALUE cursor_close(VALUE self);
|
112
|
+
static VALUE cursor_count(VALUE self);
|
113
|
+
static VALUE cursor_delete(int argc, VALUE *argv, VALUE self);
|
114
|
+
static VALUE cursor_first(VALUE self);
|
115
|
+
static void cursor_free(Cursor* cursor);
|
116
|
+
static VALUE cursor_get(VALUE self);
|
117
|
+
static VALUE cursor_last(VALUE self);
|
118
|
+
static void cursor_mark(Cursor* cursor);
|
119
|
+
static VALUE cursor_next(int argc, VALUE* argv, VALUE self);
|
120
|
+
static VALUE cursor_prev(VALUE self);
|
121
|
+
static VALUE cursor_put(int argc, VALUE* argv, VALUE self);
|
122
|
+
static VALUE cursor_set(int argc, VALUE* argv, VALUE self);
|
123
|
+
static VALUE cursor_set_range(VALUE self, VALUE vkey);
|
124
|
+
static VALUE database_clear(VALUE self);
|
125
|
+
static VALUE database_cursor(VALUE self);
|
126
|
+
static VALUE database_delete(int argc, VALUE *argv, VALUE self);
|
127
|
+
static VALUE database_drop(VALUE self);
|
128
|
+
static VALUE database_get(VALUE self, VALUE vkey);
|
129
|
+
static void database_mark(Database* database);
|
130
|
+
static VALUE database_put(int argc, VALUE *argv, VALUE self);
|
131
|
+
static VALUE database_stat(VALUE self);
|
132
|
+
static VALUE database_get_flags(VALUE self);
|
133
|
+
static VALUE database_is_dupsort(VALUE self);
|
134
|
+
static VALUE database_is_dupfixed(VALUE self);
|
135
|
+
static VALUE environment_active_txn(VALUE self);
|
136
|
+
static VALUE environment_change_flags(int argc, VALUE* argv, VALUE self, int set);
|
137
|
+
static void environment_check(Environment* environment);
|
138
|
+
static VALUE environment_clear_flags(int argc, VALUE* argv, VALUE self);
|
139
|
+
static VALUE environment_close(VALUE self);
|
140
|
+
static VALUE environment_copy(VALUE self, VALUE path);
|
141
|
+
static VALUE environment_database(int argc, VALUE *argv, VALUE self);
|
142
|
+
static VALUE environment_flags(VALUE self);
|
143
|
+
static void environment_free(Environment *environment);
|
144
|
+
static VALUE environment_info(VALUE self);
|
145
|
+
static void environment_mark(Environment* environment);
|
146
|
+
static VALUE environment_new(int argc, VALUE *argv, VALUE klass);
|
147
|
+
static int environment_options(VALUE key, VALUE value, EnvironmentOptions* options);
|
148
|
+
static VALUE environment_path(VALUE self);
|
149
|
+
static void environment_set_active_txn(VALUE self, VALUE thread, VALUE txn);
|
150
|
+
static VALUE environment_set_flags(int argc, VALUE* argv, VALUE self);
|
151
|
+
static VALUE environment_stat(VALUE self);
|
152
|
+
static VALUE environment_sync(int argc, VALUE *argv, VALUE self);
|
153
|
+
static VALUE environment_transaction(int argc, VALUE *argv, VALUE self);
|
154
|
+
static MDB_txn* need_txn(VALUE self);
|
155
|
+
static VALUE stat2hash(const MDB_stat* stat);
|
156
|
+
static VALUE transaction_abort(VALUE self);
|
157
|
+
static VALUE transaction_commit(VALUE self);
|
158
|
+
static void transaction_finish(VALUE self, int commit);
|
159
|
+
static void transaction_free(Transaction* transaction);
|
160
|
+
static void transaction_mark(Transaction* transaction);
|
161
|
+
static VALUE with_transaction(VALUE venv, VALUE(*fn)(VALUE), VALUE arg, int flags);
|
162
|
+
// END PROTOTYPES
|
163
|
+
|
164
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011-2021 Howard Chu, Symas Corp.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted only as authorized by the OpenLDAP
|
6
|
+
Public License.
|
7
|
+
|
8
|
+
A copy of this license is available in the file LICENSE in the
|
9
|
+
top-level directory of the distribution or, alternatively, at
|
10
|
+
<http://www.OpenLDAP.org/license.html>.
|
11
|
+
|
12
|
+
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
|
13
|
+
|
14
|
+
Individual files and/or contributed packages may be copyright by
|
15
|
+
other parties and/or subject to additional restrictions.
|
16
|
+
|
17
|
+
This work also contains materials derived from public sources.
|
18
|
+
|
19
|
+
Additional information about OpenLDAP can be obtained at
|
20
|
+
<http://www.openldap.org/>.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
The OpenLDAP Public License
|
2
|
+
Version 2.8, 17 August 2003
|
3
|
+
|
4
|
+
Redistribution and use of this software and associated documentation
|
5
|
+
("Software"), with or without modification, are permitted provided
|
6
|
+
that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions in source form must retain copyright statements
|
9
|
+
and notices,
|
10
|
+
|
11
|
+
2. Redistributions in binary form must reproduce applicable copyright
|
12
|
+
statements and notices, this list of conditions, and the following
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
14
|
+
with the distribution, and
|
15
|
+
|
16
|
+
3. Redistributions must contain a verbatim copy of this document.
|
17
|
+
|
18
|
+
The OpenLDAP Foundation may revise this license from time to time.
|
19
|
+
Each revision is distinguished by a version number. You may use
|
20
|
+
this Software under terms of this license revision or under the
|
21
|
+
terms of any subsequent revision of the license.
|
22
|
+
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
|
24
|
+
CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
25
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
26
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
27
|
+
SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
|
28
|
+
OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
29
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
30
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
31
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
32
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
33
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
34
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
35
|
+
POSSIBILITY OF SUCH DAMAGE.
|
36
|
+
|
37
|
+
The names of the authors and copyright holders must not be used in
|
38
|
+
advertising or otherwise to promote the sale, use or other dealing
|
39
|
+
in this Software without specific, written prior permission. Title
|
40
|
+
to copyright in this Software shall at all times remain with copyright
|
41
|
+
holders.
|
42
|
+
|
43
|
+
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
|
44
|
+
|
45
|
+
Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
|
46
|
+
California, USA. All Rights Reserved. Permission to copy and
|
47
|
+
distribute verbatim copies of this document is granted.
|