ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/bioseg/trunk/bioseg.sql
Revision: 21
Committed: Mon Apr 7 10:42:42 2008 UTC (10 years, 6 months ago) by kmr
File size: 9017 byte(s)
Log Message:
Documentation fixes.

Line File contents
1 -- Create the user-defined type for integer intervals (bioseg)
2 --
3
4 -- Adjust this setting to control where the objects get created.
5 SET search_path = public;
6
7 CREATE FUNCTION bioseg_in(cstring)
8 RETURNS bioseg
9 AS '$libdir/bioseg'
10 LANGUAGE C STRICT IMMUTABLE;
11
12 CREATE FUNCTION bioseg_out(bioseg)
13 RETURNS cstring
14 AS '$libdir/bioseg'
15 LANGUAGE C STRICT IMMUTABLE;
16
17 CREATE FUNCTION bioseg_create(int4, int4)
18 RETURNS bioseg
19 AS '$libdir/bioseg'
20 LANGUAGE C STRICT IMMUTABLE;
21
22 CREATE TYPE bioseg (
23 INTERNALLENGTH = 8,
24 INPUT = bioseg_in,
25 OUTPUT = bioseg_out
26 );
27
28 COMMENT ON TYPE bioseg IS
29 'integer point interval ''INT..INT'', ''INT...INT'', or ''INT''';
30
31 --
32 -- External C-functions for R-tree methods
33 --
34
35 -- Left/Right methods
36
37 CREATE FUNCTION bioseg_over_left(bioseg, bioseg)
38 RETURNS bool
39 AS '$libdir/bioseg'
40 LANGUAGE C STRICT IMMUTABLE;
41
42 COMMENT ON FUNCTION bioseg_over_left(bioseg, bioseg) IS
43 'overlaps or is left of';
44
45 CREATE FUNCTION bioseg_over_right(bioseg, bioseg)
46 RETURNS bool
47 AS '$libdir/bioseg'
48 LANGUAGE C STRICT IMMUTABLE;
49
50 COMMENT ON FUNCTION bioseg_over_right(bioseg, bioseg) IS
51 'overlaps or is right of';
52
53 CREATE FUNCTION bioseg_left(bioseg, bioseg)
54 RETURNS bool
55 AS '$libdir/bioseg'
56 LANGUAGE C STRICT IMMUTABLE;
57
58 COMMENT ON FUNCTION bioseg_left(bioseg, bioseg) IS
59 'is left of';
60
61 CREATE FUNCTION bioseg_right(bioseg, bioseg)
62 RETURNS bool
63 AS '$libdir/bioseg'
64 LANGUAGE C STRICT IMMUTABLE;
65
66 COMMENT ON FUNCTION bioseg_right(bioseg, bioseg) IS
67 'is right of';
68
69
70 -- Scalar comparison methods
71
72 CREATE FUNCTION bioseg_lt(bioseg, bioseg)
73 RETURNS bool
74 AS '$libdir/bioseg'
75 LANGUAGE C STRICT IMMUTABLE;
76
77 COMMENT ON FUNCTION bioseg_lt(bioseg, bioseg) IS
78 'less than';
79
80 CREATE FUNCTION bioseg_le(bioseg, bioseg)
81 RETURNS bool
82 AS '$libdir/bioseg'
83 LANGUAGE C STRICT IMMUTABLE;
84
85 COMMENT ON FUNCTION bioseg_le(bioseg, bioseg) IS
86 'less than or equal';
87
88 CREATE FUNCTION bioseg_gt(bioseg, bioseg)
89 RETURNS bool
90 AS '$libdir/bioseg'
91 LANGUAGE C STRICT IMMUTABLE;
92
93 COMMENT ON FUNCTION bioseg_gt(bioseg, bioseg) IS
94 'greater than';
95
96 CREATE FUNCTION bioseg_ge(bioseg, bioseg)
97 RETURNS bool
98 AS '$libdir/bioseg'
99 LANGUAGE C STRICT IMMUTABLE;
100
101 COMMENT ON FUNCTION bioseg_ge(bioseg, bioseg) IS
102 'greater than or equal';
103
104 CREATE FUNCTION bioseg_contains(bioseg, bioseg)
105 RETURNS bool
106 AS '$libdir/bioseg'
107 LANGUAGE C STRICT IMMUTABLE;
108
109 COMMENT ON FUNCTION bioseg_contains(bioseg, bioseg) IS
110 'contains';
111
112 CREATE FUNCTION bioseg_contained(bioseg, bioseg)
113 RETURNS bool
114 AS '$libdir/bioseg'
115 LANGUAGE C STRICT IMMUTABLE;
116
117 COMMENT ON FUNCTION bioseg_contained(bioseg, bioseg) IS
118 'contained in';
119
120 CREATE FUNCTION bioseg_overlap(bioseg, bioseg)
121 RETURNS bool
122 AS '$libdir/bioseg'
123 LANGUAGE C STRICT IMMUTABLE;
124
125 COMMENT ON FUNCTION bioseg_overlap(bioseg, bioseg) IS
126 'overlaps';
127
128 CREATE FUNCTION bioseg_same(bioseg, bioseg)
129 RETURNS bool
130 AS '$libdir/bioseg'
131 LANGUAGE C STRICT IMMUTABLE;
132
133 COMMENT ON FUNCTION bioseg_same(bioseg, bioseg) IS
134 'same as';
135
136 CREATE FUNCTION bioseg_different(bioseg, bioseg)
137 RETURNS bool
138 AS '$libdir/bioseg'
139 LANGUAGE C STRICT IMMUTABLE;
140
141 COMMENT ON FUNCTION bioseg_different(bioseg, bioseg) IS
142 'different';
143
144 -- support routines for indexing
145
146 CREATE OR REPLACE FUNCTION bioseg_cmp(bioseg, bioseg)
147 RETURNS int4
148 AS '$libdir/bioseg'
149 LANGUAGE C STRICT IMMUTABLE;
150
151 COMMENT ON FUNCTION bioseg_cmp(bioseg, bioseg) IS 'btree comparison function';
152
153 CREATE FUNCTION bioseg_size(bioseg)
154 RETURNS int4
155 AS '$libdir/bioseg'
156 LANGUAGE C STRICT IMMUTABLE;
157
158 -- miscellaneous
159
160 CREATE FUNCTION bioseg_upper(bioseg)
161 RETURNS int4
162 AS '$libdir/bioseg'
163 LANGUAGE C STRICT IMMUTABLE;
164
165 CREATE FUNCTION bioseg_lower(bioseg)
166 RETURNS int4
167 AS '$libdir/bioseg'
168 LANGUAGE C STRICT IMMUTABLE;
169
170 CREATE FUNCTION bioseg_sel(internal, oid, internal, integer)
171 RETURNS float
172 AS '$libdir/bioseg'
173 LANGUAGE C STRICT IMMUTABLE;
174
175 CREATE FUNCTION bioseg_joinsel(internal, oid, internal, smallint)
176 RETURNS FLOAT
177 AS '$libdir/bioseg'
178 LANGUAGE C STRICT IMMUTABLE;
179
180 CREATE FUNCTION bioseg_contsel(internal, oid, internal, integer)
181 RETURNS float
182 AS '$libdir/bioseg'
183 LANGUAGE C STRICT IMMUTABLE;
184
185 CREATE FUNCTION bioseg_contjoinsel(internal, oid, internal, smallint)
186 RETURNS FLOAT
187 AS '$libdir/bioseg'
188 LANGUAGE C STRICT IMMUTABLE;
189
190
191 --
192 -- OPERATORS
193 --
194
195 CREATE OPERATOR < (
196 LEFTARG = bioseg,
197 RIGHTARG = bioseg,
198 PROCEDURE = bioseg_lt,
199 COMMUTATOR = '>',
200 NEGATOR = '>=',
201 RESTRICT = scalarltsel,
202 JOIN = scalarltjoinsel
203 );
204
205 CREATE OPERATOR <= (
206 LEFTARG = bioseg,
207 RIGHTARG = bioseg,
208 PROCEDURE = bioseg_le,
209 COMMUTATOR = '>=',
210 NEGATOR = '>',
211 RESTRICT = scalarltsel,
212 JOIN = scalarltjoinsel
213 );
214
215 CREATE OPERATOR > (
216 LEFTARG = bioseg,
217 RIGHTARG = bioseg,
218 PROCEDURE = bioseg_gt,
219 COMMUTATOR = '<',
220 NEGATOR = '<=',
221 RESTRICT = scalargtsel,
222 JOIN = scalargtjoinsel
223 );
224
225 CREATE OPERATOR >= (
226 LEFTARG = bioseg,
227 RIGHTARG = bioseg,
228 PROCEDURE = bioseg_ge,
229 COMMUTATOR = '<=',
230 NEGATOR = '<',
231 RESTRICT = scalargtsel,
232 JOIN = scalargtjoinsel
233 );
234
235 CREATE OPERATOR << (
236 LEFTARG = bioseg,
237 RIGHTARG = bioseg,
238 PROCEDURE = bioseg_left,
239 COMMUTATOR = '>>',
240 RESTRICT = positionsel,
241 JOIN = positionjoinsel
242 );
243
244 CREATE OPERATOR &< (
245 LEFTARG = bioseg,
246 RIGHTARG = bioseg,
247 PROCEDURE = bioseg_over_left,
248 RESTRICT = positionsel,
249 JOIN = positionjoinsel
250 );
251
252 CREATE OPERATOR && (
253 LEFTARG = bioseg,
254 RIGHTARG = bioseg,
255 PROCEDURE = bioseg_overlap,
256 COMMUTATOR = '&&',
257 RESTRICT = bioseg_sel,
258 JOIN = bioseg_joinsel
259 );
260
261 CREATE OPERATOR &> (
262 LEFTARG = bioseg,
263 RIGHTARG = bioseg,
264 PROCEDURE = bioseg_over_right,
265 RESTRICT = positionsel,
266 JOIN = positionjoinsel
267 );
268
269 CREATE OPERATOR >> (
270 LEFTARG = bioseg,
271 RIGHTARG = bioseg,
272 PROCEDURE = bioseg_right,
273 COMMUTATOR = '<<',
274 RESTRICT = positionsel,
275 JOIN = positionjoinsel
276 );
277
278 CREATE OPERATOR = (
279 LEFTARG = bioseg,
280 RIGHTARG = bioseg,
281 PROCEDURE = bioseg_same,
282 COMMUTATOR = '=',
283 NEGATOR = '<>',
284 RESTRICT = eqsel,
285 JOIN = eqjoinsel,
286 MERGES
287 );
288
289 CREATE OPERATOR <> (
290 LEFTARG = bioseg,
291 RIGHTARG = bioseg,
292 PROCEDURE = bioseg_different,
293 COMMUTATOR = '<>',
294 NEGATOR = '=',
295 RESTRICT = neqsel,
296 JOIN = neqjoinsel
297 );
298
299 CREATE OPERATOR @> (
300 LEFTARG = bioseg,
301 RIGHTARG = bioseg,
302 PROCEDURE = bioseg_contains,
303 COMMUTATOR = '<@',
304 RESTRICT = bioseg_contsel,
305 JOIN = bioseg_contjoinsel
306 );
307
308 CREATE OPERATOR <@ (
309 LEFTARG = bioseg,
310 RIGHTARG = bioseg,
311 PROCEDURE = bioseg_contained,
312 COMMUTATOR = '@>',
313 RESTRICT = bioseg_contsel,
314 JOIN = bioseg_contjoinsel
315 );
316
317
318
319 -- define the GiST support methods
320 CREATE FUNCTION bioseg_gist_consistent(internal,bioseg,int4)
321 RETURNS bool
322 AS '$libdir/bioseg'
323 LANGUAGE C IMMUTABLE;
324
325 CREATE FUNCTION bioseg_gist_compress(internal)
326 RETURNS internal
327 AS '$libdir/bioseg'
328 LANGUAGE C IMMUTABLE;
329
330 CREATE FUNCTION bioseg_gist_decompress(internal)
331 RETURNS internal
332 AS '$libdir/bioseg'
333 LANGUAGE C IMMUTABLE;
334
335 CREATE FUNCTION bioseg_gist_penalty(internal,internal,internal)
336 RETURNS internal
337 AS '$libdir/bioseg'
338 LANGUAGE C STRICT IMMUTABLE;
339
340 CREATE FUNCTION bioseg_gist_picksplit(internal, internal)
341 RETURNS internal
342 AS '$libdir/bioseg'
343 LANGUAGE C IMMUTABLE;
344
345 CREATE FUNCTION bioseg_gist_union(internal, internal)
346 RETURNS bioseg
347 AS '$libdir/bioseg'
348 LANGUAGE C IMMUTABLE;
349
350 CREATE FUNCTION bioseg_gist_same(bioseg, bioseg, internal)
351 RETURNS internal
352 AS '$libdir/bioseg'
353 LANGUAGE C IMMUTABLE;
354
355
356 -- Create the operator classes for indexing
357
358 CREATE OPERATOR CLASS bioseg_ops
359 DEFAULT FOR TYPE bioseg USING btree AS
360 OPERATOR 1 < ,
361 OPERATOR 2 <= ,
362 OPERATOR 3 = ,
363 OPERATOR 4 >= ,
364 OPERATOR 5 > ,
365 FUNCTION 1 bioseg_cmp(bioseg, bioseg);
366
367 CREATE OPERATOR CLASS gist_bioseg_ops
368 DEFAULT FOR TYPE bioseg USING gist
369 AS
370 OPERATOR 1 << ,
371 OPERATOR 2 &< ,
372 OPERATOR 3 && ,
373 OPERATOR 4 &> ,
374 OPERATOR 5 >> ,
375 OPERATOR 6 = ,
376 OPERATOR 7 @> ,
377 OPERATOR 8 <@ ,
378 FUNCTION 1 bioseg_gist_consistent (internal, bioseg, int4),
379 FUNCTION 2 bioseg_gist_union (internal, internal),
380 FUNCTION 3 bioseg_gist_compress (internal),
381 FUNCTION 4 bioseg_gist_decompress (internal),
382 FUNCTION 5 bioseg_gist_penalty (internal, internal, internal),
383 FUNCTION 6 bioseg_gist_picksplit (internal, internal),
384 FUNCTION 7 bioseg_gist_same (bioseg, bioseg, internal);