Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72a4e65

Browse files
author
Vitaly Davydov
committed
Move brin.c(h) files into src subdirectory
Add brin support in upgrade scriptFix some code problemsFix test_initFix Indices section in the doc
1 parent6cd0cdf commit72a4e65

File tree

6 files changed

+76
-44
lines changed

6 files changed

+76
-44
lines changed

‎Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MODULE_big = pg_sphere
1111
OBJS = src/sscan.o src/sparse.o src/sbuffer.o src/vector3d.o src/point.o\
1212
src/euler.o src/circle.o src/line.o src/ellipse.o src/polygon.o\
1313
src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o\
14-
src/key.o src/gnomo.o src/epochprop.o brin.o
14+
src/key.o src/gnomo.o src/epochprop.osrc/brin.o
1515

1616
ifneq ($(USE_HEALPIX),0)
1717
OBJS += src/healpix.o src/moc.o src/process_moc.o\
@@ -43,7 +43,7 @@ REGRESS_9_5 = index_9.5 # experimental for spoint3
4343

4444
TESTS = init_test tables points euler circle line ellipse poly path box\
4545
index contains_ops contains_ops_compat bounding_box_gist gnomo\
46-
epochprop contains overlaps
46+
epochprop contains overlaps spoint_brin
4747

4848
ifneq ($(USE_HEALPIX),0)
4949
TESTS += healpix moc mocautocast
@@ -262,7 +262,7 @@ endif
262262
pg_sphere--1.2.2--1.2.3.sql:
263263
cat upgrade_scripts/$@.in>$@
264264

265-
pg_sphere--1.2.3--1.3.0.sql:
265+
pg_sphere--1.2.3--1.3.0.sql: pgs_brin.sql.in
266266
cat upgrade_scripts/$@.in>$@
267267

268268
# end of local stuff

‎doc/indices.sgm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
linkend="op.equal"><literal>=</literal></link>, and <link
3030
linkend="op.equal"><literal>!=</literal></link>.
3131
</para>
32-
<title>
33-
Create a spherical index
34-
</title>
3532
<para>
3633
You can create a GiST index with the following spherical data types:
3734
</para>

‎expected/init_test_healpix.out.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
psql:pg_sphere.test.sql:9271: NOTICE: return type smoc is only a shell
2-
psql:pg_sphere.test.sql:9277: NOTICE: argument type smoc is only a shell
1+
psql:pg_sphere.test.sql:9682: NOTICE: return type smoc is only a shell
2+
psql:pg_sphere.test.sql:9688: NOTICE: argument type smoc is only a shell

‎expected/spoint_brin.out

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,87 @@
1-
CREATE TABLE
2-
COPY 77
3-
CREATE FUNCTION
4-
CREATE INDEX
5-
SET
6-
SET
7-
SET
8-
?column? | qnodes
1+
CREATE TABLE test_points (
2+
p spoint
3+
);
4+
COPY test_points (p) FROM stdin;
5+
CREATE OR REPLACE FUNCTION qnodes(q text) RETURNS text
6+
LANGUAGE 'plpgsql' AS
7+
$$
8+
DECLARE
9+
exp TEXT;
10+
mat TEXT[];
11+
ret TEXT[];
12+
BEGIN
13+
FOR exp IN EXECUTE 'EXPLAIN ' || q
14+
LOOP
15+
--RAISE NOTICE 'EXP: %', exp;
16+
mat := regexp_matches(exp, ' *(?:-> *)?(.*Scan)');
17+
--RAISE NOTICE 'MAT: %', mat;
18+
IF mat IS NOT NULL THEN
19+
ret := array_append(ret, mat[1]);
20+
END IF;
21+
--RAISE NOTICE 'RET: %', ret;
22+
END LOOP;
23+
RETURN array_to_string(ret,',');
24+
END;
25+
$$;
26+
CREATE INDEX brin_spoint ON test_points USING brin (p) WITH (pages_per_range = 16);
27+
set enable_indexscan = off;
28+
set enable_bitmapscan = off;
29+
set enable_seqscan = on;
30+
SELECT 'scan_seq', qnodes('SELECT * FROM test_points WHERE p <@ sbox ''( (10d,10d), (20d,20d) )''');
31+
?column? | qnodes
932
----------+----------
1033
scan_seq | Seq Scan
1134
(1 row)
1235

