-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathimgsmlr--1.0.sql
executable file
·142 lines (116 loc) · 3.35 KB
/
imgsmlr--1.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* imgsmlr/imgsmlr--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION imgsmlr" to load this file. \quit
--
-- PostgreSQL code for IMGSMLR.
--
CREATE FUNCTION pattern_in(cstring)
RETURNS pattern
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION pattern_out(pattern)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE TYPE pattern (
INTERNALLENGTH = -1,
INPUT = pattern_in,
OUTPUT = pattern_out,
STORAGE = extended
);
CREATE FUNCTION signature_in(cstring)
RETURNS signature
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_out(signature)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE TYPE signature (
INTERNALLENGTH = 64,
INPUT = signature_in,
OUTPUT = signature_out,
ALIGNMENT = float
);
CREATE FUNCTION jpeg2pattern(bytea)
RETURNS pattern
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION png2pattern(bytea)
RETURNS pattern
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION gif2pattern(bytea)
RETURNS pattern
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION pattern2signature(pattern)
RETURNS signature
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION pattern_distance(pattern, pattern)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_distance(signature, signature)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR <-> (
LEFTARG = pattern,
RIGHTARG = pattern,
PROCEDURE = pattern_distance
);
CREATE OPERATOR <-> (
LEFTARG = signature,
RIGHTARG = signature,
PROCEDURE = signature_distance
);
CREATE FUNCTION shuffle_pattern(pattern)
RETURNS pattern
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_consistent(internal,signature,int,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_union(internal, internal)
RETURNS bytea
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_same(bytea, bytea, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION signature_gist_distance(internal, text, int, oid)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR CLASS gist_signature_ops
DEFAULT FOR TYPE signature USING gist AS
OPERATOR 1 <-> FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 signature_consistent (internal, signature, int, oid, internal),
FUNCTION 2 signature_union (internal, internal),
FUNCTION 3 signature_compress (internal),
FUNCTION 4 signature_decompress (internal),
FUNCTION 5 signature_penalty (internal, internal, internal),
FUNCTION 6 signature_picksplit (internal, internal),
FUNCTION 7 signature_same (bytea, bytea, internal),
FUNCTION 8 signature_gist_distance (internal, text, int, oid),
STORAGE bytea;