Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 403da2c

Browse files
df7cbmsdemlei
authored andcommitted
Add a second gin opclass smoc_gin_ops_fine using level 8
1 parent c289a46 commit 403da2c

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

moc.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ PG_FUNCTION_INFO_V1(smoc_scircle);
4040
PG_FUNCTION_INFO_V1(smoc_spoly);
4141

4242
PG_FUNCTION_INFO_V1(smoc_gin_extract_value);
43+
PG_FUNCTION_INFO_V1(smoc_gin_extract_value_fine);
4344
PG_FUNCTION_INFO_V1(smoc_gin_extract_query);
45+
PG_FUNCTION_INFO_V1(smoc_gin_extract_query_fine);
4446
PG_FUNCTION_INFO_V1(smoc_gin_consistent);
4547

4648
int32 smoc_output_type = 0;
@@ -1048,7 +1050,7 @@ smoc_gin_extract_internal(Smoc *moc_a, int32 *nkeys, int gin_order)
10481050
if (*nkeys >= nalloc)
10491051
{
10501052
nalloc *= 2;
1051-
Assert(nalloc < 1000000);
1053+
Assert(nalloc < 2000000);
10521054
keys = repalloc(keys, nalloc * sizeof(Datum));
10531055
}
10541056
keys[(*nkeys)++] = Int32GetDatum(p);
@@ -1067,6 +1069,15 @@ smoc_gin_extract_value(PG_FUNCTION_ARGS)
10671069
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER));
10681070
}
10691071

1072+
Datum
1073+
smoc_gin_extract_value_fine(PG_FUNCTION_ARGS)
1074+
{
1075+
Smoc* moc_a = (Smoc *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1076+
int32* nkeys = (int32 *) PG_GETARG_POINTER(1);
1077+
1078+
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER_FINE));
1079+
}
1080+
10701081
Datum
10711082
smoc_gin_extract_query(PG_FUNCTION_ARGS)
10721083
{
@@ -1081,6 +1092,20 @@ smoc_gin_extract_query(PG_FUNCTION_ARGS)
10811092
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER));
10821093
}
10831094

1095+
Datum
1096+
smoc_gin_extract_query_fine(PG_FUNCTION_ARGS)
1097+
{
1098+
Smoc* moc_a = (Smoc *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1099+
int32* nkeys = (int32 *) PG_GETARG_POINTER(1);
1100+
StrategyNumber st = PG_GETARG_UINT16(2);
1101+
int32* searchmode = (int32 *) PG_GETARG_POINTER(6);
1102+
1103+
if (st == MOC_GIN_STRATEGY_SUBSET)
1104+
*searchmode = GIN_SEARCH_MODE_INCLUDE_EMPTY;
1105+
1106+
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a, nkeys, MOC_GIN_ORDER_FINE));
1107+
}
1108+
10841109
Datum
10851110
smoc_gin_consistent(PG_FUNCTION_ARGS)
10861111
{

pgs_moc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ Datum smoc_scircle(PG_FUNCTION_ARGS);
9191
Datum smoc_spoly(PG_FUNCTION_ARGS);
9292

9393
Datum smoc_gin_extract_value(PG_FUNCTION_ARGS);
94+
Datum smoc_gin_extract_value_fine(PG_FUNCTION_ARGS);
9495
Datum smoc_gin_extract_query(PG_FUNCTION_ARGS);
96+
Datum smoc_gin_extract_query_fine(PG_FUNCTION_ARGS);
9597
Datum smoc_gin_consistent(PG_FUNCTION_ARGS);
9698

9799
/* parsing subroutines */
@@ -116,6 +118,7 @@ next_interval(int32 a)
116118
#define MOC_AREA_ALL_SKY 3458764513820540928
117119

118120
#define MOC_GIN_ORDER 5 /* order 5 has 12 * 4^5 = 12288 pixels */
121+
#define MOC_GIN_ORDER_FINE 8 /* order 8 has 12 * 4^8 = 786432 pixels */
119122
#define MOC_GIN_STRATEGY_INTERSECTS 1
120123
#define MOC_GIN_STRATEGY_SUBSET 2
121124
#define MOC_GIN_STRATEGY_SUPERSET 3

pgs_moc_ops.sql.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ CREATE FUNCTION smoc_gin_extract_value (smoc, internal, internal)
299299
IMMUTABLE
300300
STRICT;
301301

302+
CREATE FUNCTION smoc_gin_extract_value_fine (smoc, internal, internal)
303+
RETURNS internal
304+
AS 'MODULE_PATHNAME'
305+
LANGUAGE C
306+
PARALLEL SAFE
307+
IMMUTABLE
308+
STRICT;
309+
302310
CREATE FUNCTION smoc_gin_extract_query (smoc, internal, int2, internal, internal, internal, internal)
303311
RETURNS internal
304312
AS 'MODULE_PATHNAME'
@@ -307,6 +315,14 @@ CREATE FUNCTION smoc_gin_extract_query (smoc, internal, int2, internal, internal
307315
IMMUTABLE
308316
STRICT;
309317

318+
CREATE FUNCTION smoc_gin_extract_query_fine (smoc, internal, int2, internal, internal, internal, internal)
319+
RETURNS internal
320+
AS 'MODULE_PATHNAME'
321+
LANGUAGE C
322+
PARALLEL SAFE
323+
IMMUTABLE
324+
STRICT;
325+
310326
CREATE FUNCTION smoc_gin_consistent (internal, int2, smoc, int4, internal, internal, internal, internal)
311327
RETURNS boolean
312328
AS 'MODULE_PATHNAME'
@@ -327,3 +343,16 @@ CREATE OPERATOR CLASS smoc_gin_ops
327343
--FUNCTION 5 smoc_gin_compare_partial (),
328344
--FUNCTION 6 smoc_gin_tri_consistent (),
329345
STORAGE int4;
346+
347+
CREATE OPERATOR CLASS smoc_gin_ops_fine
348+
FOR TYPE smoc USING gin AS
349+
OPERATOR 1 &&,
350+
OPERATOR 2 <@,
351+
OPERATOR 3 @>,
352+
FUNCTION 1 btint4cmp (int4, int4),
353+
FUNCTION 2 smoc_gin_extract_value_fine (smoc, internal, internal),
354+
FUNCTION 3 smoc_gin_extract_query_fine (smoc, internal, int2, internal, internal, internal, internal),
355+
FUNCTION 4 smoc_gin_consistent (internal, int2, smoc, int4, internal, internal, internal, internal),
356+
--FUNCTION 5 smoc_gin_compare_partial (),
357+
--FUNCTION 6 smoc_gin_tri_consistent (),
358+
STORAGE int4;

0 commit comments

Comments
 (0)