1 /* contrib/cube/cubedata.h */
4 * This limit is pretty arbitrary, but don't make it so large that you
5 * risk overflow in sizing calculations.
7 #define CUBE_MAX_DIM (100)
11 /* varlena header (do not touch directly!) */
15 * Header contains info about NDBOX. For binary compatibility with old
16 * versions, it is defined as "unsigned int".
18 * Following information is stored:
20 * bits 0-7 : number of cube dimensions;
21 * bits 8-30 : unused, initialize to zero;
22 * bit 31 : point flag. If set, the upper right coordinates are not
23 * stored, and are implicitly the same as the lower left
30 * The lower left coordinates for each dimension come first, followed by
31 * upper right coordinates unless the point flag is set.
33 double x
[FLEXIBLE_ARRAY_MEMBER
];
36 /* NDBOX access macros */
37 #define POINT_BIT 0x80000000
38 #define DIM_MASK 0x7fffffff
40 #define IS_POINT(cube) ( ((cube)->header & POINT_BIT) != 0 )
41 #define SET_POINT_BIT(cube) ( (cube)->header |= POINT_BIT )
42 #define DIM(cube) ( (cube)->header & DIM_MASK )
43 #define SET_DIM(cube, _dim) ( (cube)->header = ((cube)->header & ~DIM_MASK) | (_dim) )
45 #define LL_COORD(cube, i) ( (cube)->x[i] )
46 #define UR_COORD(cube, i) ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )
48 #define POINT_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim))
49 #define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
51 /* fmgr interface macros */
52 #define DatumGetNDBOXP(x) ((NDBOX *) PG_DETOAST_DATUM(x))
53 #define PG_GETARG_NDBOX_P(x) DatumGetNDBOXP(PG_GETARG_DATUM(x))
54 #define PG_RETURN_NDBOX_P(x) PG_RETURN_POINTER(x)
56 /* GiST operator strategy numbers */
57 #define CubeKNNDistanceCoord 15 /* ~> */
58 #define CubeKNNDistanceTaxicab 16 /* <#> */
59 #define CubeKNNDistanceEuclid 17 /* <-> */
60 #define CubeKNNDistanceChebyshev 18 /* <=> */
63 extern int cube_yylex(void);
64 extern void cube_yyerror(NDBOX
**result
, Size scanbuflen
,
65 struct Node
*escontext
,
67 extern void cube_scanner_init(const char *str
, Size
*scanbuflen
);
68 extern void cube_scanner_finish(void);
71 extern int cube_yyparse(NDBOX
**result
, Size scanbuflen
,
72 struct Node
*escontext
);