PostgreSQL Source Code git master
cubedata.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NDBOX
 

Macros

#define CUBE_MAX_DIM   (100)
 
#define POINT_BIT   0x80000000
 
#define DIM_MASK   0x7fffffff
 
#define IS_POINT(cube)   ( ((cube)->header & POINT_BIT) != 0 )
 
#define SET_POINT_BIT(cube)   ( (cube)->header |= POINT_BIT )
 
#define DIM(cube)   ( (cube)->header & DIM_MASK )
 
#define SET_DIM(cube, _dim)   ( (cube)->header = ((cube)->header & ~DIM_MASK) | (_dim) )
 
#define LL_COORD(cube, i)   ( (cube)->x[i] )
 
#define UR_COORD(cube, i)   ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )
 
#define POINT_SIZE(_dim)   (offsetof(NDBOX, x) + sizeof(double)*(_dim))
 
#define CUBE_SIZE(_dim)   (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
 
#define DatumGetNDBOXP(x)   ((NDBOX *) PG_DETOAST_DATUM(x))
 
#define PG_GETARG_NDBOX_P(x)   DatumGetNDBOXP(PG_GETARG_DATUM(x))
 
#define PG_RETURN_NDBOX_P(x)   PG_RETURN_POINTER(x)
 
#define CubeKNNDistanceCoord   15 /* ~> */
 
#define CubeKNNDistanceTaxicab   16 /* <#> */
 
#define CubeKNNDistanceEuclid   17 /* <-> */
 
#define CubeKNNDistanceChebyshev   18 /* <=> */
 
#define YYSTYPE   char *
 

Typedefs

typedef struct NDBOX NDBOX
 
typedef void * yyscan_t
 

Functions

int cube_yylex (YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void cube_yyerror (NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner, const char *message)
 
void cube_scanner_init (const char *str, Size *scanbuflen, yyscan_t *yyscannerp)
 
void cube_scanner_finish (yyscan_t yyscanner)
 
int cube_yyparse (NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
 

Macro Definition Documentation

◆ CUBE_MAX_DIM

#define CUBE_MAX_DIM   (100)

Definition at line 7 of file cubedata.h.

◆ CUBE_SIZE

#define CUBE_SIZE (   _dim)    (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)

Definition at line 49 of file cubedata.h.

◆ CubeKNNDistanceChebyshev

#define CubeKNNDistanceChebyshev   18 /* <=> */

Definition at line 60 of file cubedata.h.

◆ CubeKNNDistanceCoord

#define CubeKNNDistanceCoord   15 /* ~> */

Definition at line 57 of file cubedata.h.

◆ CubeKNNDistanceEuclid

#define CubeKNNDistanceEuclid   17 /* <-> */

Definition at line 59 of file cubedata.h.

◆ CubeKNNDistanceTaxicab

#define CubeKNNDistanceTaxicab   16 /* <#> */

Definition at line 58 of file cubedata.h.

◆ DatumGetNDBOXP

#define DatumGetNDBOXP (   x)    ((NDBOX *) PG_DETOAST_DATUM(x))

Definition at line 52 of file cubedata.h.

◆ DIM

#define DIM (   cube)    ( (cube)->header & DIM_MASK )

Definition at line 42 of file cubedata.h.

◆ DIM_MASK

#define DIM_MASK   0x7fffffff

Definition at line 38 of file cubedata.h.

◆ IS_POINT

#define IS_POINT (   cube)    ( ((cube)->header & POINT_BIT) != 0 )

Definition at line 40 of file cubedata.h.

◆ LL_COORD

#define LL_COORD (   cube,
  i 
)    ( (cube)->x[i] )

Definition at line 45 of file cubedata.h.

◆ PG_GETARG_NDBOX_P

#define PG_GETARG_NDBOX_P (   x)    DatumGetNDBOXP(PG_GETARG_DATUM(x))

Definition at line 53 of file cubedata.h.

◆ PG_RETURN_NDBOX_P

#define PG_RETURN_NDBOX_P (   x)    PG_RETURN_POINTER(x)

Definition at line 54 of file cubedata.h.

◆ POINT_BIT

#define POINT_BIT   0x80000000

Definition at line 37 of file cubedata.h.

◆ POINT_SIZE

#define POINT_SIZE (   _dim)    (offsetof(NDBOX, x) + sizeof(double)*(_dim))

Definition at line 48 of file cubedata.h.

◆ SET_DIM

#define SET_DIM (   cube,
  _dim 
)    ( (cube)->header = ((cube)->header & ~DIM_MASK) | (_dim) )

Definition at line 43 of file cubedata.h.

◆ SET_POINT_BIT

#define SET_POINT_BIT (   cube)    ( (cube)->header |= POINT_BIT )

Definition at line 41 of file cubedata.h.

◆ UR_COORD

#define UR_COORD (   cube,
  i 
)    ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )

Definition at line 46 of file cubedata.h.

◆ YYSTYPE

#define YYSTYPE   char *

Definition at line 64 of file cubedata.h.

Typedef Documentation

◆ NDBOX

typedef struct NDBOX NDBOX

◆ yyscan_t

typedef void* yyscan_t

Definition at line 67 of file cubedata.h.

Function Documentation

◆ cube_scanner_finish()

void cube_scanner_finish ( yyscan_t  yyscanner)

Definition at line 121 of file cubescan.l.

122{
123 yylex_destroy(yyscanner);
124}

Referenced by cube_in().

◆ cube_scanner_init()

void cube_scanner_init ( const char *  str,
Size scanbuflen,
yyscan_t yyscannerp 
)

Definition at line 102 of file cubescan.l.

103{
104 Size slen = strlen(str);
105 yyscan_t yyscanner;
106
107 if (yylex_init(yyscannerp) != 0)
108 elog(ERROR, "yylex_init() failed: %m");
109
110 yyscanner = *yyscannerp;
111
112 yy_scan_bytes(str, slen, yyscanner);
113 *scanbuflen = slen;
114}
size_t Size
Definition: c.h:562
void * yyscan_t
Definition: cubedata.h:67
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
const char * str

References elog, ERROR, and str.

Referenced by cube_in().

◆ cube_yyerror()

void cube_yyerror ( NDBOX **  result,
Size  scanbuflen,
struct Node escontext,
yyscan_t  yyscanner,
const char *  message 
)

Definition at line 71 of file cubescan.l.

75{
76 struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
77 * macro */
78
79 if (*yytext == YY_END_OF_BUFFER_CHAR)
80 {
81 errsave(escontext,
82 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
83 errmsg("invalid input syntax for cube"),
84 /* translator: %s is typically "syntax error" */
85 errdetail("%s at end of input", message)));
86 }
87 else
88 {
89 errsave(escontext,
90 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
91 errmsg("invalid input syntax for cube"),
92 /* translator: first %s is typically "syntax error" */
93 errdetail("%s at or near \"%s\"", message, yytext)));
94 }
95}
int errdetail(const char *fmt,...)
Definition: elog.c:1203
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define errsave(context,...)
Definition: elog.h:261

References errcode(), errdetail(), errmsg(), and errsave.

◆ cube_yylex()

int cube_yylex ( YYSTYPE yylval_param,
yyscan_t  yyscanner 
)

◆ cube_yyparse()

int cube_yyparse ( NDBOX **  result,
Size  scanbuflen,
struct Node escontext,
yyscan_t  yyscanner 
)

Referenced by cube_in().