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

Commitc289a46

Browse files
df7cbmsdemlei
authored andcommitted
Refactor gin_extact functions
1 parent43d5734 commitc289a46

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

‎moc.c‎

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,13 +1020,11 @@ smoc_spoly(PG_FUNCTION_ARGS)
10201020

10211021
/* GIN index ***********************************/
10221022

1023-
Datum
1024-
smoc_gin_extract_value(PG_FUNCTION_ARGS)
1023+
staticDatum
1024+
smoc_gin_extract_internal(Smoc*moc_a,int32*nkeys,intgin_order)
10251025
{
1026-
Smoc*moc_a= (Smoc*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
10271026
char*moc_a_base=MOC_BASE(moc_a);
10281027
int32moc_a_end=VARSIZE(moc_a)-VARHDRSZ;
1029-
int32*nkeys= (int32*)PG_GETARG_POINTER(1);
10301028
int32nalloc=4;
10311029
Datum*keys=palloc(nalloc*sizeof(Datum));
10321030

@@ -1036,7 +1034,7 @@ smoc_gin_extract_value(PG_FUNCTION_ARGS)
10361034
{
10371035
moc_interval*x=MOC_INTERVAL(moc_a_base,a);
10381036

1039-
intshift=2* (HEALPIX_MAX_ORDER-MOC_GIN_ORDER);// degrade to MOC_GIN_ORDER
1037+
intshift=2* (HEALPIX_MAX_ORDER-gin_order);// degrade to MOC_GIN_ORDER
10401038
int32first= (x->first >>shift);// set low bits to zero
10411039
hpint64low_bits_one= (1L <<shift)-1;
10421040
int32second= ((x->second+low_bits_one) >>shift);// round low bits up
@@ -1060,49 +1058,27 @@ smoc_gin_extract_value(PG_FUNCTION_ARGS)
10601058
PG_RETURN_POINTER(keys);
10611059
}
10621060

1061+
Datum
1062+
smoc_gin_extract_value(PG_FUNCTION_ARGS)
1063+
{
1064+
Smoc*moc_a= (Smoc*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1065+
int32*nkeys= (int32*)PG_GETARG_POINTER(1);
1066+
1067+
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a,nkeys,MOC_GIN_ORDER));
1068+
}
1069+
10631070
Datum
10641071
smoc_gin_extract_query(PG_FUNCTION_ARGS)
10651072
{
10661073
Smoc*moc_a= (Smoc*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1067-
char*moc_a_base=MOC_BASE(moc_a);
1068-
int32moc_a_end=VARSIZE(moc_a)-VARHDRSZ;
10691074
int32*nkeys= (int32*)PG_GETARG_POINTER(1);
10701075
StrategyNumberst=PG_GETARG_UINT16(2);
10711076
int32*searchmode= (int32*)PG_GETARG_POINTER(6);
1072-
int32nalloc=4;
1073-
Datum*keys=palloc(nalloc*sizeof(Datum));
1074-
1075-
*nkeys=0;
10761077

10771078
if (st==MOC_GIN_STRATEGY_SUBSET)
10781079
*searchmode=GIN_SEARCH_MODE_INCLUDE_EMPTY;
10791080

1080-
for (int32a=moc_a->data_begin;a<moc_a_end;a=next_interval(a))
1081-
{
1082-
moc_interval*x=MOC_INTERVAL(moc_a_base,a);
1083-
1084-
intshift=2* (HEALPIX_MAX_ORDER-MOC_GIN_ORDER);// degrade to MOC_GIN_ORDER
1085-
int32first= (x->first >>shift);// set low bits to zero
1086-
hpint64low_bits_one= (1L <<shift)-1;
1087-
int32second= ((x->second+low_bits_one) >>shift);// round low bits up
1088-
Assert(shift>32);// internal GIN datatype isn't 64 bits
1089-
1090-
// split interval into individual pixels of order MOC_GIN_ORDER
1091-
for (int32p=first;p<second;p++)
1092-
{
1093-
if (*nkeys>0&&keys[*nkeys-1]==p)// has (larger) pixel already been added?
1094-
continue;
1095-
if (*nkeys >=nalloc)
1096-
{
1097-
nalloc *=2;
1098-
Assert(nalloc<1000000);
1099-
keys=repalloc(keys,nalloc*sizeof(Datum));
1100-
}
1101-
keys[(*nkeys)++]=Int32GetDatum(p);
1102-
}
1103-
}
1104-
1105-
PG_RETURN_POINTER(keys);
1081+
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a,nkeys,MOC_GIN_ORDER));
11061082
}
11071083

11081084
Datum

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp