-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscalardb.h
131 lines (113 loc) · 4.3 KB
/
scalardb.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright 2023 Scalar, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SCALARDB_H
#define SCALARDB_H
#include "c.h"
#include "postgres.h"
#include "executor/tuptable.h"
#include "foreign/foreign.h"
#include "jni.h"
#include "nodes/execnodes.h"
#include "option.h"
/*
* Represents a clustering key order.
*
* The integer value of this enum is intentionally matched with the ordinal value of
* com.scalar.db.api.Scan.Ordering.Order
*/
typedef enum {
SCALARDB_CLUSTERING_KEY_ORDER_ASC,
SCALARDB_CLUSTERING_KEY_ORDER_DESC,
} ScalarDbFdwClusteringKeyOrder;
/*
* Represents a key condition of Scan operation in the executor phase.
*/
typedef struct {
/* column name */
char *name;
/* condition value*/
Datum value;
/* type of value */
Oid value_type;
} ScalarDbFdwScanCondition;
/*
* Represents a clustering key boundary of Scan operation in the executor phase.
*/
typedef struct {
/* column names. List of String */
List *names;
/* condition values for start boundary */
Datum *start_values;
/* a number of start_values */
size_t num_start_values;
/* types of values for start boundary. List of Oid */
List *start_value_types;
/* indicates whether start boundary is inclusive */
bool start_inclusive;
/* condition values for end boundary */
Datum *end_values;
/* a number of end_values */
size_t num_end_values;
/* types of values for end boundary. List of Oid */
List *end_value_types;
/* indicates whether end boundary is inclusive */
bool end_inclusive;
/* indicates whether each condition is equal operation */
List *is_equals;
} ScalarDbFdwScanBoundary;
extern void scalardb_initialize(ScalarDbFdwOptions *opts);
extern jobject scalardb_scan_all(char *namespace, char *table_name,
List *attnames);
extern jobject scalardb_scan(char *namespace, char *table_name, List *attnames,
ScalarDbFdwScanCondition *scan_conds,
size_t scan_conds_len,
ScalarDbFdwScanBoundary *boundary,
List *sort_column_names, List *sort_orders);
extern jobject scalardb_scan_with_index(char *namespace, char *table_name,
List *attnames,
ScalarDbFdwScanCondition *scan_conds,
size_t scan_conds_len);
extern void scalardb_release_scan(jobject scan);
extern jobject scalardb_start_scan(jobject scan);
extern jobject scalardb_scanner_one(jobject scanner);
extern void scalardb_scanner_release_result(void);
extern void scalardb_scanner_close(jobject scanner);
extern int scalardb_list_size(jobject list);
extern jobject scalardb_list_iterator(jobject list);
extern bool scalardb_iterator_has_next(jobject iterator);
extern jobject scalardb_iterator_next(jobject iterator);
extern bool scalardb_optional_is_present(jobject optional);
extern jobject scalardb_optional_get(jobject optional);
extern bool scalardb_result_is_null(jobject result, char *attname);
extern bool scalardb_result_get_boolean(jobject result, char *attname);
extern int scalardb_result_get_int(jobject result, char *attname);
extern long scalardb_result_get_bigint(jobject result, char *attname);
extern float scalardb_result_get_float(jobject result, char *attname);
extern double scalardb_result_get_double(jobject result, char *attname);
extern text *scalardb_result_get_text(jobject result, char *attname);
extern bytea *scalardb_result_get_blob(jobject result, char *attname);
extern int scalardb_result_columns_size(jobject result);
extern void scalardb_get_paritition_key_names(char *namespace, char *table_name,
List **partition_key_names);
extern void
scalardb_get_clustering_key_names_and_orders(char *namespace, char *table_name,
List **clustering_key_names,
List **clustering_key_orders);
extern void scalardb_get_secondary_index_names(char *namespace,
char *table_name,
List **secondary_index_names);
extern char *scalardb_to_string(jobject scan);
#endif