13-
p
36+
SELECT * FROM test_points WHERE p <@ sbox '( (10d,10d), (20d,20d) )';
37+
p
1438
-----------------------------------------
1539
(0.349065850398866 , 0.174532925199433)
1640
(1 row)
1741

18-
?column? | qnodes
42+
SELECT 'scan_seq', qnodes('SELECT * FROM test_points WHERE p && sbox ''( (10d,10d), (20d,20d) )''');
43+
?column? | qnodes
1944
----------+----------
2045
scan_seq | Seq Scan
2146
(1 row)
2247

23-
p
48+
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )';
49+
p
2450
-----------------------------------------
2551
(0.349065850398866 , 0.174532925199433)
2652
(1 row)
2753

28-
SET
29-
SET
30-
SET
31-
?column? | qnodes
54+
set enable_indexscan = off;
55+
set enable_bitmapscan = on;
56+
set enable_seqscan = off;
57+
SELECT 'scan_idx', qnodes('SELECT * FROM test_points WHERE p <@ sbox ''( (10d,10d), (20d,20d) )''');
58+
?column? | qnodes
3259
----------+------------------------------------
3360
scan_idx | Bitmap Heap Scan,Bitmap Index Scan
3461
(1 row)
3562

36-
p
63+
SELECT * FROM test_points WHERE p <@ sbox '( (10d,10d), (20d,20d) )';
64+
p
3765
-----------------------------------------
3866
(0.349065850398866 , 0.174532925199433)
3967
(1 row)
4068

41-
?column? | qnodes
69+
SELECT 'scan_idx', qnodes('SELECT * FROM test_points WHERE p && sbox ''( (10d,10d), (20d,20d) )''');
70+
?column? | qnodes
4271
----------+------------------------------------
4372
scan_idx | Bitmap Heap Scan,Bitmap Index Scan
4473
(1 row)
4574

46-
p
75+
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )';
76+
p
4777
-----------------------------------------
4878
(0.349065850398866 , 0.174532925199433)
4979
(1 row)
5080

51-
DROP INDEX
52-
DROP TABLE
53-
DROP FUNCTION
54-
SET
55-
SET
56-
SET
81+
-- cleanup
82+
DROP INDEX brin_spoint;
83+
DROP TABLE test_points;
84+
DROP FUNCTION qnodes(text);
85+
set enable_indexscan = on;
86+
set enable_bitmapscan = on;
87+
set enable_seqscan = on;

‎brin.crenamed to‎src/brin.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ spoint_brin_inclusion_add_value(PG_FUNCTION_ARGS)
5353
PG_RETURN_BOOL(true);
5454
}
5555

56-
spherepoint_gen_key(&spointkey,newval);
56+
spherepoint_gen_key(spointkey,newval);
5757

5858
/*
5959
* If spherekey pointer is NULL, we consider the spoint entry as 'empty'.
6060
*
6161
* The OpClass support empty entries: we need to set the "contains empty"
6262
* flag in the element (unless already set).
6363
*/
64+
/*
6465
if (spointkey == NULL)
6566
{
6667
if (!DatumGetBool(column->bv_values[INCLUSION_CONTAINS_EMPTY]))
@@ -71,6 +72,7 @@ spoint_brin_inclusion_add_value(PG_FUNCTION_ARGS)
7172
7273
PG_RETURN_BOOL(false);
7374
}
75+
*/
7476

7577
/* if the recorded value is null, we just need to store the spherekey */
7678
if (column->bv_allnulls)
@@ -121,14 +123,15 @@ sbox_brin_inclusion_add_value(PG_FUNCTION_ARGS)
121123
PG_RETURN_BOOL(true);
122124
}
123125

124-
spherebox_gen_key(&sboxkey,newval);
126+
spherebox_gen_key(sboxkey,newval);
125127

126128
/*
127129
* If spherekey pointer is NULL, we consider the spoint entry as 'empty'.
128130
*
129131
* The OpClass support empty entries: we need to set the "contains empty"
130132
* flag in the element (unless already set).
131133
*/
134+
/*
132135
if (sboxkey == NULL)
133136
{
134137
if (!DatumGetBool(column->bv_values[INCLUSION_CONTAINS_EMPTY]))
@@ -139,6 +142,7 @@ sbox_brin_inclusion_add_value(PG_FUNCTION_ARGS)
139142
140143
PG_RETURN_BOOL(false);
141144
}
145+
*/
142146

