1{
2 boost186,
3 fetchFromGitHub,
4 lib,
5 postgresql,
6 postgresqlBuildExtension,
7 postgresqlTestExtension,
8}:
9
10let
11 version = "1.7.0";
12
13 main_src = fetchFromGitHub {
14 name = "datasketches-postgresql";
15 owner = "apache";
16 repo = "datasketches-postgresql";
17 tag = version;
18 hash = "sha256-W41uAs3W4V7c9O/wBw3rut65bcmY8EdQS1/tPszMGqA=";
19 };
20
21 cpp_src = fetchFromGitHub {
22 name = "datasketches-cpp";
23 owner = "apache";
24 repo = "datasketches-cpp";
25 tag = "5.0.2";
26 hash = "sha256-yGk1OckYipAgLTQK6w6p6EdHMxBIQSjPV/MMND3cDks=";
27 };
28in
29
30postgresqlBuildExtension (finalAttrs: {
31 pname = "apache_datasketches";
32 inherit version;
33
34 srcs = [
35 main_src
36 cpp_src
37 ];
38
39 sourceRoot = main_src.name;
40
41 # fails to build with boost 1.87
42 buildInputs = [ boost186 ];
43
44 patchPhase = ''
45 runHook prePatch
46 cp -r ../${cpp_src.name} .
47 runHook postPatch
48 '';
49
50 enableUpdateScript = false;
51 passthru.tests.extension = postgresqlTestExtension {
52 inherit (finalAttrs) finalPackage;
53 sql = ''
54 CREATE EXTENSION datasketches;
55 SELECT hll_sketch_to_string(hll_sketch_build(1));
56 '';
57 };
58
59 meta = {
60 description = "PostgreSQL extension providing approximate algorithms for distinct item counts, quantile estimation and frequent items detection";
61 longDescription = ''
62 apache_datasketches is an extension to support approximate algorithms on PostgreSQL. The implementation
63 is based on the Apache Datasketches CPP library, and provides support for HyperLogLog,
64 Compressed Probabilistic Counting, KLL, Frequent strings, and Theta sketches.
65 '';
66 homepage = "https://datasketches.apache.org/";
67 platforms = postgresql.meta.platforms;
68 license = lib.licenses.asl20;
69 maintainers = with lib.maintainers; [ mmusnjak ];
70 };
71})