prometheus-client-mmap 0.20.3-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +253 -0
- data/ext/fast_mmaped_file/extconf.rb +30 -0
- data/ext/fast_mmaped_file/fast_mmaped_file.c +122 -0
- data/ext/fast_mmaped_file/file_format.c +5 -0
- data/ext/fast_mmaped_file/file_format.h +11 -0
- data/ext/fast_mmaped_file/file_parsing.c +195 -0
- data/ext/fast_mmaped_file/file_parsing.h +27 -0
- data/ext/fast_mmaped_file/file_reading.c +102 -0
- data/ext/fast_mmaped_file/file_reading.h +30 -0
- data/ext/fast_mmaped_file/globals.h +14 -0
- data/ext/fast_mmaped_file/mmap.c +427 -0
- data/ext/fast_mmaped_file/mmap.h +61 -0
- data/ext/fast_mmaped_file/rendering.c +199 -0
- data/ext/fast_mmaped_file/rendering.h +8 -0
- data/ext/fast_mmaped_file/utils.c +56 -0
- data/ext/fast_mmaped_file/utils.h +22 -0
- data/ext/fast_mmaped_file/value_access.c +242 -0
- data/ext/fast_mmaped_file/value_access.h +15 -0
- data/ext/fast_mmaped_file_rs/.cargo/config.toml +23 -0
- data/ext/fast_mmaped_file_rs/Cargo.lock +790 -0
- data/ext/fast_mmaped_file_rs/Cargo.toml +30 -0
- data/ext/fast_mmaped_file_rs/README.md +52 -0
- data/ext/fast_mmaped_file_rs/extconf.rb +30 -0
- data/ext/fast_mmaped_file_rs/src/error.rs +174 -0
- data/ext/fast_mmaped_file_rs/src/file_entry.rs +579 -0
- data/ext/fast_mmaped_file_rs/src/file_info.rs +190 -0
- data/ext/fast_mmaped_file_rs/src/lib.rs +79 -0
- data/ext/fast_mmaped_file_rs/src/macros.rs +14 -0
- data/ext/fast_mmaped_file_rs/src/map.rs +492 -0
- data/ext/fast_mmaped_file_rs/src/mmap.rs +151 -0
- data/ext/fast_mmaped_file_rs/src/parser.rs +346 -0
- data/ext/fast_mmaped_file_rs/src/raw_entry.rs +473 -0
- data/ext/fast_mmaped_file_rs/src/testhelper.rs +222 -0
- data/ext/fast_mmaped_file_rs/src/util.rs +121 -0
- data/lib/2.7/fast_mmaped_file.so +0 -0
- data/lib/2.7/fast_mmaped_file_rs.so +0 -0
- data/lib/3.0/fast_mmaped_file.so +0 -0
- data/lib/3.0/fast_mmaped_file_rs.so +0 -0
- data/lib/3.1/fast_mmaped_file.so +0 -0
- data/lib/3.1/fast_mmaped_file_rs.so +0 -0
- data/lib/3.2/fast_mmaped_file.so +0 -0
- data/lib/3.2/fast_mmaped_file_rs.so +0 -0
- data/lib/prometheus/client/configuration.rb +23 -0
- data/lib/prometheus/client/counter.rb +27 -0
- data/lib/prometheus/client/formats/text.rb +118 -0
- data/lib/prometheus/client/gauge.rb +40 -0
- data/lib/prometheus/client/helper/entry_parser.rb +132 -0
- data/lib/prometheus/client/helper/file_locker.rb +50 -0
- data/lib/prometheus/client/helper/json_parser.rb +23 -0
- data/lib/prometheus/client/helper/metrics_processing.rb +45 -0
- data/lib/prometheus/client/helper/metrics_representation.rb +51 -0
- data/lib/prometheus/client/helper/mmaped_file.rb +64 -0
- data/lib/prometheus/client/helper/plain_file.rb +29 -0
- data/lib/prometheus/client/histogram.rb +80 -0
- data/lib/prometheus/client/label_set_validator.rb +86 -0
- data/lib/prometheus/client/metric.rb +80 -0
- data/lib/prometheus/client/mmaped_dict.rb +79 -0
- data/lib/prometheus/client/mmaped_value.rb +154 -0
- data/lib/prometheus/client/page_size.rb +17 -0
- data/lib/prometheus/client/push.rb +203 -0
- data/lib/prometheus/client/rack/collector.rb +88 -0
- data/lib/prometheus/client/rack/exporter.rb +96 -0
- data/lib/prometheus/client/registry.rb +65 -0
- data/lib/prometheus/client/simple_value.rb +31 -0
- data/lib/prometheus/client/summary.rb +69 -0
- data/lib/prometheus/client/support/unicorn.rb +35 -0
- data/lib/prometheus/client/uses_value_type.rb +20 -0
- data/lib/prometheus/client/version.rb +5 -0
- data/lib/prometheus/client.rb +58 -0
- data/lib/prometheus.rb +3 -0
- data/vendor/c/hashmap/.gitignore +52 -0
- data/vendor/c/hashmap/LICENSE +21 -0
- data/vendor/c/hashmap/README.md +90 -0
- data/vendor/c/hashmap/_config.yml +1 -0
- data/vendor/c/hashmap/src/hashmap.c +692 -0
- data/vendor/c/hashmap/src/hashmap.h +267 -0
- data/vendor/c/hashmap/test/Makefile +22 -0
- data/vendor/c/hashmap/test/hashmap_test.c +608 -0
- data/vendor/c/jsmn/.travis.yml +4 -0
- data/vendor/c/jsmn/LICENSE +20 -0
- data/vendor/c/jsmn/Makefile +41 -0
- data/vendor/c/jsmn/README.md +168 -0
- data/vendor/c/jsmn/example/jsondump.c +126 -0
- data/vendor/c/jsmn/example/simple.c +76 -0
- data/vendor/c/jsmn/jsmn.c +314 -0
- data/vendor/c/jsmn/jsmn.h +76 -0
- data/vendor/c/jsmn/library.json +16 -0
- data/vendor/c/jsmn/test/test.h +27 -0
- data/vendor/c/jsmn/test/tests.c +407 -0
- data/vendor/c/jsmn/test/testutil.h +94 -0
- metadata +243 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
# Prerequisites
|
2
|
+
*.d
|
3
|
+
|
4
|
+
# Object files
|
5
|
+
*.o
|
6
|
+
*.ko
|
7
|
+
*.obj
|
8
|
+
*.elf
|
9
|
+
|
10
|
+
# Linker output
|
11
|
+
*.ilk
|
12
|
+
*.map
|
13
|
+
*.exp
|
14
|
+
|
15
|
+
# Precompiled Headers
|
16
|
+
*.gch
|
17
|
+
*.pch
|
18
|
+
|
19
|
+
# Libraries
|
20
|
+
*.lib
|
21
|
+
*.a
|
22
|
+
*.la
|
23
|
+
*.lo
|
24
|
+
|
25
|
+
# Shared objects (inc. Windows DLLs)
|
26
|
+
*.dll
|
27
|
+
*.so
|
28
|
+
*.so.*
|
29
|
+
*.dylib
|
30
|
+
|
31
|
+
# Executables
|
32
|
+
*.exe
|
33
|
+
*.out
|
34
|
+
*.app
|
35
|
+
*.i*86
|
36
|
+
*.x86_64
|
37
|
+
*.hex
|
38
|
+
|
39
|
+
# Debug files
|
40
|
+
*.dSYM/
|
41
|
+
*.su
|
42
|
+
*.idb
|
43
|
+
*.pdb
|
44
|
+
|
45
|
+
# Kernel Module Compile Results
|
46
|
+
*.mod*
|
47
|
+
*.cmd
|
48
|
+
.tmp_versions/
|
49
|
+
modules.order
|
50
|
+
Module.symvers
|
51
|
+
Mkfile.old
|
52
|
+
dkms.conf
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 David Leeds
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# hashmap
|
2
|
+
Flexible hashmap implementation in C using open addressing and linear probing for collision resolution.
|
3
|
+
|
4
|
+
### Summary
|
5
|
+
This project came into existence because there are a notable lack of flexible and easy to use data structures available in C. Sure, higher level languages have built-in libraries, but plenty of embedded projects or higher level libraries start with core C code. It was undesirable to add a bulky library like Glib as a dependency to my projects, or grapple with a restrictive license agreement. Searching for "C hashmap" yielded results with questionable algorithms and code quality, projects with difficult or inflexible interfaces, or projects with less desirable licenses. I decided it was time to create my own.
|
6
|
+
|
7
|
+
|
8
|
+
### Goals
|
9
|
+
* **To scale gracefully to the full capacity of the numeric primitives in use.** E.g. on a 32-bit machine, you should be able to load a billion+ entries without hitting any bugs relating to integer overflows. Lookups on a hashtable with a billion entries should be performed in close to constant time, no different than lookups in a hashtable with 20 entries. Automatic rehashing occurs and maintains a load factor of 0.75 or less.
|
10
|
+
* **To provide a clean and easy-to-use interface.** C data structures often struggle to strike a balance between flexibility and ease of use. To this end, I provided a generic interface using void pointers for keys and data, and macros to generate type-specific wrapper functions, if desired.
|
11
|
+
* **To enable easy iteration and safe entry removal during iteration.** Applications often need these features, and the data structure should not hold them back. Both an iterator interface and a foreach function was provided to satisfy various use-cases. This hashmap also uses an open addressing scheme, which has superior iteration performance to a similar hashmap implemented using separate chaining (buckets with linked lists). This is because fewer instructions are needed per iteration, and array traversal has superior cache performance than linked list traversal.
|
12
|
+
* **To use a very unrestrictive software license.** Using no license was an option, but I wanted to allow the code to be tracked, simply for my own edification. I chose the MIT license because it is the most common open source license in use, and it grants full rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell the code. Basically, take this code and do what you want with it. Just be nice and leave the license comment and my name at top of the file. Feel free to add your name if you are modifying and redistributing.
|
13
|
+
|
14
|
+
### Code Example
|
15
|
+
```C
|
16
|
+
#include <stdlib.h>
|
17
|
+
#include <stdio.h>
|
18
|
+
|
19
|
+
#include <hashmap.h>
|
20
|
+
|
21
|
+
/* Some sample data structure with a string key */
|
22
|
+
struct blob {
|
23
|
+
char key[32];
|
24
|
+
size_t data_len;
|
25
|
+
unsigned char data[1024];
|
26
|
+
};
|
27
|
+
|
28
|
+
/* Declare type-specific blob_hashmap_* functions with this handy macro */
|
29
|
+
HASHMAP_FUNCS_CREATE(blob, const char, struct blob)
|
30
|
+
|
31
|
+
struct blob *blob_load(void)
|
32
|
+
{
|
33
|
+
struct blob *b;
|
34
|
+
/*
|
35
|
+
* Hypothetical function that allocates and loads blob structures
|
36
|
+
* from somewhere. Returns NULL when there are no more blobs to load.
|
37
|
+
*/
|
38
|
+
return b;
|
39
|
+
}
|
40
|
+
|
41
|
+
/* Hashmap structure */
|
42
|
+
struct hashmap map;
|
43
|
+
|
44
|
+
int main(int argc, char **argv)
|
45
|
+
{
|
46
|
+
struct blob *b;
|
47
|
+
struct hashmap_iter *iter;
|
48
|
+
|
49
|
+
/* Initialize with default string key functions and init size */
|
50
|
+
hashmap_init(&map, hashmap_hash_string, hashmap_compare_string, 0);
|
51
|
+
|
52
|
+
/* Load some sample data into the map and discard duplicates */
|
53
|
+
while ((b = blob_load()) != NULL) {
|
54
|
+
if (blob_hashmap_put(&map, b->key, b) != b) {
|
55
|
+
printf("discarding blob with duplicate key: %s\n", b->key);
|
56
|
+
free(b);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
/* Lookup a blob with key "AbCdEf" */
|
61
|
+
b = blob_hashmap_get(&map, "AbCdEf");
|
62
|
+
if (b) {
|
63
|
+
printf("Found blob[%s]\n", b->key);
|
64
|
+
}
|
65
|
+
|
66
|
+
/* Iterate through all blobs and print each one */
|
67
|
+
for (iter = hashmap_iter(&map); iter; iter = hashmap_iter_next(&map, iter)) {
|
68
|
+
printf("blob[%s]: data_len %zu bytes\n", blob_hashmap_iter_get_key(iter),
|
69
|
+
blob_hashmap_iter_get_data(iter)->data_len);
|
70
|
+
}
|
71
|
+
|
72
|
+
/* Remove all blobs with no data */
|
73
|
+
iter = hashmap_iter(&map);
|
74
|
+
while (iter) {
|
75
|
+
b = blob_hashmap_iter_get_data(iter);
|
76
|
+
if (b->data_len == 0) {
|
77
|
+
iter = hashmap_iter_remove(&map, iter);
|
78
|
+
free(b);
|
79
|
+
} else {
|
80
|
+
iter = hashmap_iter_next(&map, iter);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
/* Free all allocated resources associated with map and reset its state */
|
85
|
+
hashmap_destroy(&map);
|
86
|
+
|
87
|
+
return 0;
|
88
|
+
}
|
89
|
+
|
90
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-slate
|