Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vislee/lua-resty-hyperloglog
Hyperloglog for openresty.
https://github.com/vislee/lua-resty-hyperloglog
hll hyperloglog lua-resty
Last synced: about 1 month ago
JSON representation
Hyperloglog for openresty.
- Host: GitHub
- URL: https://github.com/vislee/lua-resty-hyperloglog
- Owner: vislee
- License: bsd-2-clause
- Created: 2021-06-05T02:27:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-05T07:30:17.000Z (over 3 years ago)
- Last Synced: 2024-02-15T02:32:00.026Z (10 months ago)
- Topics: hll, hyperloglog, lua-resty
- Language: Lua
- Homepage:
- Size: 65.4 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-resty - lua-resty-hyperloglog - hyperloglog for openresty. (Libraries)
README
# lua-resty-hyperloglog
`lua-resty-hyperloglog` is hyperloglog for openresty.
Table of Contents
=================
* [Status](#status)
* [Synopsis](#Synopsis)
* [Methods](#methods)
* [new](#new)
* [insert](#insert)
* [count](#count)
* [merge](#merge)
* [close](#close)
* [Author](#author)
* [Copyright and License](#copyright-and-license)Status
======This library is still under early development and is still experimental.
Synopsis
========```nginx
http {
...
lua_shared_dict hll_count 10m;
init_by_lua_block {
local hll = require "resty.hyperloglog"
h = hll.new("hll_count", 12)
}server {
listen 8080;location / {
access_by_lua_block {
h:insert(ngx.var.uri)
}...
}location = /stats {
content_by_lua_block {
ngx.print("count:", h:count())
ngx.exit(ngx.HTTP_OK)
}
}
}
}```
[Back to TOC](#table-of-contents)
Methods
=======new
---
`syntax: h, err = hll.new(name, log2m)`Create a hyperloglog object with 2^log2m bucket. Returns `nil` on error.
insert
------
`syntax: h:insert(str)`Insert a string to hyperloglog object.
count
-----
`syntax: c = h:count()`Returns the cardinality of the hyperloglog object.
merge
-----
`syntax: ok, err = h:merge(h2)`Merge another hyperloglog object(h2) into h. Returns `false` on error.
close
-----
`syntax: h:close()`Close the hyperloglog object.
[Back to TOC](#table-of-contents)
Author
======wenqiang li(vislee)
[Back to TOC](#table-of-contents)
Copyright and License
=====================This module is licensed under the BSD License.
Copyright (C) by vislee.
All rights reserved.
[Back to TOC](#table-of-contents)