hirlite 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +28 -0
- data/Rakefile +51 -0
- data/ext/hirlite_ext/extconf.rb +33 -0
- data/ext/hirlite_ext/hirlite_ext.c +14 -0
- data/ext/hirlite_ext/hirlite_ext.h +38 -0
- data/ext/hirlite_ext/rlite.c +351 -0
- data/lib/hirlite/rlite.rb +1 -0
- data/lib/hirlite/version.rb +3 -0
- data/lib/hirlite.rb +2 -0
- data/vendor/rlite/Makefile +6 -0
- data/vendor/rlite/deps/crc64.c +191 -0
- data/vendor/rlite/deps/crc64.h +3 -0
- data/vendor/rlite/deps/endianconv.h +73 -0
- data/vendor/rlite/deps/hyperloglog.c +1547 -0
- data/vendor/rlite/deps/hyperloglog.h +14 -0
- data/vendor/rlite/deps/lzf.h +100 -0
- data/vendor/rlite/deps/lzfP.h +159 -0
- data/vendor/rlite/deps/lzf_c.c +295 -0
- data/vendor/rlite/deps/lzf_d.c +150 -0
- data/vendor/rlite/deps/sha1.c +227 -0
- data/vendor/rlite/deps/sha1.h +19 -0
- data/vendor/rlite/deps/utilfromredis.c +397 -0
- data/vendor/rlite/deps/utilfromredis.h +11 -0
- data/vendor/rlite/src/Makefile +79 -0
- data/vendor/rlite/src/constants.h +15 -0
- data/vendor/rlite/src/dump.c +191 -0
- data/vendor/rlite/src/dump.h +3 -0
- data/vendor/rlite/src/hirlite.c +3985 -0
- data/vendor/rlite/src/hirlite.h +186 -0
- data/vendor/rlite/src/page_btree.c +1556 -0
- data/vendor/rlite/src/page_btree.h +133 -0
- data/vendor/rlite/src/page_key.c +283 -0
- data/vendor/rlite/src/page_key.h +25 -0
- data/vendor/rlite/src/page_list.c +718 -0
- data/vendor/rlite/src/page_list.h +70 -0
- data/vendor/rlite/src/page_long.c +61 -0
- data/vendor/rlite/src/page_long.h +14 -0
- data/vendor/rlite/src/page_multi_string.c +538 -0
- data/vendor/rlite/src/page_multi_string.h +18 -0
- data/vendor/rlite/src/page_skiplist.c +689 -0
- data/vendor/rlite/src/page_skiplist.h +70 -0
- data/vendor/rlite/src/page_string.c +55 -0
- data/vendor/rlite/src/page_string.h +12 -0
- data/vendor/rlite/src/pqsort.c +185 -0
- data/vendor/rlite/src/pqsort.h +40 -0
- data/vendor/rlite/src/restore.c +401 -0
- data/vendor/rlite/src/restore.h +3 -0
- data/vendor/rlite/src/rlite.c +1309 -0
- data/vendor/rlite/src/rlite.h +159 -0
- data/vendor/rlite/src/sort.c +530 -0
- data/vendor/rlite/src/sort.h +18 -0
- data/vendor/rlite/src/status.h +19 -0
- data/vendor/rlite/src/type_hash.c +607 -0
- data/vendor/rlite/src/type_hash.h +29 -0
- data/vendor/rlite/src/type_list.c +477 -0
- data/vendor/rlite/src/type_list.h +23 -0
- data/vendor/rlite/src/type_set.c +796 -0
- data/vendor/rlite/src/type_set.h +34 -0
- data/vendor/rlite/src/type_string.c +613 -0
- data/vendor/rlite/src/type_string.h +34 -0
- data/vendor/rlite/src/type_zset.c +1147 -0
- data/vendor/rlite/src/type_zset.h +50 -0
- data/vendor/rlite/src/util.c +334 -0
- data/vendor/rlite/src/util.h +71 -0
- metadata +151 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
#ifndef _RL_TYPE_ZSET_H
|
2
|
+
#define _RL_TYPE_ZSET_H
|
3
|
+
|
4
|
+
#include "page_skiplist.h"
|
5
|
+
|
6
|
+
#define RL_TYPE_ZSET 'Z'
|
7
|
+
|
8
|
+
#define RL_ZSET_AGGREGATE_SUM 0
|
9
|
+
#define RL_ZSET_AGGREGATE_MIN 1
|
10
|
+
#define RL_ZSET_AGGREGATE_MAX 2
|
11
|
+
|
12
|
+
struct rlite;
|
13
|
+
|
14
|
+
typedef struct {
|
15
|
+
double min;
|
16
|
+
int minex;
|
17
|
+
double max;
|
18
|
+
int maxex;
|
19
|
+
} rl_zrangespec;
|
20
|
+
|
21
|
+
typedef struct rl_skiplist_iterator rl_zset_iterator;
|
22
|
+
|
23
|
+
int rl_zset_iterator_next(rl_zset_iterator *iterator, double *score, unsigned char **data, long *datalen);
|
24
|
+
int rl_zset_iterator_destroy(rl_zset_iterator *iterator);
|
25
|
+
|
26
|
+
int rl_zadd(struct rlite *db, const unsigned char *key, long keylen, double score, unsigned char *data, long datalen);
|
27
|
+
int rl_zcard(struct rlite *db, const unsigned char *key, long keylen, long *card);
|
28
|
+
int rl_zcount(struct rlite *db, const unsigned char *key, long keylen, rl_zrangespec *range, long *count);
|
29
|
+
int rl_zincrby(struct rlite *db, const unsigned char *key, long keylen, double score, unsigned char *data, long datalen, double *newscore);
|
30
|
+
int rl_zinterstore(struct rlite *db, long keys_size, unsigned char **keys, long *keys_len, double *weights, int aggregate);
|
31
|
+
int rl_zlexcount(struct rlite *db, const unsigned char *key, long keylen, unsigned char *min, long minlen, unsigned char *max, long maxlen, long *lexcount);
|
32
|
+
int rl_zrange(struct rlite *db, const unsigned char *key, long keylen, long start, long end, rl_zset_iterator **iterator);
|
33
|
+
int rl_zrangebylex(struct rlite *db, const unsigned char *key, long keylen, unsigned char *min, long minlen, unsigned char *max, long maxlen, long offset, long count, rl_zset_iterator **iterator);
|
34
|
+
int rl_zrangebyscore(struct rlite *db, const unsigned char *key, long keylen, rl_zrangespec *range, long offset, long count, rl_zset_iterator **iterator);
|
35
|
+
int rl_zrank(struct rlite *db, const unsigned char *key, long keylen, unsigned char *data, long datalen, long *rank);
|
36
|
+
int rl_zrevrange(struct rlite *db, const unsigned char *key, long keylen, long start, long end, rl_zset_iterator **iterator);
|
37
|
+
int rl_zrevrangebylex(struct rlite *db, const unsigned char *key, long keylen, unsigned char *max, long maxlen, unsigned char *min, long minlen, long offset, long count, rl_zset_iterator **iterator);
|
38
|
+
int rl_zrevrangebyscore(struct rlite *db, const unsigned char *key, long keylen, rl_zrangespec *range, long offset, long count, rl_zset_iterator **iterator);
|
39
|
+
int rl_zrevrank(struct rlite *db, const unsigned char *key, long keylen, unsigned char *data, long datalen, long *revrank);
|
40
|
+
int rl_zrem(struct rlite *db, const unsigned char *key, long keylen, long members_size, unsigned char **members, long *members_len, long *changed);
|
41
|
+
int rl_zremrangebylex(struct rlite *db, const unsigned char *key, long keylen, unsigned char *min, long minlen, unsigned char *max, long maxlen, long *changed);
|
42
|
+
int rl_zremrangebyrank(struct rlite *db, const unsigned char *key, long keylen, long start, long end, long *changed);
|
43
|
+
int rl_zremrangebyscore(struct rlite *db, const unsigned char *key, long keylen, rl_zrangespec *range, long *changed);
|
44
|
+
int rl_zscore(struct rlite *db, const unsigned char *key, long keylen, unsigned char *data, long datalen, double *score);
|
45
|
+
int rl_zunionstore(struct rlite *db, long keys_size, unsigned char **keys, long *keys_len, double *weights, int aggregate);
|
46
|
+
|
47
|
+
int rl_zset_pages(struct rlite *db, long page, short *pages);
|
48
|
+
int rl_zset_delete(struct rlite *db, long value_page);
|
49
|
+
|
50
|
+
#endif
|
@@ -0,0 +1,334 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <math.h>
|
5
|
+
#include "../deps/sha1.h"
|
6
|
+
#ifdef DEBUG
|
7
|
+
#include <unistd.h>
|
8
|
+
#include <sys/stat.h>
|
9
|
+
#include <execinfo.h>
|
10
|
+
#include <valgrind/valgrind.h>
|
11
|
+
#endif
|
12
|
+
#include "status.h"
|
13
|
+
#include "util.h"
|
14
|
+
#include <sys/time.h>
|
15
|
+
|
16
|
+
int _sha1_formatter(unsigned char *data, char formatted[40])
|
17
|
+
{
|
18
|
+
static const char *hex_lookup = "0123456789ABCDEF";
|
19
|
+
int i;
|
20
|
+
for (i = 0; i < 20; i++) {
|
21
|
+
formatted[i * 2] = hex_lookup[data[i] & 0x0F];
|
22
|
+
formatted[i * 2 + 1] = hex_lookup[(data[i] / 0x0F) & 0x0F];
|
23
|
+
}
|
24
|
+
return RL_OK;
|
25
|
+
}
|
26
|
+
|
27
|
+
#ifdef DEBUG
|
28
|
+
|
29
|
+
int test_mode = 0;
|
30
|
+
int failed = 0;
|
31
|
+
|
32
|
+
int expect_fail()
|
33
|
+
{
|
34
|
+
return failed;
|
35
|
+
}
|
36
|
+
|
37
|
+
void *rl_malloc(size_t size)
|
38
|
+
{
|
39
|
+
if (test_mode == 0) {
|
40
|
+
return malloc(size);
|
41
|
+
}
|
42
|
+
unsigned char digest[20];
|
43
|
+
char hexdigest[41];
|
44
|
+
int j, nptrs;
|
45
|
+
void *r;
|
46
|
+
#define SIZE 1000
|
47
|
+
void *buffer[SIZE];
|
48
|
+
char **strings;
|
49
|
+
nptrs = backtrace(buffer, SIZE);
|
50
|
+
strings = backtrace_symbols(buffer, nptrs);
|
51
|
+
if (strings == NULL) {
|
52
|
+
return NULL;
|
53
|
+
}
|
54
|
+
|
55
|
+
SHA1_CTX sha;
|
56
|
+
SHA1Init(&sha);
|
57
|
+
for (j = 0; j < nptrs; j++) {
|
58
|
+
SHA1Update(&sha, (unsigned char *)strings[j], strlen(strings[j]));
|
59
|
+
}
|
60
|
+
SHA1Final(digest, &sha);
|
61
|
+
|
62
|
+
_sha1_formatter(digest, hexdigest);
|
63
|
+
|
64
|
+
const char *dir = "malloc-debug";
|
65
|
+
char subdir[100];
|
66
|
+
mkdir(dir, 0777);
|
67
|
+
long i = strlen(dir);
|
68
|
+
memcpy(subdir, dir, strlen(dir));
|
69
|
+
subdir[i] = '/';
|
70
|
+
subdir[i + 1] = hexdigest[0];
|
71
|
+
subdir[i + 2] = hexdigest[1];
|
72
|
+
subdir[i + 3] = 0;
|
73
|
+
mkdir(subdir, 0777);
|
74
|
+
subdir[i + 3] = '/';
|
75
|
+
|
76
|
+
for (j = 0; j < 38; j++) {
|
77
|
+
subdir[i + 4 + j] = hexdigest[2 + j];
|
78
|
+
}
|
79
|
+
subdir[42] = 0;
|
80
|
+
|
81
|
+
if (access(subdir, F_OK) == 0) {
|
82
|
+
r = malloc(size);
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
hexdigest[40] = 0;
|
86
|
+
fprintf(stderr, "Failing malloc on %s\n", hexdigest);
|
87
|
+
|
88
|
+
FILE *fp = fopen(subdir, "w");
|
89
|
+
for (j = 0; j < nptrs; j++) {
|
90
|
+
fwrite(strings[j], 1, strlen(strings[j]), fp);
|
91
|
+
fwrite("\n", 1, 1, fp);
|
92
|
+
}
|
93
|
+
fclose(fp);
|
94
|
+
failed = 1;
|
95
|
+
fprintf(stderr, "Simulating OOM\n");
|
96
|
+
r = NULL;
|
97
|
+
}
|
98
|
+
free(strings);
|
99
|
+
return r;
|
100
|
+
}
|
101
|
+
|
102
|
+
void rl_free(void *ptr)
|
103
|
+
{
|
104
|
+
free(ptr);
|
105
|
+
}
|
106
|
+
#endif
|
107
|
+
|
108
|
+
|
109
|
+
void put_4bytes(unsigned char *p, long v)
|
110
|
+
{
|
111
|
+
p[0] = (unsigned char)(v >> 24);
|
112
|
+
p[1] = (unsigned char)(v >> 16);
|
113
|
+
p[2] = (unsigned char)(v >> 8);
|
114
|
+
p[3] = (unsigned char)v;
|
115
|
+
}
|
116
|
+
|
117
|
+
int get_4bytes(const unsigned char *p)
|
118
|
+
{
|
119
|
+
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
120
|
+
}
|
121
|
+
|
122
|
+
unsigned long long get_8bytes(const unsigned char *p)
|
123
|
+
{
|
124
|
+
unsigned long long retval = 0;
|
125
|
+
retval |= (unsigned long long)p[0] << 56;
|
126
|
+
retval |= (unsigned long long)p[1] << 48;
|
127
|
+
retval |= (unsigned long long)p[2] << 40;
|
128
|
+
retval |= (unsigned long long)p[3] << 32;
|
129
|
+
retval |= (unsigned long long)p[4] << 24;
|
130
|
+
retval |= (unsigned long long)p[5] << 16;
|
131
|
+
retval |= (unsigned long long)p[6] << 8;
|
132
|
+
retval |= (unsigned long long)p[7];
|
133
|
+
return retval;
|
134
|
+
}
|
135
|
+
|
136
|
+
void put_8bytes(unsigned char *p, unsigned long long v)
|
137
|
+
{
|
138
|
+
p[0] = (unsigned char)(v >> 56);
|
139
|
+
p[1] = (unsigned char)(v >> 48);
|
140
|
+
p[2] = (unsigned char)(v >> 40);
|
141
|
+
p[3] = (unsigned char)(v >> 32);
|
142
|
+
p[4] = (unsigned char)(v >> 24);
|
143
|
+
p[5] = (unsigned char)(v >> 16);
|
144
|
+
p[6] = (unsigned char)(v >> 8);
|
145
|
+
p[7] = (unsigned char)v;
|
146
|
+
}
|
147
|
+
|
148
|
+
int long_cmp(void *v1, void *v2)
|
149
|
+
{
|
150
|
+
long a = *((long *)v1), b = *((long *)v2);
|
151
|
+
if (a == b) {
|
152
|
+
return 0;
|
153
|
+
}
|
154
|
+
return a > b ? 1 : -1;
|
155
|
+
}
|
156
|
+
|
157
|
+
int sha1_cmp(void *v1, void *v2)
|
158
|
+
{
|
159
|
+
return memcmp(v1, v2, sizeof(unsigned char) * 20);
|
160
|
+
}
|
161
|
+
|
162
|
+
#ifdef DEBUG
|
163
|
+
int long_formatter(void *v2, char **formatted, int *size)
|
164
|
+
{
|
165
|
+
*formatted = rl_malloc(sizeof(char) * 22);
|
166
|
+
if (*formatted == NULL) {
|
167
|
+
return RL_OUT_OF_MEMORY;
|
168
|
+
}
|
169
|
+
*size = snprintf(*formatted, 22, "%ld", *(long *)v2);
|
170
|
+
return RL_OK;
|
171
|
+
}
|
172
|
+
|
173
|
+
int sha1_formatter(void *v2, char **formatted, int *size)
|
174
|
+
{
|
175
|
+
unsigned char *data = (unsigned char *)v2;
|
176
|
+
*formatted = rl_malloc(sizeof(char) * 40);
|
177
|
+
if (*formatted == NULL) {
|
178
|
+
return RL_OUT_OF_MEMORY;
|
179
|
+
}
|
180
|
+
_sha1_formatter(data, *formatted);
|
181
|
+
if (size) {
|
182
|
+
*size = 40;
|
183
|
+
}
|
184
|
+
return RL_OK;
|
185
|
+
}
|
186
|
+
|
187
|
+
#endif
|
188
|
+
|
189
|
+
// Code for serialize/deserialize double comes from
|
190
|
+
// http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#serialization
|
191
|
+
|
192
|
+
#define pack754_32(f) (pack754((f), 32, 8))
|
193
|
+
#define pack754_64(f) (pack754((f), 64, 11))
|
194
|
+
#define unpack754_32(i) (unpack754((i), 32, 8))
|
195
|
+
#define unpack754_64(i) (unpack754((i), 64, 11))
|
196
|
+
|
197
|
+
unsigned long long pack754(long double f, unsigned bits, unsigned expbits)
|
198
|
+
{
|
199
|
+
long double fnorm;
|
200
|
+
int shift;
|
201
|
+
long long sign, exp, significand;
|
202
|
+
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
203
|
+
|
204
|
+
if (f == 0.0) {
|
205
|
+
return 0; // get this special case out of the way
|
206
|
+
}
|
207
|
+
|
208
|
+
// This doesn't look very formal, but the values for +inf and -inf were
|
209
|
+
// calculated using the formula described in
|
210
|
+
// http://stackoverflow.com/a/3421923/551548
|
211
|
+
if ((double)f == (double) - INFINITY) {
|
212
|
+
return 140737360872672;
|
213
|
+
}
|
214
|
+
|
215
|
+
if ((double)f == (double)INFINITY) {
|
216
|
+
return 140737151196432;
|
217
|
+
}
|
218
|
+
|
219
|
+
// check sign and begin normalization
|
220
|
+
if (f < 0) {
|
221
|
+
sign = 1;
|
222
|
+
fnorm = -f;
|
223
|
+
}
|
224
|
+
else {
|
225
|
+
sign = 0;
|
226
|
+
fnorm = f;
|
227
|
+
}
|
228
|
+
|
229
|
+
// get the normalized form of f and track the exponent
|
230
|
+
shift = 0;
|
231
|
+
while(fnorm >= 2.0) {
|
232
|
+
fnorm /= 2.0;
|
233
|
+
shift++;
|
234
|
+
}
|
235
|
+
while(fnorm < 1.0) {
|
236
|
+
fnorm *= 2.0;
|
237
|
+
shift--;
|
238
|
+
}
|
239
|
+
fnorm = fnorm - 1.0;
|
240
|
+
|
241
|
+
// calculate the binary form (non-float) of the significand data
|
242
|
+
significand = fnorm * ((1LL << significandbits) + 0.5f);
|
243
|
+
|
244
|
+
// get the biased exponent
|
245
|
+
exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias
|
246
|
+
|
247
|
+
// return the final answer
|
248
|
+
return (sign << (bits - 1)) | (exp << (bits - expbits - 1)) | significand;
|
249
|
+
}
|
250
|
+
|
251
|
+
long double unpack754(unsigned long long i, unsigned bits, unsigned expbits)
|
252
|
+
{
|
253
|
+
long double result;
|
254
|
+
long long shift;
|
255
|
+
unsigned bias;
|
256
|
+
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
257
|
+
|
258
|
+
if (i == 0) {
|
259
|
+
return 0.0;
|
260
|
+
}
|
261
|
+
if (i == 140737360872672) {
|
262
|
+
return -INFINITY;
|
263
|
+
}
|
264
|
+
|
265
|
+
if (i == 140737151196432) {
|
266
|
+
return INFINITY;
|
267
|
+
}
|
268
|
+
|
269
|
+
// pull the significand
|
270
|
+
result = (i & ((1LL << significandbits) - 1)); // mask
|
271
|
+
result /= (1LL << significandbits); // convert back to float
|
272
|
+
result += 1.0f; // add the one back on
|
273
|
+
|
274
|
+
// deal with the exponent
|
275
|
+
bias = (1 << (expbits - 1)) - 1;
|
276
|
+
shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
|
277
|
+
while(shift > 0) {
|
278
|
+
result *= 2.0;
|
279
|
+
shift--;
|
280
|
+
}
|
281
|
+
while(shift < 0) {
|
282
|
+
result /= 2.0;
|
283
|
+
shift++;
|
284
|
+
}
|
285
|
+
|
286
|
+
// sign it
|
287
|
+
result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
|
288
|
+
|
289
|
+
return result;
|
290
|
+
}
|
291
|
+
|
292
|
+
double get_double(const unsigned char *p)
|
293
|
+
{
|
294
|
+
unsigned long long ull = get_8bytes(p);
|
295
|
+
return unpack754_64(ull);
|
296
|
+
}
|
297
|
+
|
298
|
+
void put_double(unsigned char *p, double v)
|
299
|
+
{
|
300
|
+
unsigned long long ull = pack754_64(v);
|
301
|
+
put_8bytes(p, ull);
|
302
|
+
}
|
303
|
+
|
304
|
+
int sha1(const unsigned char *data, long datalen, unsigned char digest[20])
|
305
|
+
{
|
306
|
+
SHA1_CTX sha;
|
307
|
+
SHA1Init(&sha);
|
308
|
+
SHA1Update(&sha, data, datalen);
|
309
|
+
SHA1Final(digest, &sha);
|
310
|
+
return RL_OK;
|
311
|
+
}
|
312
|
+
|
313
|
+
unsigned long long rl_mstime()
|
314
|
+
{
|
315
|
+
struct timeval tp;
|
316
|
+
gettimeofday(&tp, NULL);
|
317
|
+
return tp.tv_sec * 1000 + tp.tv_usec / 1000;
|
318
|
+
}
|
319
|
+
|
320
|
+
double rl_strtod(unsigned char *_str, long strlen, unsigned char **_eptr) {
|
321
|
+
double d;
|
322
|
+
char str[40];
|
323
|
+
char *eptr;
|
324
|
+
if (strlen > 39) {
|
325
|
+
strlen = 39;
|
326
|
+
}
|
327
|
+
memcpy(str, _str, strlen);
|
328
|
+
str[strlen] = 0;
|
329
|
+
d = strtod(str, &eptr);
|
330
|
+
if (_eptr) {
|
331
|
+
*_eptr = _str + (eptr - str);
|
332
|
+
}
|
333
|
+
return d;
|
334
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#ifndef _RL_UTIL_H
|
2
|
+
#define _RL_UTIL_H
|
3
|
+
|
4
|
+
#include <float.h>
|
5
|
+
#include <ctype.h>
|
6
|
+
#include <string.h>
|
7
|
+
#include <limits.h>
|
8
|
+
#include "../deps/utilfromredis.h"
|
9
|
+
|
10
|
+
// http://stackoverflow.com/questions/1701055/what-is-the-maximum-length-in-chars-needed-to-represent-any-double-value
|
11
|
+
#define MAX_DOUBLE_DIGITS (3 + DBL_MANT_DIG - DBL_MIN_EXP)
|
12
|
+
#define MAX_LLONG_DIGITS 22
|
13
|
+
|
14
|
+
#ifdef DEBUG
|
15
|
+
int expect_fail();
|
16
|
+
extern int test_mode;
|
17
|
+
void *rl_malloc(size_t size);
|
18
|
+
void rl_free(void *ptr);
|
19
|
+
#else
|
20
|
+
#define rl_malloc malloc
|
21
|
+
#define rl_free free
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#define RL_MALLOC(obj, size)\
|
25
|
+
obj = rl_malloc(size);\
|
26
|
+
if (!obj) {\
|
27
|
+
retval = RL_OUT_OF_MEMORY;\
|
28
|
+
goto cleanup;\
|
29
|
+
}
|
30
|
+
|
31
|
+
#define RL_REALLOC(ptr, size)\
|
32
|
+
tmp = realloc(ptr, size);\
|
33
|
+
if (!tmp) {\
|
34
|
+
retval = RL_OUT_OF_MEMORY;\
|
35
|
+
goto cleanup;\
|
36
|
+
}\
|
37
|
+
ptr = tmp;
|
38
|
+
|
39
|
+
#define RL_CALL(func, expected, ...)\
|
40
|
+
retval = func(__VA_ARGS__);\
|
41
|
+
if (expected != retval) goto cleanup;
|
42
|
+
|
43
|
+
#define RL_CALL2(func, expected, expected2, ...)\
|
44
|
+
retval = func(__VA_ARGS__);\
|
45
|
+
if (expected != retval && expected2 != retval) goto cleanup;
|
46
|
+
|
47
|
+
#ifdef __GNUC__
|
48
|
+
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
|
49
|
+
#else
|
50
|
+
# define UNUSED(x) UNUSED_ ## x
|
51
|
+
#endif
|
52
|
+
|
53
|
+
int get_4bytes(const unsigned char *p);
|
54
|
+
void put_4bytes(unsigned char *p, long v);
|
55
|
+
unsigned long long get_8bytes(const unsigned char *p);
|
56
|
+
void put_8bytes(unsigned char *p, unsigned long long v);
|
57
|
+
int long_cmp(void *v1, void *v2);
|
58
|
+
int sha1_cmp(void *v1, void *v2);
|
59
|
+
int double_cmp(void *v1, void *v2);
|
60
|
+
#ifdef DEBUG
|
61
|
+
int long_formatter(void *v2, char **formatted, int *size);
|
62
|
+
int sha1_formatter(void *v2, char **formatted, int *size);
|
63
|
+
int double_formatter(void *v2, char **formatted, int *size);
|
64
|
+
#endif
|
65
|
+
double get_double(const unsigned char *p);
|
66
|
+
void put_double(unsigned char *p, double v);
|
67
|
+
int sha1(const unsigned char *data, long datalen, unsigned char digest[20]);
|
68
|
+
unsigned long long rl_mstime();
|
69
|
+
double rl_strtod(unsigned char *str, long strlen, unsigned char **eptr);
|
70
|
+
|
71
|
+
#endif
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hirlite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian Waisbrot
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.5.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.5.1
|
55
|
+
description: Ruby wrapper for hirlite
|
56
|
+
email:
|
57
|
+
- seppo0010@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/hirlite_ext/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- Rakefile
|
65
|
+
- ext/hirlite_ext/extconf.rb
|
66
|
+
- ext/hirlite_ext/hirlite_ext.c
|
67
|
+
- ext/hirlite_ext/hirlite_ext.h
|
68
|
+
- ext/hirlite_ext/rlite.c
|
69
|
+
- lib/hirlite.rb
|
70
|
+
- lib/hirlite/rlite.rb
|
71
|
+
- lib/hirlite/version.rb
|
72
|
+
- vendor/rlite/Makefile
|
73
|
+
- vendor/rlite/deps/crc64.c
|
74
|
+
- vendor/rlite/deps/crc64.h
|
75
|
+
- vendor/rlite/deps/endianconv.h
|
76
|
+
- vendor/rlite/deps/hyperloglog.c
|
77
|
+
- vendor/rlite/deps/hyperloglog.h
|
78
|
+
- vendor/rlite/deps/lzf.h
|
79
|
+
- vendor/rlite/deps/lzfP.h
|
80
|
+
- vendor/rlite/deps/lzf_c.c
|
81
|
+
- vendor/rlite/deps/lzf_d.c
|
82
|
+
- vendor/rlite/deps/sha1.c
|
83
|
+
- vendor/rlite/deps/sha1.h
|
84
|
+
- vendor/rlite/deps/utilfromredis.c
|
85
|
+
- vendor/rlite/deps/utilfromredis.h
|
86
|
+
- vendor/rlite/src/Makefile
|
87
|
+
- vendor/rlite/src/constants.h
|
88
|
+
- vendor/rlite/src/dump.c
|
89
|
+
- vendor/rlite/src/dump.h
|
90
|
+
- vendor/rlite/src/hirlite.c
|
91
|
+
- vendor/rlite/src/hirlite.h
|
92
|
+
- vendor/rlite/src/page_btree.c
|
93
|
+
- vendor/rlite/src/page_btree.h
|
94
|
+
- vendor/rlite/src/page_key.c
|
95
|
+
- vendor/rlite/src/page_key.h
|
96
|
+
- vendor/rlite/src/page_list.c
|
97
|
+
- vendor/rlite/src/page_list.h
|
98
|
+
- vendor/rlite/src/page_long.c
|
99
|
+
- vendor/rlite/src/page_long.h
|
100
|
+
- vendor/rlite/src/page_multi_string.c
|
101
|
+
- vendor/rlite/src/page_multi_string.h
|
102
|
+
- vendor/rlite/src/page_skiplist.c
|
103
|
+
- vendor/rlite/src/page_skiplist.h
|
104
|
+
- vendor/rlite/src/page_string.c
|
105
|
+
- vendor/rlite/src/page_string.h
|
106
|
+
- vendor/rlite/src/pqsort.c
|
107
|
+
- vendor/rlite/src/pqsort.h
|
108
|
+
- vendor/rlite/src/restore.c
|
109
|
+
- vendor/rlite/src/restore.h
|
110
|
+
- vendor/rlite/src/rlite.c
|
111
|
+
- vendor/rlite/src/rlite.h
|
112
|
+
- vendor/rlite/src/sort.c
|
113
|
+
- vendor/rlite/src/sort.h
|
114
|
+
- vendor/rlite/src/status.h
|
115
|
+
- vendor/rlite/src/type_hash.c
|
116
|
+
- vendor/rlite/src/type_hash.h
|
117
|
+
- vendor/rlite/src/type_list.c
|
118
|
+
- vendor/rlite/src/type_list.h
|
119
|
+
- vendor/rlite/src/type_set.c
|
120
|
+
- vendor/rlite/src/type_set.h
|
121
|
+
- vendor/rlite/src/type_string.c
|
122
|
+
- vendor/rlite/src/type_string.h
|
123
|
+
- vendor/rlite/src/type_zset.c
|
124
|
+
- vendor/rlite/src/type_zset.h
|
125
|
+
- vendor/rlite/src/util.c
|
126
|
+
- vendor/rlite/src/util.h
|
127
|
+
homepage: http://github.com/seppo0010/hirlite-rb
|
128
|
+
licenses:
|
129
|
+
- BSD-3-Clause
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.4.6
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Ruby wrapper for hirlite
|
151
|
+
test_files: []
|