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

Commitd50e125

Browse files
committed
Clean up a couple of box gist helper functions.
The original idea of this patch was to make box picksplit run faster, byeliminating unnecessary palloc() overhead, but that was obsoleted by the newdouble-sorting split algorithm that doesn't call these functions so heavilyanymore. Nevertheless, the code looks better this way.Original patch by me, reviewed and tidied up after the double-sorting patchby Kevin Grittner.
1 parentcbfa92c commitd50e125

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

‎src/backend/access/gist/gistproc.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
staticboolgist_box_leaf_consistent(BOX*key,BOX*query,
2525
StrategyNumberstrategy);
26-
staticdoublesize_box(Datumdbox);
26+
staticdoublesize_box(BOX*box);
2727
staticboolrtree_internal_consistent(BOX*key,BOX*query,
2828
StrategyNumberstrategy);
2929

@@ -35,21 +35,16 @@ static bool rtree_internal_consistent(BOX *key, BOX *query,
3535
* Box ops
3636
**************************************************/
3737

38-
staticDatum
39-
rt_box_union(PG_FUNCTION_ARGS)
38+
/*
39+
* Calculates union of two boxes, a and b. The result is stored in *n.
40+
*/
41+
staticvoid
42+
rt_box_union(BOX*n,BOX*a,BOX*b)
4043
{
41-
BOX*a=PG_GETARG_BOX_P(0);
42-
BOX*b=PG_GETARG_BOX_P(1);
43-
BOX*n;
44-
45-
n= (BOX*)palloc(sizeof(BOX));
46-
4744
n->high.x=Max(a->high.x,b->high.x);
4845
n->high.y=Max(a->high.y,b->high.y);
4946
n->low.x=Min(a->low.x,b->low.x);
5047
n->low.y=Min(a->low.y,b->low.y);
51-
52-
PG_RETURN_BOX_P(n);
5348
}
5449

5550
/*
@@ -166,10 +161,12 @@ gist_box_penalty(PG_FUNCTION_ARGS)
166161
GISTENTRY*origentry= (GISTENTRY*)PG_GETARG_POINTER(0);
167162
GISTENTRY*newentry= (GISTENTRY*)PG_GETARG_POINTER(1);
168163
float*result= (float*)PG_GETARG_POINTER(2);
169-
Datumud;
164+
BOX*origbox=DatumGetBoxP(origentry->key);
165+
BOX*newbox=DatumGetBoxP(newentry->key);
166+
BOXunionbox;
170167

171-
ud=DirectFunctionCall2(rt_box_union,origentry->key,newentry->key);
172-
*result= (float) (size_box(ud)-size_box(origentry->key));
168+
rt_box_union(&unionbox,origbox,newbox);
169+
*result= (float) (size_box(&unionbox)-size_box(origbox));
173170
PG_RETURN_POINTER(result);
174171
}
175172

@@ -937,11 +934,9 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
937934
}
938935

939936
staticdouble
940-
size_box(Datumdbox)
937+
size_box(BOX*box)
941938
{
942-
BOX*box=DatumGetBoxP(dbox);
943-
944-
if (box==NULL||box->high.x <=box->low.x||box->high.y <=box->low.y)
939+
if (box->high.x <=box->low.x||box->high.y <=box->low.y)
945940
return0.0;
946941
return (box->high.x-box->low.x)* (box->high.y-box->low.y);
947942
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp