hyperdex 1.4.5.1.gc197953
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.
- data/ext/client.c +975 -0
- data/ext/definitions.c +1258 -0
- data/ext/depend +1 -0
- data/ext/extconf.rb +10 -0
- data/ext/hyperdex.c +42 -0
- data/ext/prototypes.c +163 -0
- data/lib/ffi/monkey_patches.rb +10 -0
- data/lib/hyperdex.rb +25 -0
- data/lib/hyperdex/admin.rb +4 -0
- data/lib/hyperdex/admin/client.rb +71 -0
- data/lib/hyperdex/admin/exception.rb +11 -0
- data/lib/hyperdex/client.rb +377 -0
- data/lib/hyperdex/client/client.rb +45 -0
- data/lib/hyperdex/client/deferred.rb +8 -0
- data/lib/hyperdex/client/hyperdex_client_exception.rb +9 -0
- data/lib/hyperdex/client/iterator.rb +30 -0
- data/lib/hyperdex/client/response.rb +70 -0
- data/lib/hyperdex/ffi.rb +5 -0
- data/lib/hyperdex/ffi/admin.rb +53 -0
- data/lib/hyperdex/ffi/client.rb +44 -0
- data/lib/hyperdex/ffi/ds.rb +82 -0
- metadata +281 -0
data/ext/depend
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
client.o: definitions.c prototypes.c
|
data/ext/extconf.rb
ADDED
data/ext/hyperdex.c
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
/* Copyright (c) 2013, Cornell University
|
2
|
+
* All rights reserved.
|
3
|
+
*
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
5
|
+
* modification, are permitted provided that the following conditions are met:
|
6
|
+
*
|
7
|
+
* * Redistributions of source code must retain the above copyright notice,
|
8
|
+
* this list of conditions and the following disclaimer.
|
9
|
+
* * Redistributions in binary form must reproduce the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer in the
|
11
|
+
* documentation and/or other materials provided with the distribution.
|
12
|
+
* * Neither the name of HyperDex nor the names of its contributors may be
|
13
|
+
* used to endorse or promote products derived from this software without
|
14
|
+
* specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
/* Ruby */
|
30
|
+
#include <ruby/ruby.h>
|
31
|
+
|
32
|
+
VALUE mod_hyperdex;
|
33
|
+
|
34
|
+
void Init_hyperdex_client(void);
|
35
|
+
|
36
|
+
void
|
37
|
+
Init__hyperdex()
|
38
|
+
{
|
39
|
+
mod_hyperdex = rb_define_module("HyperDex");
|
40
|
+
|
41
|
+
Init_hyperdex_client();
|
42
|
+
};
|
data/ext/prototypes.c
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
/* Copyright (c) 2013-2014, Cornell University
|
2
|
+
* All rights reserved.
|
3
|
+
*
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
5
|
+
* modification, are permitted provided that the following conditions are met:
|
6
|
+
*
|
7
|
+
* * Redistributions of source code must retain the above copyright notice,
|
8
|
+
* this list of conditions and the following disclaimer.
|
9
|
+
* * Redistributions in binary form must reproduce the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer in the
|
11
|
+
* documentation and/or other materials provided with the distribution.
|
12
|
+
* * Neither the name of HyperDex nor the names of its contributors may be
|
13
|
+
* used to endorse or promote products derived from this software without
|
14
|
+
* specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
20
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
/* This file is generated by bindings/ruby.py */
|
29
|
+
|
30
|
+
rb_define_method(class_client, "async_get", hyperdex_ruby_client_get, 2);
|
31
|
+
rb_define_method(class_client, "get", hyperdex_ruby_client_wait_get, 2);
|
32
|
+
rb_define_method(class_client, "async_get_partial", hyperdex_ruby_client_get_partial, 3);
|
33
|
+
rb_define_method(class_client, "get_partial", hyperdex_ruby_client_wait_get_partial, 3);
|
34
|
+
rb_define_method(class_client, "async_put", hyperdex_ruby_client_put, 3);
|
35
|
+
rb_define_method(class_client, "put", hyperdex_ruby_client_wait_put, 3);
|
36
|
+
rb_define_method(class_client, "async_cond_put", hyperdex_ruby_client_cond_put, 4);
|
37
|
+
rb_define_method(class_client, "cond_put", hyperdex_ruby_client_wait_cond_put, 4);
|
38
|
+
rb_define_method(class_client, "async_put_if_not_exist", hyperdex_ruby_client_put_if_not_exist, 3);
|
39
|
+
rb_define_method(class_client, "put_if_not_exist", hyperdex_ruby_client_wait_put_if_not_exist, 3);
|
40
|
+
rb_define_method(class_client, "async_del", hyperdex_ruby_client_del, 2);
|
41
|
+
rb_define_method(class_client, "del", hyperdex_ruby_client_wait_del, 2);
|
42
|
+
rb_define_method(class_client, "async_cond_del", hyperdex_ruby_client_cond_del, 3);
|
43
|
+
rb_define_method(class_client, "cond_del", hyperdex_ruby_client_wait_cond_del, 3);
|
44
|
+
rb_define_method(class_client, "async_atomic_add", hyperdex_ruby_client_atomic_add, 3);
|
45
|
+
rb_define_method(class_client, "atomic_add", hyperdex_ruby_client_wait_atomic_add, 3);
|
46
|
+
rb_define_method(class_client, "async_cond_atomic_add", hyperdex_ruby_client_cond_atomic_add, 4);
|
47
|
+
rb_define_method(class_client, "cond_atomic_add", hyperdex_ruby_client_wait_cond_atomic_add, 4);
|
48
|
+
rb_define_method(class_client, "async_atomic_sub", hyperdex_ruby_client_atomic_sub, 3);
|
49
|
+
rb_define_method(class_client, "atomic_sub", hyperdex_ruby_client_wait_atomic_sub, 3);
|
50
|
+
rb_define_method(class_client, "async_cond_atomic_sub", hyperdex_ruby_client_cond_atomic_sub, 4);
|
51
|
+
rb_define_method(class_client, "cond_atomic_sub", hyperdex_ruby_client_wait_cond_atomic_sub, 4);
|
52
|
+
rb_define_method(class_client, "async_atomic_mul", hyperdex_ruby_client_atomic_mul, 3);
|
53
|
+
rb_define_method(class_client, "atomic_mul", hyperdex_ruby_client_wait_atomic_mul, 3);
|
54
|
+
rb_define_method(class_client, "async_cond_atomic_mul", hyperdex_ruby_client_cond_atomic_mul, 4);
|
55
|
+
rb_define_method(class_client, "cond_atomic_mul", hyperdex_ruby_client_wait_cond_atomic_mul, 4);
|
56
|
+
rb_define_method(class_client, "async_atomic_div", hyperdex_ruby_client_atomic_div, 3);
|
57
|
+
rb_define_method(class_client, "atomic_div", hyperdex_ruby_client_wait_atomic_div, 3);
|
58
|
+
rb_define_method(class_client, "async_cond_atomic_div", hyperdex_ruby_client_cond_atomic_div, 4);
|
59
|
+
rb_define_method(class_client, "cond_atomic_div", hyperdex_ruby_client_wait_cond_atomic_div, 4);
|
60
|
+
rb_define_method(class_client, "async_atomic_mod", hyperdex_ruby_client_atomic_mod, 3);
|
61
|
+
rb_define_method(class_client, "atomic_mod", hyperdex_ruby_client_wait_atomic_mod, 3);
|
62
|
+
rb_define_method(class_client, "async_cond_atomic_mod", hyperdex_ruby_client_cond_atomic_mod, 4);
|
63
|
+
rb_define_method(class_client, "cond_atomic_mod", hyperdex_ruby_client_wait_cond_atomic_mod, 4);
|
64
|
+
rb_define_method(class_client, "async_atomic_and", hyperdex_ruby_client_atomic_and, 3);
|
65
|
+
rb_define_method(class_client, "atomic_and", hyperdex_ruby_client_wait_atomic_and, 3);
|
66
|
+
rb_define_method(class_client, "async_cond_atomic_and", hyperdex_ruby_client_cond_atomic_and, 4);
|
67
|
+
rb_define_method(class_client, "cond_atomic_and", hyperdex_ruby_client_wait_cond_atomic_and, 4);
|
68
|
+
rb_define_method(class_client, "async_atomic_or", hyperdex_ruby_client_atomic_or, 3);
|
69
|
+
rb_define_method(class_client, "atomic_or", hyperdex_ruby_client_wait_atomic_or, 3);
|
70
|
+
rb_define_method(class_client, "async_cond_atomic_or", hyperdex_ruby_client_cond_atomic_or, 4);
|
71
|
+
rb_define_method(class_client, "cond_atomic_or", hyperdex_ruby_client_wait_cond_atomic_or, 4);
|
72
|
+
rb_define_method(class_client, "async_atomic_xor", hyperdex_ruby_client_atomic_xor, 3);
|
73
|
+
rb_define_method(class_client, "atomic_xor", hyperdex_ruby_client_wait_atomic_xor, 3);
|
74
|
+
rb_define_method(class_client, "async_cond_atomic_xor", hyperdex_ruby_client_cond_atomic_xor, 4);
|
75
|
+
rb_define_method(class_client, "cond_atomic_xor", hyperdex_ruby_client_wait_cond_atomic_xor, 4);
|
76
|
+
rb_define_method(class_client, "async_string_prepend", hyperdex_ruby_client_string_prepend, 3);
|
77
|
+
rb_define_method(class_client, "string_prepend", hyperdex_ruby_client_wait_string_prepend, 3);
|
78
|
+
rb_define_method(class_client, "async_cond_string_prepend", hyperdex_ruby_client_cond_string_prepend, 4);
|
79
|
+
rb_define_method(class_client, "cond_string_prepend", hyperdex_ruby_client_wait_cond_string_prepend, 4);
|
80
|
+
rb_define_method(class_client, "async_string_append", hyperdex_ruby_client_string_append, 3);
|
81
|
+
rb_define_method(class_client, "string_append", hyperdex_ruby_client_wait_string_append, 3);
|
82
|
+
rb_define_method(class_client, "async_cond_string_append", hyperdex_ruby_client_cond_string_append, 4);
|
83
|
+
rb_define_method(class_client, "cond_string_append", hyperdex_ruby_client_wait_cond_string_append, 4);
|
84
|
+
rb_define_method(class_client, "async_list_lpush", hyperdex_ruby_client_list_lpush, 3);
|
85
|
+
rb_define_method(class_client, "list_lpush", hyperdex_ruby_client_wait_list_lpush, 3);
|
86
|
+
rb_define_method(class_client, "async_cond_list_lpush", hyperdex_ruby_client_cond_list_lpush, 4);
|
87
|
+
rb_define_method(class_client, "cond_list_lpush", hyperdex_ruby_client_wait_cond_list_lpush, 4);
|
88
|
+
rb_define_method(class_client, "async_list_rpush", hyperdex_ruby_client_list_rpush, 3);
|
89
|
+
rb_define_method(class_client, "list_rpush", hyperdex_ruby_client_wait_list_rpush, 3);
|
90
|
+
rb_define_method(class_client, "async_cond_list_rpush", hyperdex_ruby_client_cond_list_rpush, 4);
|
91
|
+
rb_define_method(class_client, "cond_list_rpush", hyperdex_ruby_client_wait_cond_list_rpush, 4);
|
92
|
+
rb_define_method(class_client, "async_set_add", hyperdex_ruby_client_set_add, 3);
|
93
|
+
rb_define_method(class_client, "set_add", hyperdex_ruby_client_wait_set_add, 3);
|
94
|
+
rb_define_method(class_client, "async_cond_set_add", hyperdex_ruby_client_cond_set_add, 4);
|
95
|
+
rb_define_method(class_client, "cond_set_add", hyperdex_ruby_client_wait_cond_set_add, 4);
|
96
|
+
rb_define_method(class_client, "async_set_remove", hyperdex_ruby_client_set_remove, 3);
|
97
|
+
rb_define_method(class_client, "set_remove", hyperdex_ruby_client_wait_set_remove, 3);
|
98
|
+
rb_define_method(class_client, "async_cond_set_remove", hyperdex_ruby_client_cond_set_remove, 4);
|
99
|
+
rb_define_method(class_client, "cond_set_remove", hyperdex_ruby_client_wait_cond_set_remove, 4);
|
100
|
+
rb_define_method(class_client, "async_set_intersect", hyperdex_ruby_client_set_intersect, 3);
|
101
|
+
rb_define_method(class_client, "set_intersect", hyperdex_ruby_client_wait_set_intersect, 3);
|
102
|
+
rb_define_method(class_client, "async_cond_set_intersect", hyperdex_ruby_client_cond_set_intersect, 4);
|
103
|
+
rb_define_method(class_client, "cond_set_intersect", hyperdex_ruby_client_wait_cond_set_intersect, 4);
|
104
|
+
rb_define_method(class_client, "async_set_union", hyperdex_ruby_client_set_union, 3);
|
105
|
+
rb_define_method(class_client, "set_union", hyperdex_ruby_client_wait_set_union, 3);
|
106
|
+
rb_define_method(class_client, "async_cond_set_union", hyperdex_ruby_client_cond_set_union, 4);
|
107
|
+
rb_define_method(class_client, "cond_set_union", hyperdex_ruby_client_wait_cond_set_union, 4);
|
108
|
+
rb_define_method(class_client, "async_map_add", hyperdex_ruby_client_map_add, 3);
|
109
|
+
rb_define_method(class_client, "map_add", hyperdex_ruby_client_wait_map_add, 3);
|
110
|
+
rb_define_method(class_client, "async_cond_map_add", hyperdex_ruby_client_cond_map_add, 4);
|
111
|
+
rb_define_method(class_client, "cond_map_add", hyperdex_ruby_client_wait_cond_map_add, 4);
|
112
|
+
rb_define_method(class_client, "async_map_remove", hyperdex_ruby_client_map_remove, 3);
|
113
|
+
rb_define_method(class_client, "map_remove", hyperdex_ruby_client_wait_map_remove, 3);
|
114
|
+
rb_define_method(class_client, "async_cond_map_remove", hyperdex_ruby_client_cond_map_remove, 4);
|
115
|
+
rb_define_method(class_client, "cond_map_remove", hyperdex_ruby_client_wait_cond_map_remove, 4);
|
116
|
+
rb_define_method(class_client, "async_map_atomic_add", hyperdex_ruby_client_map_atomic_add, 3);
|
117
|
+
rb_define_method(class_client, "map_atomic_add", hyperdex_ruby_client_wait_map_atomic_add, 3);
|
118
|
+
rb_define_method(class_client, "async_cond_map_atomic_add", hyperdex_ruby_client_cond_map_atomic_add, 4);
|
119
|
+
rb_define_method(class_client, "cond_map_atomic_add", hyperdex_ruby_client_wait_cond_map_atomic_add, 4);
|
120
|
+
rb_define_method(class_client, "async_map_atomic_sub", hyperdex_ruby_client_map_atomic_sub, 3);
|
121
|
+
rb_define_method(class_client, "map_atomic_sub", hyperdex_ruby_client_wait_map_atomic_sub, 3);
|
122
|
+
rb_define_method(class_client, "async_cond_map_atomic_sub", hyperdex_ruby_client_cond_map_atomic_sub, 4);
|
123
|
+
rb_define_method(class_client, "cond_map_atomic_sub", hyperdex_ruby_client_wait_cond_map_atomic_sub, 4);
|
124
|
+
rb_define_method(class_client, "async_map_atomic_mul", hyperdex_ruby_client_map_atomic_mul, 3);
|
125
|
+
rb_define_method(class_client, "map_atomic_mul", hyperdex_ruby_client_wait_map_atomic_mul, 3);
|
126
|
+
rb_define_method(class_client, "async_cond_map_atomic_mul", hyperdex_ruby_client_cond_map_atomic_mul, 4);
|
127
|
+
rb_define_method(class_client, "cond_map_atomic_mul", hyperdex_ruby_client_wait_cond_map_atomic_mul, 4);
|
128
|
+
rb_define_method(class_client, "async_map_atomic_div", hyperdex_ruby_client_map_atomic_div, 3);
|
129
|
+
rb_define_method(class_client, "map_atomic_div", hyperdex_ruby_client_wait_map_atomic_div, 3);
|
130
|
+
rb_define_method(class_client, "async_cond_map_atomic_div", hyperdex_ruby_client_cond_map_atomic_div, 4);
|
131
|
+
rb_define_method(class_client, "cond_map_atomic_div", hyperdex_ruby_client_wait_cond_map_atomic_div, 4);
|
132
|
+
rb_define_method(class_client, "async_map_atomic_mod", hyperdex_ruby_client_map_atomic_mod, 3);
|
133
|
+
rb_define_method(class_client, "map_atomic_mod", hyperdex_ruby_client_wait_map_atomic_mod, 3);
|
134
|
+
rb_define_method(class_client, "async_cond_map_atomic_mod", hyperdex_ruby_client_cond_map_atomic_mod, 4);
|
135
|
+
rb_define_method(class_client, "cond_map_atomic_mod", hyperdex_ruby_client_wait_cond_map_atomic_mod, 4);
|
136
|
+
rb_define_method(class_client, "async_map_atomic_and", hyperdex_ruby_client_map_atomic_and, 3);
|
137
|
+
rb_define_method(class_client, "map_atomic_and", hyperdex_ruby_client_wait_map_atomic_and, 3);
|
138
|
+
rb_define_method(class_client, "async_cond_map_atomic_and", hyperdex_ruby_client_cond_map_atomic_and, 4);
|
139
|
+
rb_define_method(class_client, "cond_map_atomic_and", hyperdex_ruby_client_wait_cond_map_atomic_and, 4);
|
140
|
+
rb_define_method(class_client, "async_map_atomic_or", hyperdex_ruby_client_map_atomic_or, 3);
|
141
|
+
rb_define_method(class_client, "map_atomic_or", hyperdex_ruby_client_wait_map_atomic_or, 3);
|
142
|
+
rb_define_method(class_client, "async_cond_map_atomic_or", hyperdex_ruby_client_cond_map_atomic_or, 4);
|
143
|
+
rb_define_method(class_client, "cond_map_atomic_or", hyperdex_ruby_client_wait_cond_map_atomic_or, 4);
|
144
|
+
rb_define_method(class_client, "async_map_atomic_xor", hyperdex_ruby_client_map_atomic_xor, 3);
|
145
|
+
rb_define_method(class_client, "map_atomic_xor", hyperdex_ruby_client_wait_map_atomic_xor, 3);
|
146
|
+
rb_define_method(class_client, "async_cond_map_atomic_xor", hyperdex_ruby_client_cond_map_atomic_xor, 4);
|
147
|
+
rb_define_method(class_client, "cond_map_atomic_xor", hyperdex_ruby_client_wait_cond_map_atomic_xor, 4);
|
148
|
+
rb_define_method(class_client, "async_map_string_prepend", hyperdex_ruby_client_map_string_prepend, 3);
|
149
|
+
rb_define_method(class_client, "map_string_prepend", hyperdex_ruby_client_wait_map_string_prepend, 3);
|
150
|
+
rb_define_method(class_client, "async_cond_map_string_prepend", hyperdex_ruby_client_cond_map_string_prepend, 4);
|
151
|
+
rb_define_method(class_client, "cond_map_string_prepend", hyperdex_ruby_client_wait_cond_map_string_prepend, 4);
|
152
|
+
rb_define_method(class_client, "async_map_string_append", hyperdex_ruby_client_map_string_append, 3);
|
153
|
+
rb_define_method(class_client, "map_string_append", hyperdex_ruby_client_wait_map_string_append, 3);
|
154
|
+
rb_define_method(class_client, "async_cond_map_string_append", hyperdex_ruby_client_cond_map_string_append, 4);
|
155
|
+
rb_define_method(class_client, "cond_map_string_append", hyperdex_ruby_client_wait_cond_map_string_append, 4);
|
156
|
+
rb_define_method(class_client, "search", hyperdex_ruby_client_search, 2);
|
157
|
+
rb_define_method(class_client, "async_search_describe", hyperdex_ruby_client_search_describe, 2);
|
158
|
+
rb_define_method(class_client, "search_describe", hyperdex_ruby_client_wait_search_describe, 2);
|
159
|
+
rb_define_method(class_client, "sorted_search", hyperdex_ruby_client_sorted_search, 5);
|
160
|
+
rb_define_method(class_client, "async_group_del", hyperdex_ruby_client_group_del, 2);
|
161
|
+
rb_define_method(class_client, "group_del", hyperdex_ruby_client_wait_group_del, 2);
|
162
|
+
rb_define_method(class_client, "async_count", hyperdex_ruby_client_count, 2);
|
163
|
+
rb_define_method(class_client, "count", hyperdex_ruby_client_wait_count, 2);
|
data/lib/hyperdex.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require '_hyperdex'
|
2
|
+
|
3
|
+
module HyperDex; end
|
4
|
+
|
5
|
+
require_relative 'hyperdex/ffi'
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module HyperDex
|
10
|
+
def self.init_ds_iterator(type, value)
|
11
|
+
::FFI::MemoryPointer.new(HyperDex::FFI::DS::DsIterator, 1).tap do |iter|
|
12
|
+
HyperDex::FFI::DS.iterator_init(iter,
|
13
|
+
type,
|
14
|
+
::FFI::MemoryPointer.from_string(value),
|
15
|
+
value.length
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
DataType = Module.new
|
21
|
+
HyperDex::FFI::DS.enum_type(:hyperdatatype).set_consts(DataType)
|
22
|
+
end
|
23
|
+
|
24
|
+
require_relative 'hyperdex/admin'
|
25
|
+
require_relative 'hyperdex/client'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class HyperDex::Admin::Client
|
2
|
+
attr_reader :host, :port
|
3
|
+
|
4
|
+
def initialize(host = 'localhost', port = 1982)
|
5
|
+
@host = host
|
6
|
+
@port = port
|
7
|
+
@client = ::FFI::AutoPointer.new(
|
8
|
+
HyperDex::FFI::Admin.create(
|
9
|
+
::FFI::MemoryPointer.from_string(host),
|
10
|
+
port
|
11
|
+
),
|
12
|
+
proc { |p| HyperDex::FFI::Admin.destroy(p) }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_spaces
|
17
|
+
ptr = ::FFI::MemoryPointer.new(:pointer)
|
18
|
+
|
19
|
+
make_request(:list_spaces, :rc, ptr)
|
20
|
+
|
21
|
+
ptr.read_pointer.read_string.split("\n").map { |s| s.to_sym }
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_space(definition)
|
25
|
+
make_request(
|
26
|
+
:add_space,
|
27
|
+
::FFI::MemoryPointer.from_string(definition.to_s),
|
28
|
+
:rc
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def rm_space(name)
|
33
|
+
make_request(
|
34
|
+
:rm_space,
|
35
|
+
::FFI::MemoryPointer.from_string(name.to_s),
|
36
|
+
:rc
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def make_request(f, *args)
|
42
|
+
rc = ::FFI::MemoryPointer.new(:int)
|
43
|
+
|
44
|
+
# Sigh... not all functions have the returncode as the last arg, so we
|
45
|
+
# need to specify where the rc parameter is in the arg list with this
|
46
|
+
# special symbol.
|
47
|
+
args.map! { |e| (:rc == e) ? rc : e }
|
48
|
+
reqid = HyperDex::FFI::Admin.__send__(f, @client, *args)
|
49
|
+
|
50
|
+
if reqid < 0
|
51
|
+
raise HyperDex::Admin::Exception.new(rc.read_int, "hyperdex_admin_#{f} failed")
|
52
|
+
end
|
53
|
+
|
54
|
+
wait_for_response(reqid)
|
55
|
+
end
|
56
|
+
|
57
|
+
def wait_for_response(reqid)
|
58
|
+
rc = ::FFI::MemoryPointer.new(:int)
|
59
|
+
|
60
|
+
if (ri = HyperDex::FFI::Admin.loop(@client, -1, rc)) != reqid
|
61
|
+
raise HyperDex::Admin::Exception.new(
|
62
|
+
HyperDex::Admin::EXCEPTION,
|
63
|
+
"CAN'T HAPPEN: hyperdex_admin_loop() returned an unknown reqid (expected #{reqid}, got #{ri})"
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
if ri < 0
|
68
|
+
raise HyperDex::Admin::Exception.new(rc.read_int, "hyperdex_admin_loop failed")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class HyperDex::Admin::Exception < StandardError
|
2
|
+
attr_reader :status, :detail
|
3
|
+
|
4
|
+
def initialize(rc, detail)
|
5
|
+
@status = rc
|
6
|
+
@detail = detail
|
7
|
+
|
8
|
+
rc_string = HyperDex::FFI::Admin.returncode_to_string(rc).read_string
|
9
|
+
super("#{rc_string} (#{rc}): #{detail}")
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,377 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'ffi/monkey_patches'
|
3
|
+
require 'ffi/tools/const_generator'
|
4
|
+
|
5
|
+
module HyperDex::Client
|
6
|
+
def self.encode_attributes(attrs, attrs_size)
|
7
|
+
(0..attrs_size-1).inject({}) do |h, i|
|
8
|
+
attr = Attribute.new(attrs[i*Attribute.size])
|
9
|
+
k = attr[:name].read_string.to_sym
|
10
|
+
h.tap { |h| h[k] = build_attribute(attr) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.build_attribute(attr)
|
15
|
+
type = attr[:datatype]
|
16
|
+
value = attr[:value].read_string(attr[:value_sz])
|
17
|
+
|
18
|
+
case type
|
19
|
+
when :STRING
|
20
|
+
value
|
21
|
+
|
22
|
+
when :INT64
|
23
|
+
i = ::FFI::MemoryPointer.new(:int64_t)
|
24
|
+
if HyperDex::FFI::DS.unpack_int(attr[:value], attr[:value_sz], i) < 0
|
25
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
26
|
+
HyperDex::Client::SERVERERROR,
|
27
|
+
"server sent malformed int attribute (#{value.inspect})"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
i.read_int64
|
32
|
+
|
33
|
+
when :FLOAT
|
34
|
+
d = ::FFI::MemoryPointer.new(:double)
|
35
|
+
if HyperDex::FFI::DS.unpack_float(attr[:value], attr[:value_sz], d) < 0
|
36
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
37
|
+
HyperDex::Client::SERVERERROR,
|
38
|
+
"server sent malformed float attribute (#{value.inspect})"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
d.read_double
|
43
|
+
|
44
|
+
when :DOCUMENT
|
45
|
+
begin
|
46
|
+
JSON.parse(value)
|
47
|
+
rescue JSON::ParserError
|
48
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
49
|
+
HyperDex::Client::SERVERERROR,
|
50
|
+
"server sent malformed attribute(document)"
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
when :LIST_STRING
|
55
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
56
|
+
ptr = ::FFI::MemoryPointer.new(:pointer)
|
57
|
+
len = ::FFI::MemoryPointer.new(:size_t)
|
58
|
+
|
59
|
+
res = []
|
60
|
+
while (result = HyperDex::FFI::DS.iterate_list_string_next(iter, ptr, len)) > 0
|
61
|
+
if result < 0
|
62
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
63
|
+
HyperDex::Client::SERVERERROR,
|
64
|
+
"server sent malformed list(string)"
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
str = ptr.read_pointer
|
69
|
+
res << (str.null? ? nil : str.read_string(len.read_size_t))
|
70
|
+
end
|
71
|
+
|
72
|
+
res
|
73
|
+
|
74
|
+
when :LIST_INT64
|
75
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
76
|
+
int = ::FFI::MemoryPointer.new(:int64_t)
|
77
|
+
|
78
|
+
res = []
|
79
|
+
while (result = HyperDex::FFI::DS.iterate_list_int_next(iter, int)) > 0
|
80
|
+
if result < 0
|
81
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
82
|
+
HyperDex::Client::SERVERERROR,
|
83
|
+
"server sent malformed list(int)"
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
res << int.read_int64
|
88
|
+
end
|
89
|
+
|
90
|
+
res
|
91
|
+
|
92
|
+
when :LIST_FLOAT
|
93
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
94
|
+
dbl = ::FFI::MemoryPointer.new(:double)
|
95
|
+
|
96
|
+
res = []
|
97
|
+
while (result = HyperDex::FFI::DS.iterate_list_float_next(iter, dbl)) > 0
|
98
|
+
if result < 0
|
99
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
100
|
+
HyperDex::Client::SERVERERROR,
|
101
|
+
"server sent malformed list(float)"
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
res << dbl.read_double
|
106
|
+
end
|
107
|
+
|
108
|
+
res
|
109
|
+
|
110
|
+
when :SET_STRING
|
111
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
112
|
+
ptr = ::FFI::MemoryPointer.new(:pointer)
|
113
|
+
len = ::FFI::MemoryPointer.new(:size_t)
|
114
|
+
|
115
|
+
res = Set.new
|
116
|
+
while (result = HyperDex::FFI::DS.iterate_set_string_next(iter, ptr, len)) > 0
|
117
|
+
if result < 0
|
118
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
119
|
+
HyperDex::Client::SERVERERROR,
|
120
|
+
"server sent malformed set(string)"
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
str = ptr.read_pointer
|
125
|
+
res << (str.null? ? nil : str.read_string(len.read_size_t))
|
126
|
+
end
|
127
|
+
|
128
|
+
res
|
129
|
+
|
130
|
+
when :SET_INT64
|
131
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
132
|
+
int = ::FFI::MemoryPointer.new(:int64_t)
|
133
|
+
|
134
|
+
res = Set.new
|
135
|
+
while (result = HyperDex::FFI::DS.iterate_set_int_next(iter, int)) > 0
|
136
|
+
if result < 0
|
137
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
138
|
+
HyperDex::Client::SERVERERROR,
|
139
|
+
"server sent malformed set(int)"
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
res << int.read_int64
|
144
|
+
end
|
145
|
+
|
146
|
+
res
|
147
|
+
|
148
|
+
when :SET_FLOAT
|
149
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
150
|
+
dbl = ::FFI::MemoryPointer.new(:double)
|
151
|
+
|
152
|
+
res = Set.new
|
153
|
+
while (result = HyperDex::FFI::DS.iterate_set_float_next(iter, dbl)) > 0
|
154
|
+
if result < 0
|
155
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
156
|
+
HyperDex::Client::SERVERERROR,
|
157
|
+
"server sent malformed set(float)"
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
res << dbl.read_double
|
162
|
+
end
|
163
|
+
|
164
|
+
res
|
165
|
+
|
166
|
+
when :MAP_STRING_STRING
|
167
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
168
|
+
kptr = ::FFI::MemoryPointer.new(:pointer)
|
169
|
+
klen = ::FFI::MemoryPointer.new(:size_t)
|
170
|
+
vptr = ::FFI::MemoryPointer.new(:pointer)
|
171
|
+
vlen = ::FFI::MemoryPointer.new(:size_t)
|
172
|
+
|
173
|
+
res = {}
|
174
|
+
while (result = HyperDex::FFI::DS.iterate_map_string_string_next(iter, kptr, klen, vptr, vlen)) > 0
|
175
|
+
if result < 0
|
176
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
177
|
+
HyperDex::Client::SERVERERROR,
|
178
|
+
"server sent malformed map(string, string)"
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
kstr = kptr.read_pointer
|
183
|
+
kstr = (kstr.null? ? nil : kstr.read_string(klen.read_size_t))
|
184
|
+
vstr = vptr.read_pointer
|
185
|
+
vstr = (vstr.null? ? nil : vstr.read_string(vlen.read_size_t))
|
186
|
+
res[kstr] = vstr
|
187
|
+
end
|
188
|
+
|
189
|
+
res
|
190
|
+
|
191
|
+
when :MAP_STRING_INT64
|
192
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
193
|
+
kptr = ::FFI::MemoryPointer.new(:pointer)
|
194
|
+
klen = ::FFI::MemoryPointer.new(:size_t)
|
195
|
+
vint = ::FFI::MemoryPointer.new(:int64_t)
|
196
|
+
|
197
|
+
res = {}
|
198
|
+
while (result = HyperDex::FFI::DS.iterate_map_string_int_next(iter, kptr, klen, vint)) > 0
|
199
|
+
if result < 0
|
200
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
201
|
+
HyperDex::Client::SERVERERROR,
|
202
|
+
"server sent malformed map(string, int)"
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
206
|
+
kstr = kptr.read_pointer
|
207
|
+
kstr = (kstr.null? ? nil : kstr.read_string(klen.read_size_t))
|
208
|
+
res[kstr] = vint.read_int64
|
209
|
+
end
|
210
|
+
|
211
|
+
res
|
212
|
+
|
213
|
+
when :MAP_STRING_FLOAT
|
214
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
215
|
+
kptr = ::FFI::MemoryPointer.new(:pointer)
|
216
|
+
klen = ::FFI::MemoryPointer.new(:size_t)
|
217
|
+
vdbl = ::FFI::MemoryPointer.new(:double)
|
218
|
+
|
219
|
+
res = {}
|
220
|
+
while (result = HyperDex::FFI::DS.iterate_map_string_float_next(iter, kptr, klen, vdbl)) > 0
|
221
|
+
if result < 0
|
222
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
223
|
+
HyperDex::Client::SERVERERROR,
|
224
|
+
"server sent malformed map(string, float)"
|
225
|
+
)
|
226
|
+
end
|
227
|
+
|
228
|
+
kstr = kptr.read_pointer
|
229
|
+
kstr = (kstr.null? ? nil : kstr.read_string(klen.read_size_t))
|
230
|
+
res[kstr] = vdbl.read_double
|
231
|
+
end
|
232
|
+
|
233
|
+
res
|
234
|
+
|
235
|
+
when :MAP_INT64_STRING
|
236
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
237
|
+
kint = ::FFI::MemoryPointer.new(:int64_t)
|
238
|
+
vptr = ::FFI::MemoryPointer.new(:pointer)
|
239
|
+
vlen = ::FFI::MemoryPointer.new(:size_t)
|
240
|
+
|
241
|
+
res = {}
|
242
|
+
while (result = HyperDex::FFI::DS.iterate_map_int_string_next(iter, kint, vptr, vlen)) > 0
|
243
|
+
if result < 0
|
244
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
245
|
+
HyperDex::Client::SERVERERROR,
|
246
|
+
"server sent malformed map(int, string)"
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
vstr = vptr.read_pointer
|
251
|
+
vstr = (vstr.null? ? nil : vstr.read_string(vlen.read_size_t))
|
252
|
+
res[kint.read_int64] = vstr
|
253
|
+
end
|
254
|
+
|
255
|
+
res
|
256
|
+
|
257
|
+
when :MAP_INT64_INT64
|
258
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
259
|
+
kint = ::FFI::MemoryPointer.new(:int64_t)
|
260
|
+
vint = ::FFI::MemoryPointer.new(:int64_t)
|
261
|
+
|
262
|
+
res = {}
|
263
|
+
while (result = HyperDex::FFI::DS.iterate_map_int_int_next(iter, kint, vint)) > 0
|
264
|
+
if result < 0
|
265
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
266
|
+
HyperDex::Client::SERVERERROR,
|
267
|
+
"server sent malformed map(int, int)"
|
268
|
+
)
|
269
|
+
end
|
270
|
+
|
271
|
+
res[kint.read_int64] = vint.read_int64
|
272
|
+
end
|
273
|
+
|
274
|
+
res
|
275
|
+
|
276
|
+
when :MAP_INT64_FLOAT
|
277
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
278
|
+
kint = ::FFI::MemoryPointer.new(:int64_t)
|
279
|
+
vdbl = ::FFI::MemoryPointer.new(:double)
|
280
|
+
|
281
|
+
res = {}
|
282
|
+
while (result = HyperDex::FFI::DS.iterate_map_int_float_next(iter, kint, vdbl)) > 0
|
283
|
+
if result < 0
|
284
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
285
|
+
HyperDex::Client::SERVERERROR,
|
286
|
+
"server sent malformed map(int, float)"
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
res[kint.read_int64] = vdbl.read_double
|
291
|
+
end
|
292
|
+
|
293
|
+
res
|
294
|
+
|
295
|
+
when :MAP_FLOAT_STRING
|
296
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
297
|
+
kdbl = ::FFI::MemoryPointer.new(:double)
|
298
|
+
vptr = ::FFI::MemoryPointer.new(:pointer)
|
299
|
+
vlen = ::FFI::MemoryPointer.new(:size_t)
|
300
|
+
|
301
|
+
res = {}
|
302
|
+
while (result = HyperDex::FFI::DS.iterate_map_float_string_next(iter, kdbl, vptr, vlen)) > 0
|
303
|
+
if result < 0
|
304
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
305
|
+
HyperDex::Client::SERVERERROR,
|
306
|
+
"server sent malformed map(float, string)"
|
307
|
+
)
|
308
|
+
end
|
309
|
+
|
310
|
+
vstr = vptr.read_pointer
|
311
|
+
vstr = (vstr.null? ? nil : vstr.read_string(vlen.read_size_t))
|
312
|
+
res[kdbl.read_double] = vstr
|
313
|
+
end
|
314
|
+
|
315
|
+
res
|
316
|
+
|
317
|
+
when :MAP_FLOAT_INT64
|
318
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
319
|
+
kdbl = ::FFI::MemoryPointer.new(:double)
|
320
|
+
vint = ::FFI::MemoryPointer.new(:int64_t)
|
321
|
+
|
322
|
+
res = {}
|
323
|
+
while (result = HyperDex::FFI::DS.iterate_map_float_int_next(iter, kdbl, vint)) > 0
|
324
|
+
if result < 0
|
325
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
326
|
+
HyperDex::Client::SERVERERROR,
|
327
|
+
"server sent malformed map(float, int)"
|
328
|
+
)
|
329
|
+
end
|
330
|
+
|
331
|
+
res[kdbl.read_double] = vint.read_int64
|
332
|
+
end
|
333
|
+
|
334
|
+
res
|
335
|
+
|
336
|
+
when :MAP_FLOAT_FLOAT
|
337
|
+
iter = HyperDex.init_ds_iterator(type, value)
|
338
|
+
kdbl = ::FFI::MemoryPointer.new(:double)
|
339
|
+
vdbl = ::FFI::MemoryPointer.new(:double)
|
340
|
+
|
341
|
+
res = {}
|
342
|
+
while (result = HyperDex::FFI::DS.iterate_map_float_float_next(iter, kdbl, vdbl)) > 0
|
343
|
+
if result < 0
|
344
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
345
|
+
HyperDex::Client::SERVERERROR,
|
346
|
+
"server sent malformed map(int, float)"
|
347
|
+
)
|
348
|
+
end
|
349
|
+
|
350
|
+
res[kdbl.read_double] = vdbl.read_double
|
351
|
+
end
|
352
|
+
|
353
|
+
res
|
354
|
+
|
355
|
+
else
|
356
|
+
raise HyperDex::Client::HyperDexClientException.new(
|
357
|
+
HyperDex::Client::SERVERERROR,
|
358
|
+
"server sent malformed attributes"
|
359
|
+
)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
HyperDex::FFI::Client.enum_type(:hyperdex_client_returncode).set_consts(self)
|
364
|
+
|
365
|
+
class Attribute < ::FFI::Struct
|
366
|
+
layout :name, :pointer,
|
367
|
+
:value, :pointer,
|
368
|
+
:value_sz, :size_t,
|
369
|
+
:datatype, HyperDex::FFI::DS.enum_type(:hyperdatatype)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
require_relative 'client/client'
|
374
|
+
require_relative 'client/deferred'
|
375
|
+
require_relative 'client/hyperdex_client_exception'
|
376
|
+
require_relative 'client/iterator'
|
377
|
+
require_relative 'client/response'
|