143147
/* if the recorded value is null, we just need to store the spherekey */
144148
if (column->bv_allnulls)
@@ -178,7 +182,7 @@ spoint_overlaps_spherekey(PG_FUNCTION_ARGS)
178182
SPoint*p1= (SPoint*)PG_GETARG_POINTER(0);
179183
int32*k2= (int32*)PG_GETARG_POINTER(1);
180184

181-
spherepoint_gen_key(&k1,p1);
185+
spherepoint_gen_key(k1,p1);
182186
if (spherekey_interleave(k1,k2)==SCKEY_OVERLAP)
183187
{
184188
PG_RETURN_BOOL(true);
@@ -194,7 +198,7 @@ spoint_contains_spherekey(PG_FUNCTION_ARGS)
194198
SPoint*p1= (SPoint*)PG_GETARG_POINTER(0);
195199
int32*k2= (int32*)PG_GETARG_POINTER(1);
196200

197-
spherepoint_gen_key(&k1,p1);
201+
spherepoint_gen_key(k1,p1);
198202
if (spherekey_interleave(k1,k2)==SCKEY_IN)
199203
{
200204
PG_RETURN_BOOL(true);
@@ -210,7 +214,7 @@ spoint_iscontained_spherekey(PG_FUNCTION_ARGS)
210214
SPoint*p1= (SPoint*)PG_GETARG_POINTER(0);
211215
int32*k2= (int32*)PG_GETARG_POINTER(1);
212216

213-
spherepoint_gen_key(&k1,p1);
217+
spherepoint_gen_key(k1,p1);
214218
if (spherekey_interleave(k2,k1)==SCKEY_IN)
215219
{
216220
PG_RETURN_BOOL(true);
@@ -226,7 +230,7 @@ sbox_overlaps_spherekey(PG_FUNCTION_ARGS)
226230
SBOX*p1= (SBOX*)PG_GETARG_POINTER(0);
227231
int32*k2= (int32*)PG_GETARG_POINTER(1);
228232

229-
spherebox_gen_key(&k1,p1);
233+
spherebox_gen_key(k1,p1);
230234
if (spherekey_interleave(k1,k2)==SCKEY_OVERLAP)
231235
{
232236
PG_RETURN_BOOL(true);
@@ -242,7 +246,7 @@ sbox_contains_spherekey(PG_FUNCTION_ARGS)
242246
SBOX*p1= (SBOX*)PG_GETARG_POINTER(0);
243247
int32*k2= (int32*)PG_GETARG_POINTER(1);
244248

245-
spherebox_gen_key(&k1,p1);
249+
spherebox_gen_key(k1,p1);
246250
if (spherekey_interleave(k1,k2)==SCKEY_IN)
247251
{
248252
PG_RETURN_BOOL(true);
@@ -258,7 +262,7 @@ sbox_iscontained_spherekey(PG_FUNCTION_ARGS)
258262
SBOX*p1= (SBOX*)PG_GETARG_POINTER(0);
259263
int32*k2= (int32*)PG_GETARG_POINTER(1);
260264

261-
spherebox_gen_key(&k1,p1);
265+
spherebox_gen_key(k1,p1);
262266
if (spherekey_interleave(k2,k1)==SCKEY_IN)
263267
{
264268
PG_RETURN_BOOL(true);
@@ -317,8 +321,8 @@ spoint_overlaps_sbox(PG_FUNCTION_ARGS)
317321
int32k2[6];
318322
SBOX*p2= (SBOX*)PG_GETARG_POINTER(1);
319323

320-
spherepoint_gen_key(&k1,p1);
321-
spherebox_gen_key(&k2,p2);
324+
spherepoint_gen_key(k1,p1);
325+
spherebox_gen_key(k2,p2);
322326

323327
if (spherekey_interleave(k1,k2)==SCKEY_OVERLAP)
324328
{
@@ -336,8 +340,8 @@ sbox_iscontained_spoint(PG_FUNCTION_ARGS)
336340
int32k2[6];
337341
SPoint*p2= (SPoint*)PG_GETARG_POINTER(1);
338342

339-
spherebox_gen_key(&k1,p1);
340-
spherepoint_gen_key(&k2,p2);
343+
spherebox_gen_key(k1,p1);
344+
spherepoint_gen_key(k2,p2);
341345

342346
if (spherekey_interleave(k1,k2)==SCKEY_IN)
343347
{

‎brin.hrenamed to‎src/brin.h

File renamed without changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp