gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2KB

  1. /* contrib/cube/cubedata.h */
  2. /*
  3. * This limit is pretty arbitrary, but don't make it so large that you
  4. * risk overflow in sizing calculations.
  5. */
  6. #define CUBE_MAX_DIM (100)
  7. typedef struct NDBOX
  8. {
  9. /* varlena header (do not touch directly!) */
  10. int32 vl_len_;
  11. /*----------
  12. * Header contains info about NDBOX. For binary compatibility with old
  13. * versions, it is defined as "unsigned int".
  14. *
  15. * Following information is stored:
  16. *
  17. * bits 0-7 : number of cube dimensions;
  18. * bits 8-30 : unused, initialize to zero;
  19. * bit 31 : point flag. If set, the upper right coordinates are not
  20. * stored, and are implicitly the same as the lower left
  21. * coordinates.
  22. *----------
  23. */
  24. unsigned int header;
  25. /*
  26. * The lower left coordinates for each dimension come first, followed by
  27. * upper right coordinates unless the point flag is set.
  28. */
  29. double x[FLEXIBLE_ARRAY_MEMBER];
  30. } NDBOX;
  31. /* NDBOX access macros */
  32. #define POINT_BIT 0x80000000
  33. #define DIM_MASK 0x7fffffff
  34. #define IS_POINT(cube) ( ((cube)->header & POINT_BIT) != 0 )
  35. #define SET_POINT_BIT(cube) ( (cube)->header |= POINT_BIT )
  36. #define DIM(cube) ( (cube)->header & DIM_MASK )
  37. #define SET_DIM(cube, _dim) ( (cube)->header = ((cube)->header & ~DIM_MASK) | (_dim) )
  38. #define LL_COORD(cube, i) ( (cube)->x[i] )
  39. #define UR_COORD(cube, i) ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )
  40. #define POINT_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim))
  41. #define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
  42. /* fmgr interface macros */
  43. #define DatumGetNDBOXP(x) ((NDBOX *) PG_DETOAST_DATUM(x))
  44. #define PG_GETARG_NDBOX_P(x) DatumGetNDBOXP(PG_GETARG_DATUM(x))
  45. #define PG_RETURN_NDBOX_P(x) PG_RETURN_POINTER(x)
  46. /* GiST operator strategy numbers */
  47. #define CubeKNNDistanceCoord 15 /* ~> */
  48. #define CubeKNNDistanceTaxicab 16 /* <#> */
  49. #define CubeKNNDistanceEuclid 17 /* <-> */
  50. #define CubeKNNDistanceChebyshev 18 /* <=> */
  51. /* in cubescan.l */
  52. extern int cube_yylex(void);
  53. extern void cube_yyerror(NDBOX **result, const char *message) pg_attribute_noreturn();
  54. extern void cube_scanner_init(const char *str);
  55. extern void cube_scanner_finish(void);
  56. /* in cubeparse.y */
  57. extern int cube_yyparse(NDBOX **result);
上海开阖软件有限公司 沪ICP备12045867号-1