@@ -104,7 +104,7 @@ bool g_cube_internal_consistent(NDBOX *key, NDBOX *query, StrategyNumber strate
104
104
** Auxiliary funxtions
105
105
*/
106
106
static double distance_1D (double a1 , double a2 , double b1 , double b2 );
107
- static bool cube_is_point_internal (NDBOX * cube );
107
+ static bool cube_is_point_internal (NDBOX * cube );
108
108
109
109
110
110
/*****************************************************************************
@@ -538,7 +538,7 @@ g_cube_picksplit(PG_FUNCTION_ARGS)
538
538
rt_cube_size (datum_r , & size_r );
539
539
540
540
/*
541
- * Now split up the regions between the two seeds. An important property
541
+ * Now split up the regions between the two seeds. An important property
542
542
* of this split algorithm is that the split vector v has the indices of
543
543
* items to be split in order in its left and right vectors. We exploit
544
544
* this property by doing a merge in the code that actually splits the
@@ -554,7 +554,7 @@ g_cube_picksplit(PG_FUNCTION_ARGS)
554
554
{
555
555
/*
556
556
* If we've already decided where to place this item, just put it on
557
- * the right list. Otherwise, we need to figure out which page needs
557
+ * the right list. Otherwise, we need to figure out which page needs
558
558
* the least enlargement in order to store the item.
559
559
*/
560
560
@@ -728,27 +728,27 @@ cube_union_v0(NDBOX *a, NDBOX *b)
728
728
SET_VARSIZE (result , size );
729
729
SET_DIM (result , dim );
730
730
731
- /* First compute the union of the dimensions present in both args */
731
+ /* First compute the union of the dimensions present in both args */
732
732
for (i = 0 ; i < DIM (b ); i ++ )
733
733
{
734
734
result -> x [i ] = Min (
735
- Min (LL_COORD (a , i ), UR_COORD (a , i )),
736
- Min (LL_COORD (b , i ), UR_COORD (b , i ))
737
- );
735
+ Min (LL_COORD (a , i ), UR_COORD (a , i )),
736
+ Min (LL_COORD (b , i ), UR_COORD (b , i ))
737
+ );
738
738
result -> x [i + DIM (a )] = Max (
739
- Max (LL_COORD (a , i ), UR_COORD (a , i )),
740
- Max (LL_COORD (b , i ), UR_COORD (b , i ))
741
- );
739
+ Max (LL_COORD (a , i ), UR_COORD (a , i )),
740
+ Max (LL_COORD (b , i ), UR_COORD (b , i ))
741
+ );
742
742
}
743
743
/* continue on the higher dimensions only present in 'a' */
744
744
for (; i < DIM (a ); i ++ )
745
745
{
746
746
result -> x [i ] = Min (0 ,
747
- Min (LL_COORD (a , i ), UR_COORD (a , i ))
748
- );
747
+ Min (LL_COORD (a , i ), UR_COORD (a , i ))
748
+ );
749
749
result -> x [i + dim ] = Max (0 ,
750
- Max (LL_COORD (a , i ), UR_COORD (a , i ))
751
- );
750
+ Max (LL_COORD (a , i ), UR_COORD (a , i ))
751
+ );
752
752
}
753
753
754
754
/*
@@ -795,6 +795,7 @@ cube_inter(PG_FUNCTION_ARGS)
795
795
if (DIM (a ) < DIM (b ))
796
796
{
797
797
NDBOX * tmp = b ;
798
+
798
799
b = a ;
799
800
a = tmp ;
800
801
swapped = true;
@@ -806,27 +807,27 @@ cube_inter(PG_FUNCTION_ARGS)
806
807
SET_VARSIZE (result , size );
807
808
SET_DIM (result , dim );
808
809
809
- /* First compute intersection of the dimensions present in both args */
810
+ /* First compute intersection of the dimensions present in both args */
810
811
for (i = 0 ; i < DIM (b ); i ++ )
811
812
{
812
813
result -> x [i ] = Max (
813
- Min (LL_COORD (a , i ), UR_COORD (a , i )),
814
- Min (LL_COORD (b , i ), UR_COORD (b , i ))
815
- );
814
+ Min (LL_COORD (a , i ), UR_COORD (a , i )),
815
+ Min (LL_COORD (b , i ), UR_COORD (b , i ))
816
+ );
816
817
result -> x [i + DIM (a )] = Min (
817
- Max (LL_COORD (a , i ), UR_COORD (a , i )),
818
- Max (LL_COORD (b , i ), UR_COORD (b , i ))
819
- );
818
+ Max (LL_COORD (a , i ), UR_COORD (a , i )),
819
+ Max (LL_COORD (b , i ), UR_COORD (b , i ))
820
+ );
820
821
}
821
822
/* continue on the higher dimemsions only present in 'a' */
822
823
for (; i < DIM (a ); i ++ )
823
824
{
824
825
result -> x [i ] = Max (0 ,
825
- Min (LL_COORD (a , i ), UR_COORD (a , i ))
826
- );
826
+ Min (LL_COORD (a , i ), UR_COORD (a , i ))
827
+ );
827
828
result -> x [i + DIM (a )] = Min (0 ,
828
- Max (LL_COORD (a , i ), UR_COORD (a , i ))
829
- );
829
+ Max (LL_COORD (a , i ), UR_COORD (a , i ))
830
+ );
830
831
}
831
832
832
833
/*
@@ -1236,14 +1237,14 @@ cube_distance(PG_FUNCTION_ARGS)
1236
1237
/* compute within the dimensions of (b) */
1237
1238
for (i = 0 ; i < DIM (b ); i ++ )
1238
1239
{
1239
- d = distance_1D (LL_COORD (a ,i ), UR_COORD (a ,i ), LL_COORD (b ,i ), UR_COORD (b ,i ));
1240
+ d = distance_1D (LL_COORD (a , i ), UR_COORD (a , i ), LL_COORD (b , i ), UR_COORD (b , i ));
1240
1241
distance += d * d ;
1241
1242
}
1242
1243
1243
1244
/* compute distance to zero for those dimensions in (a) absent in (b) */
1244
1245
for (i = DIM (b ); i < DIM (a ); i ++ )
1245
1246
{
1246
- d = distance_1D (LL_COORD (a ,i ), UR_COORD (a ,i ), 0.0 , 0.0 );
1247
+ d = distance_1D (LL_COORD (a , i ), UR_COORD (a , i ), 0.0 , 0.0 );
1247
1248
distance += d * d ;
1248
1249
}
1249
1250
@@ -1297,11 +1298,11 @@ cube_is_point_internal(NDBOX *cube)
1297
1298
return true;
1298
1299
1299
1300
/*
1300
- * Even if the point-flag is not set, all the lower-left coordinates
1301
- * might match the upper-right coordinates, so that the value is in
1302
- * fact a point. Such values don't arise with current code - the point
1303
- * flag is always set if appropriate - but they might be present on-disk
1304
- * in clusters upgraded from pre-9.4 versions.
1301
+ * Even if the point-flag is not set, all the lower-left coordinates might
1302
+ * match the upper-right coordinates, so that the value is in fact a
1303
+ * point. Such values don't arise with current code - the point flag is
1304
+ * always set if appropriate - but they might be present on-disk in
1305
+ * clusters upgraded from pre-9.4 versions.
1305
1306
*/
1306
1307
for (i = 0 ; i < DIM (cube ); i ++ )
1307
1308
{
@@ -1317,6 +1318,7 @@ cube_dim(PG_FUNCTION_ARGS)
1317
1318
{
1318
1319
NDBOX * c = PG_GETARG_NDBOX (0 );
1319
1320
int dim = DIM (c );
1321
+
1320
1322
PG_FREE_IF_COPY (c , 0 );
1321
1323
PG_RETURN_INT32 (dim );
1322
1324
}
@@ -1330,7 +1332,7 @@ cube_ll_coord(PG_FUNCTION_ARGS)
1330
1332
double result ;
1331
1333
1332
1334
if (DIM (c ) >= n && n > 0 )
1333
- result = Min (LL_COORD (c , n - 1 ), UR_COORD (c , n - 1 ));
1335
+ result = Min (LL_COORD (c , n - 1 ), UR_COORD (c , n - 1 ));
1334
1336
else
1335
1337
result = 0 ;
1336
1338
@@ -1347,7 +1349,7 @@ cube_ur_coord(PG_FUNCTION_ARGS)
1347
1349
double result ;
1348
1350
1349
1351
if (DIM (c ) >= n && n > 0 )
1350
- result = Max (LL_COORD (c , n - 1 ), UR_COORD (c , n - 1 ));
1352
+ result = Max (LL_COORD (c , n - 1 ), UR_COORD (c , n - 1 ));
1351
1353
else
1352
1354
result = 0 ;
1353
1355
@@ -1382,15 +1384,15 @@ cube_enlarge(PG_FUNCTION_ARGS)
1382
1384
1383
1385
for (i = 0 , j = dim ; i < DIM (a ); i ++ , j ++ )
1384
1386
{
1385
- if (LL_COORD (a ,i ) >= UR_COORD (a ,i ))
1387
+ if (LL_COORD (a , i ) >= UR_COORD (a , i ))
1386
1388
{
1387
- result -> x [i ] = UR_COORD (a ,i ) - r ;
1388
- result -> x [j ] = LL_COORD (a ,i ) + r ;
1389
+ result -> x [i ] = UR_COORD (a , i ) - r ;
1390
+ result -> x [j ] = LL_COORD (a , i ) + r ;
1389
1391
}
1390
1392
else
1391
1393
{
1392
- result -> x [i ] = LL_COORD (a ,i ) - r ;
1393
- result -> x [j ] = UR_COORD (a ,i ) + r ;
1394
+ result -> x [i ] = LL_COORD (a , i ) - r ;
1395
+ result -> x [j ] = UR_COORD (a , i ) + r ;
1394
1396
}
1395
1397
if (result -> x [i ] > result -> x [j ])
1396
1398
{
@@ -1503,7 +1505,7 @@ cube_c_f8(PG_FUNCTION_ARGS)
1503
1505
result -> x [DIM (result ) + i ] = cube -> x [DIM (cube ) + i ];
1504
1506
}
1505
1507
result -> x [DIM (result ) - 1 ] = x ;
1506
- result -> x [2 * DIM (result ) - 1 ] = x ;
1508
+ result -> x [2 * DIM (result ) - 1 ] = x ;
1507
1509
}
1508
1510
1509
1511
PG_FREE_IF_COPY (cube , 0 );
@@ -1521,7 +1523,8 @@ cube_c_f8_f8(PG_FUNCTION_ARGS)
1521
1523
int size ;
1522
1524
int i ;
1523
1525
1524
- if (IS_POINT (cube ) && (x1 == x2 )){
1526
+ if (IS_POINT (cube ) && (x1 == x2 ))
1527
+ {
1525
1528
size = POINT_SIZE ((DIM (cube ) + 1 ));
1526
1529
result = (NDBOX * ) palloc0 (size );
1527
1530
SET_VARSIZE (result , size );
0 commit comments