rage-iodine 1.7.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- data/.github/workflows/ruby.yml +42 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.yardopts +8 -0
- data/CHANGELOG.md +1098 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/LIMITS.md +41 -0
- data/README.md +782 -0
- data/Rakefile +23 -0
- data/SPEC-PubSub-Draft.md +159 -0
- data/SPEC-WebSocket-Draft.md +239 -0
- data/bin/console +22 -0
- data/bin/info.md +353 -0
- data/bin/mustache_bench.rb +100 -0
- data/bin/poc/Gemfile.lock +23 -0
- data/bin/poc/README.md +37 -0
- data/bin/poc/config.ru +66 -0
- data/bin/poc/gemfile +1 -0
- data/bin/poc/www/index.html +57 -0
- data/examples/async_task.ru +92 -0
- data/examples/bates/README.md +3 -0
- data/examples/bates/config.ru +342 -0
- data/examples/bates/david+bold.pdf +0 -0
- data/examples/bates/public/drop-pdf.png +0 -0
- data/examples/bates/public/index.html +600 -0
- data/examples/config.ru +59 -0
- data/examples/echo.ru +59 -0
- data/examples/etag.ru +16 -0
- data/examples/hello.ru +29 -0
- data/examples/pubsub_engine.ru +81 -0
- data/examples/rack3.ru +12 -0
- data/examples/redis.ru +70 -0
- data/examples/shootout.ru +73 -0
- data/examples/sub-protocols.ru +90 -0
- data/examples/tcp_client.rb +66 -0
- data/examples/x-sendfile.ru +14 -0
- data/exe/iodine +280 -0
- data/ext/iodine/extconf.rb +110 -0
- data/ext/iodine/fio.c +12096 -0
- data/ext/iodine/fio.h +6390 -0
- data/ext/iodine/fio_cli.c +431 -0
- data/ext/iodine/fio_cli.h +189 -0
- data/ext/iodine/fio_json_parser.h +687 -0
- data/ext/iodine/fio_siphash.c +157 -0
- data/ext/iodine/fio_siphash.h +37 -0
- data/ext/iodine/fio_tls.h +129 -0
- data/ext/iodine/fio_tls_missing.c +649 -0
- data/ext/iodine/fio_tls_openssl.c +1056 -0
- data/ext/iodine/fio_tmpfile.h +50 -0
- data/ext/iodine/fiobj.h +44 -0
- data/ext/iodine/fiobj4fio.h +21 -0
- data/ext/iodine/fiobj_ary.c +333 -0
- data/ext/iodine/fiobj_ary.h +139 -0
- data/ext/iodine/fiobj_data.c +1185 -0
- data/ext/iodine/fiobj_data.h +167 -0
- data/ext/iodine/fiobj_hash.c +409 -0
- data/ext/iodine/fiobj_hash.h +176 -0
- data/ext/iodine/fiobj_json.c +622 -0
- data/ext/iodine/fiobj_json.h +68 -0
- data/ext/iodine/fiobj_mem.h +71 -0
- data/ext/iodine/fiobj_mustache.c +317 -0
- data/ext/iodine/fiobj_mustache.h +62 -0
- data/ext/iodine/fiobj_numbers.c +344 -0
- data/ext/iodine/fiobj_numbers.h +127 -0
- data/ext/iodine/fiobj_str.c +433 -0
- data/ext/iodine/fiobj_str.h +172 -0
- data/ext/iodine/fiobject.c +620 -0
- data/ext/iodine/fiobject.h +654 -0
- data/ext/iodine/hpack.h +1923 -0
- data/ext/iodine/http.c +2736 -0
- data/ext/iodine/http.h +1019 -0
- data/ext/iodine/http1.c +825 -0
- data/ext/iodine/http1.h +29 -0
- data/ext/iodine/http1_parser.h +1835 -0
- data/ext/iodine/http_internal.c +1279 -0
- data/ext/iodine/http_internal.h +248 -0
- data/ext/iodine/http_mime_parser.h +350 -0
- data/ext/iodine/iodine.c +1433 -0
- data/ext/iodine/iodine.h +64 -0
- data/ext/iodine/iodine_caller.c +218 -0
- data/ext/iodine/iodine_caller.h +27 -0
- data/ext/iodine/iodine_connection.c +941 -0
- data/ext/iodine/iodine_connection.h +55 -0
- data/ext/iodine/iodine_defer.c +420 -0
- data/ext/iodine/iodine_defer.h +6 -0
- data/ext/iodine/iodine_fiobj2rb.h +120 -0
- data/ext/iodine/iodine_helpers.c +282 -0
- data/ext/iodine/iodine_helpers.h +12 -0
- data/ext/iodine/iodine_http.c +1280 -0
- data/ext/iodine/iodine_http.h +23 -0
- data/ext/iodine/iodine_json.c +302 -0
- data/ext/iodine/iodine_json.h +6 -0
- data/ext/iodine/iodine_mustache.c +567 -0
- data/ext/iodine/iodine_mustache.h +6 -0
- data/ext/iodine/iodine_pubsub.c +580 -0
- data/ext/iodine/iodine_pubsub.h +26 -0
- data/ext/iodine/iodine_rack_io.c +273 -0
- data/ext/iodine/iodine_rack_io.h +20 -0
- data/ext/iodine/iodine_store.c +142 -0
- data/ext/iodine/iodine_store.h +20 -0
- data/ext/iodine/iodine_tcp.c +346 -0
- data/ext/iodine/iodine_tcp.h +13 -0
- data/ext/iodine/iodine_tls.c +261 -0
- data/ext/iodine/iodine_tls.h +13 -0
- data/ext/iodine/mustache_parser.h +1546 -0
- data/ext/iodine/redis_engine.c +957 -0
- data/ext/iodine/redis_engine.h +79 -0
- data/ext/iodine/resp_parser.h +317 -0
- data/ext/iodine/scheduler.c +173 -0
- data/ext/iodine/scheduler.h +6 -0
- data/ext/iodine/websocket_parser.h +506 -0
- data/ext/iodine/websockets.c +752 -0
- data/ext/iodine/websockets.h +185 -0
- data/iodine.gemspec +50 -0
- data/lib/iodine/connection.rb +61 -0
- data/lib/iodine/json.rb +42 -0
- data/lib/iodine/mustache.rb +113 -0
- data/lib/iodine/pubsub.rb +55 -0
- data/lib/iodine/rack_utils.rb +43 -0
- data/lib/iodine/tls.rb +16 -0
- data/lib/iodine/version.rb +3 -0
- data/lib/iodine.rb +274 -0
- data/lib/rack/handler/iodine.rb +33 -0
- data/logo.png +0 -0
- metadata +284 -0
@@ -0,0 +1,176 @@
|
|
1
|
+
/*
|
2
|
+
Copyright: Boaz Segev, 2017-2019
|
3
|
+
License: MIT
|
4
|
+
*/
|
5
|
+
#ifndef H_FIOBJ_HASH_H
|
6
|
+
/**
|
7
|
+
* The facil.io Hash object is an ordered Hash Table implementation.
|
8
|
+
*
|
9
|
+
* By compromising some of the HashMap's collision resistance (comparing only
|
10
|
+
* the Hash values rather than comparing key data), memory comparison can be
|
11
|
+
* avoided and performance increased.
|
12
|
+
*
|
13
|
+
* By being ordered it's possible to iterate over key-value pairs in the order
|
14
|
+
* in which they were added to the Hash table, making it possible to output JSON
|
15
|
+
* in a controlled manner.
|
16
|
+
*/
|
17
|
+
#define H_FIOBJ_HASH_H
|
18
|
+
|
19
|
+
#include <fiobject.h>
|
20
|
+
|
21
|
+
#include <fio_siphash.h>
|
22
|
+
#include <fiobj_str.h>
|
23
|
+
|
24
|
+
#include <errno.h>
|
25
|
+
|
26
|
+
#ifdef __cplusplus
|
27
|
+
extern "C" {
|
28
|
+
#endif
|
29
|
+
|
30
|
+
/* MUST be a power of 2 */
|
31
|
+
#define HASH_INITIAL_CAPACITY 16
|
32
|
+
|
33
|
+
/** attempts to rehash the hashmap. */
|
34
|
+
void fiobj_hash_rehash(FIOBJ h);
|
35
|
+
|
36
|
+
/* *****************************************************************************
|
37
|
+
Hash Creation
|
38
|
+
***************************************************************************** */
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Creates a mutable empty Hash object. Use `fiobj_free` when done.
|
42
|
+
*
|
43
|
+
* Notice that these Hash objects are optimized for smaller collections and
|
44
|
+
* retain order of object insertion.
|
45
|
+
*/
|
46
|
+
FIOBJ fiobj_hash_new(void);
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Creates a mutable empty Hash object with an initial capacity of `capa`. Use
|
50
|
+
* `fiobj_free` when done.
|
51
|
+
*
|
52
|
+
* This allows optimizations for larger (or smaller) collections.
|
53
|
+
*/
|
54
|
+
FIOBJ fiobj_hash_new2(size_t capa);
|
55
|
+
|
56
|
+
/* *****************************************************************************
|
57
|
+
Hash properties and state
|
58
|
+
***************************************************************************** */
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Returns a temporary theoretical Hash map capacity.
|
62
|
+
* This could be used for testing performance and memory consumption.
|
63
|
+
*/
|
64
|
+
size_t fiobj_hash_capa(const FIOBJ hash);
|
65
|
+
|
66
|
+
/** Returns the number of elements in the Hash. */
|
67
|
+
size_t fiobj_hash_count(const FIOBJ hash);
|
68
|
+
|
69
|
+
/** Returns the key for the object in the current `fiobj_each` loop (if any). */
|
70
|
+
FIOBJ fiobj_hash_key_in_loop(void);
|
71
|
+
|
72
|
+
/* *****************************************************************************
|
73
|
+
Populating the Hash
|
74
|
+
***************************************************************************** */
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Sets a key-value pair in the Hash, duplicating the Symbol and **moving**
|
78
|
+
* the ownership of the object to the Hash.
|
79
|
+
*
|
80
|
+
* Returns -1 on error.
|
81
|
+
*/
|
82
|
+
int fiobj_hash_set(FIOBJ hash, FIOBJ key, FIOBJ obj);
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Allows the Hash to be used as a stack.
|
86
|
+
*
|
87
|
+
* If a pointer `key` is provided, it will receive ownership of the key
|
88
|
+
* (remember to free).
|
89
|
+
*
|
90
|
+
* Returns FIOBJ_INVALID on error.
|
91
|
+
*
|
92
|
+
* Returns and object if successful (remember to free).
|
93
|
+
*/
|
94
|
+
FIOBJ fiobj_hash_pop(FIOBJ hash, FIOBJ *key);
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Replaces the value in a key-value pair, returning the old value (and it's
|
98
|
+
* ownership) to the caller.
|
99
|
+
*
|
100
|
+
* A return value of FIOBJ_INVALID indicates that no previous object existed
|
101
|
+
* (but a new key-value pair was created.
|
102
|
+
*
|
103
|
+
* Errors are silently ignored.
|
104
|
+
*
|
105
|
+
* Remember to free the returned object.
|
106
|
+
*/
|
107
|
+
FIOBJ fiobj_hash_replace(FIOBJ hash, FIOBJ key, FIOBJ obj);
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Removes a key-value pair from the Hash, if it exists, returning the old
|
111
|
+
* object (instead of freeing it).
|
112
|
+
*/
|
113
|
+
FIOBJ fiobj_hash_remove(FIOBJ hash, FIOBJ key);
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Removes a key-value pair from the Hash, if it exists, returning the old
|
117
|
+
* object (instead of freeing it).
|
118
|
+
*/
|
119
|
+
FIOBJ fiobj_hash_remove2(FIOBJ hash, uint64_t key_hash);
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Deletes a key-value pair from the Hash, if it exists, freeing the
|
123
|
+
* associated object.
|
124
|
+
*
|
125
|
+
* Returns -1 on type error or if the object never existed.
|
126
|
+
*/
|
127
|
+
int fiobj_hash_delete(FIOBJ hash, FIOBJ key);
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Deletes a key-value pair from the Hash, if it exists, freeing the
|
131
|
+
* associated object.
|
132
|
+
*
|
133
|
+
* This function takes a `uint64_t` Hash value (see `fio_siphash`) to
|
134
|
+
* perform a lookup in the HashMap, which is slightly faster than the other
|
135
|
+
* variations.
|
136
|
+
*
|
137
|
+
* Returns -1 on type error or if the object never existed.
|
138
|
+
*/
|
139
|
+
int fiobj_hash_delete2(FIOBJ hash, uint64_t key_hash);
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Returns a temporary handle to the object associated with the Symbol,
|
143
|
+
* FIOBJ_INVALID if none.
|
144
|
+
*/
|
145
|
+
FIOBJ fiobj_hash_get(const FIOBJ hash, FIOBJ key);
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Returns a temporary handle to the object associated hashed key value.
|
149
|
+
*
|
150
|
+
* This function takes a `uint64_t` Hash value (see `fio_siphash`) to
|
151
|
+
* perform a lookup in the HashMap, which is slightly faster than the other
|
152
|
+
* variations.
|
153
|
+
*
|
154
|
+
* Returns FIOBJ_INVALID if no object is associated with this hashed key value.
|
155
|
+
*/
|
156
|
+
FIOBJ fiobj_hash_get2(const FIOBJ hash, uint64_t key_hash);
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Returns 1 if the key (Symbol) exists in the Hash, even if it's value is NULL.
|
160
|
+
*/
|
161
|
+
int fiobj_hash_haskey(const FIOBJ hash, FIOBJ key);
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Empties the Hash.
|
165
|
+
*/
|
166
|
+
void fiobj_hash_clear(const FIOBJ hash);
|
167
|
+
|
168
|
+
#if DEBUG
|
169
|
+
void fiobj_test_hash(void);
|
170
|
+
#endif
|
171
|
+
|
172
|
+
#ifdef __cplusplus
|
173
|
+
} /* extern "C" */
|
174
|
+
#endif
|
175
|
+
|
176
|
+
#endif
|