-
Notifications
You must be signed in to change notification settings - Fork 13
/
tdigest--1.0.1--1.2.0.sql
89 lines (77 loc) · 3.48 KB
/
tdigest--1.0.1--1.2.0.sql
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
CREATE OR REPLACE FUNCTION tdigest_add_double_count(p_pointer internal, p_element double precision, p_count bigint, p_compression int)
RETURNS internal
AS 'tdigest', 'tdigest_add_double_count'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_add_double_count(p_pointer internal, p_element double precision, p_count bigint, p_compression int, p_quantile double precision)
RETURNS internal
AS 'tdigest', 'tdigest_add_double_count'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_add_double_array_count(p_pointer internal, p_element double precision, p_count bigint, p_compression int, p_quantile double precision[])
RETURNS internal
AS 'tdigest', 'tdigest_add_double_array_count'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_add_double_values_count(p_pointer internal, p_element double precision, p_count bigint, p_compression int, p_value double precision)
RETURNS internal
AS 'tdigest', 'tdigest_add_double_values_count'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_add_double_array_values_count(p_pointer internal, p_element double precision, p_count bigint, p_compression int, p_value double precision[])
RETURNS internal
AS 'tdigest', 'tdigest_add_double_array_values_count'
LANGUAGE C IMMUTABLE;
CREATE AGGREGATE tdigest(double precision, bigint, int) (
SFUNC = tdigest_add_double_count,
STYPE = internal,
FINALFUNC = tdigest_digest,
SERIALFUNC = tdigest_serial,
DESERIALFUNC = tdigest_deserial,
COMBINEFUNC = tdigest_combine,
PARALLEL = SAFE
);
CREATE AGGREGATE tdigest_percentile(double precision, bigint, int, double precision) (
SFUNC = tdigest_add_double_count,
STYPE = internal,
FINALFUNC = tdigest_percentiles,
SERIALFUNC = tdigest_serial,
DESERIALFUNC = tdigest_deserial,
COMBINEFUNC = tdigest_combine,
PARALLEL = SAFE
);
CREATE AGGREGATE tdigest_percentile(double precision, bigint, int, double precision[]) (
SFUNC = tdigest_add_double_array_count,
STYPE = internal,
FINALFUNC = tdigest_array_percentiles,
SERIALFUNC = tdigest_serial,
DESERIALFUNC = tdigest_deserial,
COMBINEFUNC = tdigest_combine,
PARALLEL = SAFE
);
CREATE AGGREGATE tdigest_percentile_of(double precision, bigint, int, double precision) (
SFUNC = tdigest_add_double_values_count,
STYPE = internal,
FINALFUNC = tdigest_percentiles_of,
SERIALFUNC = tdigest_serial,
DESERIALFUNC = tdigest_deserial,
COMBINEFUNC = tdigest_combine,
PARALLEL = SAFE
);
CREATE AGGREGATE tdigest_percentile_of(double precision, bigint, int, double precision[]) (
SFUNC = tdigest_add_double_array_values_count,
STYPE = internal,
FINALFUNC = tdigest_array_percentiles_of,
SERIALFUNC = tdigest_serial,
DESERIALFUNC = tdigest_deserial,
COMBINEFUNC = tdigest_combine,
PARALLEL = SAFE
);
CREATE OR REPLACE FUNCTION tdigest_add(p_digest tdigest, p_element double precision, p_compression int = NULL, p_compact bool = true)
RETURNS tdigest
AS 'tdigest', 'tdigest_add_double_increment'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_add(p_digest tdigest, p_elements double precision[], p_compression int = NULL, p_compact bool = true)
RETURNS tdigest
AS 'tdigest', 'tdigest_add_double_array_increment'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION tdigest_union(p_digest1 tdigest, p_digest2 tdigest, p_compact bool = true)
RETURNS tdigest
AS 'tdigest', 'tdigest_union_double_increment'
LANGUAGE C IMMUTABLE;