-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathorc_fdw.h
98 lines (77 loc) · 2.33 KB
/
orc_fdw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*-------------------------------------------------------------------------
*
* orc_fdw.h
*
* Type and function declarations for JSON foreign data wrapper.
*
* Copyright (c) 2013, Citus Data, Inc.
*
* $Id$
*
*-------------------------------------------------------------------------
*/
#ifndef ORC_FDW_H
#define ORC_FDW_H
#include "fmgr.h"
#include "catalog/pg_foreign_server.h"
#include "catalog/pg_foreign_table.h"
#include "utils/hsearch.h"
#include "nodes/pg_list.h"
#include "nodes/relation.h"
#include "orc.pb-c.h"
#include "recordReader.h"
/* when enabled, index data will also be read from the file and unnecessary rows will be skipped */
#define ENABLE_ROW_SKIPPING 1
/* Defines for valid option names and default values */
#define OPTION_NAME_FILENAME "filename"
#define ORC_TUPLE_COST_MULTIPLIER 10
/*
* OrcValidOption keeps an option name and a context. When an option is passed
* into orc_fdw objects (server and foreign table), we compare this option's
* name and context against those of valid options.
*/
typedef struct OrcValidOption
{
const char *optionName;
Oid optionContextId;
} OrcValidOption;
/* Array of options that are valid for orc_fdw */
static const uint32 ValidOptionCount = 3;
static const OrcValidOption ValidOptionArray[] =
{
/* foreign table options */
{ OPTION_NAME_FILENAME, ForeignTableRelationId },
};
/*
* OrcFdwOptions holds the option values to be used when reading and parsing
* the orc file. To resolve these values, we first check foreign table's
* options, and if not present, we then fall back to the default values
* specified above.
*/
typedef struct OrcFdwOptions
{
char *filename;
} OrcFdwOptions;
/*
* OrcFdwExecState keeps foreign data wrapper specific execution state that we
* create and hold onto when executing the query.
*/
typedef struct OrcFdwExecState
{
char *filename;
FILE *file;
PostScript *postScript;
Footer *footer;
StripeFooter *stripeFooter;
CompressionParameters compressionParameters;
FieldReader *recordReader;
MemoryContext orcContext;
List *queryRestrictionList;
uint32 nextStripeNumber;
StripeInformation *currentStripeInfo;
uint32 currentLineNumber;
} OrcFdwExecState;
/* Function declarations for foreign data wrapper */
extern Datum orc_fdw_handler(PG_FUNCTION_ARGS);
extern Datum orc_fdw_validator(PG_FUNCTION_ARGS);
#endif /* orc_fdw_H */