Skip to main content
Version: I2023.3.0

Db2 SQL Script

CREATE OR REPLACE PROCEDURE hllagg_initialize(OUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!initialize';

CREATE OR REPLACE PROCEDURE hllagg_accumulate_int(IN value INTEGER, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!accumulate_int';

CREATE OR REPLACE PROCEDURE hllagg_accumulate_dbl(IN value DOUBLE, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!accumulate_dbl';

CREATE OR REPLACE PROCEDURE hllagg_accumulate_flt(IN value REAL, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!accumulate_flt';

CREATE OR REPLACE PROCEDURE hllagg_accumulate_lng(IN value BIGINT, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!accumulate_lng';

CREATE OR REPLACE PROCEDURE hllagg_accumulate_str(IN value VARCHAR(4000), INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!accumulate_str';

CREATE OR REPLACE PROCEDURE hllagg_merge(IN obuffer VARCHAR(22000) FOR BIT DATA, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate!merge';

CREATE OR REPLACE FUNCTION hllagg_finalize(buffer VARCHAR(22000) FOR BIT DATA)
RETURNS VARCHAR(32670)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
NO SCRATCHPAD
CALLED ON NULL INPUT
EXTERNAL NAME 'hll_aggregate!finalize';

CREATE OR REPLACE FUNCTION hll_aggregate(INTEGER)
RETURNS VARCHAR(32670)
SPECIFIC hllagg_int
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllagg_initialize
ACCUMULATE PROCEDURE hllagg_accumulate_int
MERGE PROCEDURE hllagg_merge
FINALIZE FUNCTION hllagg_finalize;

CREATE OR REPLACE FUNCTION hll_aggregate(BIGINT)
RETURNS VARCHAR(32670)
SPECIFIC hllagg_lng
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllagg_initialize
ACCUMULATE PROCEDURE hllagg_accumulate_lng
MERGE PROCEDURE hllagg_merge
FINALIZE FUNCTION hllagg_finalize;

CREATE OR REPLACE FUNCTION hll_aggregate(DOUBLE)
RETURNS VARCHAR(32670)
SPECIFIC hllagg_dbl
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllagg_initialize
ACCUMULATE PROCEDURE hllagg_accumulate_dbl
MERGE PROCEDURE hllagg_merge
FINALIZE FUNCTION hllagg_finalize;

CREATE OR REPLACE FUNCTION hll_aggregate(REAL)
RETURNS VARCHAR(32670)
SPECIFIC hllagg_flt
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllagg_initialize
ACCUMULATE PROCEDURE hllagg_accumulate_flt
MERGE PROCEDURE hllagg_merge
FINALIZE FUNCTION hllagg_finalize;

CREATE OR REPLACE FUNCTION hll_aggregate(VARCHAR(4000))
RETURNS VARCHAR(32670)
SPECIFIC hllagg_str
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllagg_initialize
ACCUMULATE PROCEDURE hllagg_accumulate_str
MERGE PROCEDURE hllagg_merge
FINALIZE FUNCTION hllagg_finalize;


-- estimate

CREATE OR REPLACE PROCEDURE hllest_initialize(OUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!initialize';

CREATE OR REPLACE PROCEDURE hllest_accumulate_int(IN value INTEGER, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!accumulate_int';

CREATE OR REPLACE PROCEDURE hllest_accumulate_dbl(IN value DOUBLE, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!accumulate_dbl';

CREATE OR REPLACE PROCEDURE hllest_accumulate_flt(IN value REAL, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!accumulate_flt';

CREATE OR REPLACE PROCEDURE hllest_accumulate_lng(IN value BIGINT, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!accumulate_lng';

CREATE OR REPLACE PROCEDURE hllest_accumulate_str(IN value VARCHAR(4000), INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!accumulate_str';

CREATE OR REPLACE PROCEDURE hllest_merge(IN obuffer VARCHAR(22000) FOR BIT DATA, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_estimate!merge';

CREATE OR REPLACE FUNCTION hllest_finalize(buffer VARCHAR(22000) FOR BIT DATA)
RETURNS BIGINT
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
NO SCRATCHPAD
CALLED ON NULL INPUT
EXTERNAL NAME 'hll_estimate!finalize';

CREATE OR REPLACE FUNCTION hll_estimate(INTEGER)
RETURNS BIGINT
SPECIFIC hllest_int
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllest_initialize
ACCUMULATE PROCEDURE hllest_accumulate_int
MERGE PROCEDURE hllest_merge
FINALIZE FUNCTION hllest_finalize;

CREATE OR REPLACE FUNCTION hll_estimate(BIGINT)
RETURNS BIGINT
SPECIFIC hllest_lng
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllest_initialize
ACCUMULATE PROCEDURE hllest_accumulate_lng
MERGE PROCEDURE hllest_merge
FINALIZE FUNCTION hllest_finalize;

CREATE OR REPLACE FUNCTION hll_estimate(DOUBLE)
RETURNS BIGINT
SPECIFIC hllest_dbl
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllest_initialize
ACCUMULATE PROCEDURE hllest_accumulate_dbl
MERGE PROCEDURE hllest_merge
FINALIZE FUNCTION hllest_finalize;

CREATE OR REPLACE FUNCTION hll_estimate(REAL)
RETURNS BIGINT
SPECIFIC hllest_flt
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllest_initialize
ACCUMULATE PROCEDURE hllest_accumulate_flt
MERGE PROCEDURE hllest_merge
FINALIZE FUNCTION hllest_finalize;

CREATE OR REPLACE FUNCTION hll_estimate(VARCHAR(4000))
RETURNS BIGINT
SPECIFIC hllest_str
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllest_initialize
ACCUMULATE PROCEDURE hllest_accumulate_str
MERGE PROCEDURE hllest_merge
FINALIZE FUNCTION hllest_finalize;


-- agg estimate

CREATE OR REPLACE PROCEDURE hllaggest_initialize(OUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_estimate!initialize';

CREATE OR REPLACE PROCEDURE hllaggest_accumulate(IN value VARCHAR(32670), INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_estimate!accumulate';

CREATE OR REPLACE PROCEDURE hllaggest_merge(IN obuffer VARCHAR(22000) FOR BIT DATA, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_estimate!merge';

CREATE OR REPLACE FUNCTION hllaggest_finalize(buffer VARCHAR(22000) FOR BIT DATA)
RETURNS BIGINT
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
NO SCRATCHPAD
CALLED ON NULL INPUT
EXTERNAL NAME 'hll_aggregate_estimate!finalize';

CREATE OR REPLACE FUNCTION hll_aggregate_estimate(IN value VARCHAR(32670))
RETURNS BIGINT
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllaggest_initialize
ACCUMULATE PROCEDURE hllaggest_accumulate
MERGE PROCEDURE hllaggest_merge
FINALIZE FUNCTION hllaggest_finalize;

-- agg merge

CREATE OR REPLACE PROCEDURE hllaggmerge_initialize(OUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_merge!initialize';

CREATE OR REPLACE PROCEDURE hllaggmerge_accumulate(IN value VARCHAR(32670), INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_merge!accumulate';

CREATE OR REPLACE PROCEDURE hllaggmerge_merge(IN obuffer VARCHAR(22000) FOR BIT DATA, INOUT buffer VARCHAR(22000) FOR BIT DATA)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
EXTERNAL NAME 'hll_aggregate_merge!merge';

CREATE OR REPLACE FUNCTION hllaggmerge_finalize(buffer VARCHAR(22000) FOR BIT DATA)
RETURNS VARCHAR(32670)
LANGUAGE C
PARAMETER STYLE SQL
NOT FENCED THREADSAFE
NO SQL
NO SCRATCHPAD
CALLED ON NULL INPUT
EXTERNAL NAME 'hll_aggregate_merge!finalize';

CREATE OR REPLACE FUNCTION hll_aggregate_merge(IN value VARCHAR(32670))
RETURNS VARCHAR(32670)
AGGREGATE WITH (buffer VARCHAR(22000) FOR BIT DATA)
USING
INITIALIZE PROCEDURE hllaggmerge_initialize
ACCUMULATE PROCEDURE hllaggmerge_accumulate
MERGE PROCEDURE hllaggmerge_merge
FINALIZE FUNCTION hllaggmerge_finalize;


-- version check

CREATE OR REPLACE FUNCTION atscale_honeybee_version()
RETURNS VARCHAR(1000)
LANGUAGE C
PARAMETER STYLE SQL
FENCED THREADSAFE
NO SQL
NO EXTERNAL ACTION
EXTERNAL NAME 'honeybee_version!version';