File: index.md

package info (click to toggle)
lua-sandbox-extensions 0~git20161128-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,596 kB
  • ctags: 1,458
  • sloc: ansic: 4,402; cpp: 2,102; makefile: 8
file content (125 lines) | stat: -rw-r--r-- 2,098 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Lua HyperLogLog Module

## Overview
HyperLogLog is an algorithm for the count-distinct problem, approximating the
number of distinct elements in a multiset (the cardinality).

## Module

### Example Usage
```lua
require "hyperloglog"

local hll = hyperloglog.new()
hll:add("test")
local estimate = hll:count()
-- estimate == 1

```

### Functions

#### new
```lua
require "hyperloglog"
local hll = hyperloglog.new()
```

Import Lua _hyperloglog_ via the Lua 'require' function. The module is
globally registered and returned by the require function. The _new_ function
takes no arguments and returns a hyperloglog userdata object.

#### version
```lua
local v = hyperloglog.version()
-- v == "0.1.0"
```

Returns a string with the running version of hyperloglog.

*Arguments*
- none

*Return*
- Semantic version string

#### count
```lua
local estimate = hyperloglog.count(hll, hll1, ... hlln)
```

Returns the approximated number of distinct items in the merged set.

*Arguments*
- hyperloglog (userdata) - Two or more hyperloglog userdata objects.

*Return*
- estimate (number) - count of distinct items.


### Methods

#### add
```lua
local altered = hll:add(key)
```

Adds an item to the hyperloglog.

*Arguments*
- key (string/number) The item key to add to the hyperloglog.

*Return*
- True if the estimate was altered, false if it remains unchanged.

#### merge
```lua
hll:merge(hll1)
```

Merges the provided hyperloglog into the current object.

*Arguments*
- hyperloglog (userdata) A single hyperloglog object to be merged.

*Return*
- self (userdata)

#### count
```lua
local estimate = hll:count()
```

Returns the approximated number of distinct items in the set.

*Arguments*
- none

*Return*
- estimate (number) - count of distinct items.

#### clear
```lua
hll:clear()
```

Resets the hyperloglog to an empty set.

*Arguments*
- none

*Return*
- none

#### fromstring
```lua
hll:fromstring(str)
```

Loads the tostring() representation back into a hyperloglog user data object.

*Arguments*
- hll_str (string) - hyperloglog representation generated by tostring()

*Return*
- none