-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsparse_vector--0.1.sql
39 lines (30 loc) · 1.19 KB
/
sparse_vector--0.1.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
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION sparse_vector" to load this file. \quit
-- sparse_vector type
CREATE TYPE sparse_vector;
CREATE FUNCTION sparse_vector_in(cstring)
RETURNS sparse_vector
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION sparse_vector_out(sparse_vector)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE TYPE sparse_vector (
INTERNALLENGTH = variable,
INPUT = sparse_vector_in,
OUTPUT = sparse_vector_out,
ALIGNMENT = double
);
CREATE FUNCTION sparse_vector(float4[]) RETURNS sparse_vector
AS 'MODULE_PATHNAME', 'sparse_vector_a_f4'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION sparse_vector_norm(float4[]) RETURNS sparse_vector
AS 'MODULE_PATHNAME', 'sparse_vector_a_f4_norm'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION dot_product(sparse_vector, sparse_vector) RETURNS float4
AS 'MODULE_PATHNAME', 'sparse_vector_dot_product'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION cosine_similarity(sparse_vector, sparse_vector) RETURNS float4
AS 'MODULE_PATHNAME', 'sparse_vector_cosine_similarity'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;