Skip to content

Commit 754026b

Browse files
committed
update protocol code
1 parent 4f8c525 commit 754026b

File tree

4 files changed

+31
-89
lines changed

4 files changed

+31
-89
lines changed

presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.cpp

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -89,43 +89,6 @@ void from_json(const json& j, ClpSplit& p) {
8989
}
9090
} // namespace facebook::presto::protocol::clp
9191
namespace facebook::presto::protocol::clp {
92-
// Loosly copied this here from NLOHMANN_JSON_SERIALIZE_ENUM()
93-
94-
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
95-
static const std::pair<StorageType, json> StorageType_enum_table[] =
96-
{ // NOLINT: cert-err58-cpp
97-
{StorageType::FS, "FS"},
98-
{StorageType::S3, "S3"}};
99-
void to_json(json& j, const StorageType& e) {
100-
static_assert(
101-
std::is_enum<StorageType>::value, "StorageType must be an enum!");
102-
const auto* it = std::find_if(
103-
std::begin(StorageType_enum_table),
104-
std::end(StorageType_enum_table),
105-
[e](const std::pair<StorageType, json>& ej_pair) -> bool {
106-
return ej_pair.first == e;
107-
});
108-
j = ((it != std::end(StorageType_enum_table))
109-
? it
110-
: std::begin(StorageType_enum_table))
111-
->second;
112-
}
113-
void from_json(const json& j, StorageType& e) {
114-
static_assert(
115-
std::is_enum<StorageType>::value, "StorageType must be an enum!");
116-
const auto* it = std::find_if(
117-
std::begin(StorageType_enum_table),
118-
std::end(StorageType_enum_table),
119-
[&j](const std::pair<StorageType, json>& ej_pair) -> bool {
120-
return ej_pair.second == j;
121-
});
122-
e = ((it != std::end(StorageType_enum_table))
123-
? it
124-
: std::begin(StorageType_enum_table))
125-
->first;
126-
}
127-
} // namespace facebook::presto::protocol::clp
128-
namespace facebook::presto::protocol::clp {
12992
ClpTableHandle::ClpTableHandle() noexcept {
13093
_type = "clp";
13194
}
@@ -141,12 +104,7 @@ void to_json(json& j, const ClpTableHandle& p) {
141104
"SchemaTableName",
142105
"schemaTableName");
143106
to_json_key(
144-
j,
145-
"storageType",
146-
p.storageType,
147-
"ClpTableHandle",
148-
"StorageType",
149-
"storageType");
107+
j, "tablePath", p.tablePath, "ClpTableHandle", "String", "tablePath");
150108
}
151109

152110
void from_json(const json& j, ClpTableHandle& p) {
@@ -159,12 +117,7 @@ void from_json(const json& j, ClpTableHandle& p) {
159117
"SchemaTableName",
160118
"schemaTableName");
161119
from_json_key(
162-
j,
163-
"storageType",
164-
p.storageType,
165-
"ClpTableHandle",
166-
"StorageType",
167-
"storageType");
120+
j, "tablePath", p.tablePath, "ClpTableHandle", "String", "tablePath");
168121
}
169122
} // namespace facebook::presto::protocol::clp
170123
namespace facebook::presto::protocol::clp {
@@ -179,6 +132,13 @@ void to_json(json& j, const ClpTableLayoutHandle& p) {
179132
j, "table", p.table, "ClpTableLayoutHandle", "ClpTableHandle", "table");
180133
to_json_key(
181134
j, "kqlQuery", p.kqlQuery, "ClpTableLayoutHandle", "String", "kqlQuery");
135+
to_json_key(
136+
j,
137+
"metadataFilterQuery",
138+
p.metadataFilterQuery,
139+
"ClpTableLayoutHandle",
140+
"String",
141+
"metadataFilterQuery");
182142
}
183143

184144
void from_json(const json& j, ClpTableLayoutHandle& p) {
@@ -187,5 +147,12 @@ void from_json(const json& j, ClpTableLayoutHandle& p) {
187147
j, "table", p.table, "ClpTableLayoutHandle", "ClpTableHandle", "table");
188148
from_json_key(
189149
j, "kqlQuery", p.kqlQuery, "ClpTableLayoutHandle", "String", "kqlQuery");
150+
from_json_key(
151+
j,
152+
"metadataFilterQuery",
153+
p.metadataFilterQuery,
154+
"ClpTableLayoutHandle",
155+
"String",
156+
"metadataFilterQuery");
190157
}
191158
} // namespace facebook::presto::protocol::clp

presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@ void to_json(json& j, const ClpTransactionHandle& p);
3030

3131
void from_json(const json& j, ClpTransactionHandle& p);
3232
} // namespace facebook::presto::protocol::clp
33-
/*
34-
* Licensed under the Apache License, Version 2.0 (the "License");
35-
* you may not use this file except in compliance with the License.
36-
* You may obtain a copy of the License at
37-
*
38-
* http://www.apache.org/licenses/LICENSE-2.0
39-
*
40-
* Unless required by applicable law or agreed to in writing, software
41-
* distributed under the License is distributed on an "AS IS" BASIS,
42-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43-
* See the License for the specific language governing permissions and
44-
* limitations under the License.
45-
*/
46-
4733
// ClpColumnHandle is special since it needs an implementation of
4834
// operator<().
4935

@@ -73,14 +59,9 @@ void to_json(json& j, const ClpSplit& p);
7359
void from_json(const json& j, ClpSplit& p);
7460
} // namespace facebook::presto::protocol::clp
7561
namespace facebook::presto::protocol::clp {
76-
enum class StorageType { FS, S3 };
77-
extern void to_json(json& j, const StorageType& e);
78-
extern void from_json(const json& j, StorageType& e);
79-
} // namespace facebook::presto::protocol::clp
80-
namespace facebook::presto::protocol::clp {
8162
struct ClpTableHandle : public ConnectorTableHandle {
8263
SchemaTableName schemaTableName = {};
83-
StorageType storageType = {};
64+
String tablePath = {};
8465

8566
ClpTableHandle() noexcept;
8667
};
@@ -91,6 +72,7 @@ namespace facebook::presto::protocol::clp {
9172
struct ClpTableLayoutHandle : public ConnectorTableLayoutHandle {
9273
ClpTableHandle table = {};
9374
std::shared_ptr<String> kqlQuery = {};
75+
std::shared_ptr<String> metadataFilterQuery = {};
9476

9577
ClpTableLayoutHandle() noexcept;
9678
};

presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.json

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
{
66
"class_name": "ClpColumnHandle",
7-
"hinc": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// ClpColumnHandle is special since it needs an implementation of\n// operator<().\n\nnamespace facebook::presto::protocol::clp {\nstruct ClpColumnHandle : public ColumnHandle {\n String columnName = {};\n String originalColumnName = {};\n Type columnType = {};\n boolean nullable = {};\n\n ClpColumnHandle() noexcept;\n\n bool operator<(const ColumnHandle& o) const override {\n return columnName < dynamic_cast<const ClpColumnHandle&>(o).columnName;\n }\n};\nvoid to_json(json& j, const ClpColumnHandle& p);\nvoid from_json(const json& j, ClpColumnHandle& p);\n} // namespace facebook::presto::protocol::clp",
7+
"hinc": "// ClpColumnHandle is special since it needs an implementation of\n// operator<().\n\nnamespace facebook::presto::protocol::clp {\nstruct ClpColumnHandle : public ColumnHandle {\n String columnName = {};\n String originalColumnName = {};\n Type columnType = {};\n boolean nullable = {};\n\n ClpColumnHandle() noexcept;\n\n bool operator<(const ColumnHandle& o) const override {\n return columnName < dynamic_cast<const ClpColumnHandle&>(o).columnName;\n }\n};\nvoid to_json(json& j, const ClpColumnHandle& p);\nvoid from_json(const json& j, ClpColumnHandle& p);\n} // namespace facebook::presto::protocol::clp",
88
"struct": true,
99
"fields": [
1010
{
@@ -56,21 +56,6 @@
5656
"super_class": "ConnectorSplit",
5757
"json_key": "clp"
5858
},
59-
{
60-
"class_name": "StorageType",
61-
"enum": true,
62-
"elements": [
63-
{
64-
"element": "FS",
65-
"_N": 1
66-
},
67-
{
68-
"element": "S3",
69-
"_N": 2,
70-
"_last": true
71-
}
72-
]
73-
},
7459
{
7560
"class_name": "ClpTableHandle",
7661
"struct": true,
@@ -83,9 +68,9 @@
8368
"field_local": true
8469
},
8570
{
86-
"field_type": "StorageType",
87-
"field_name": "storageType",
88-
"field_text": "StorageType",
71+
"field_type": "String",
72+
"field_name": "tablePath",
73+
"field_text": "String",
8974
"_N": 2,
9075
"field_local": true
9176
}
@@ -112,6 +97,14 @@
11297
"optional": true,
11398
"_N": 2,
11499
"field_local": true
100+
},
101+
{
102+
"field_type": "Optional<String>",
103+
"field_name": "metadataFilterQuery",
104+
"field_text": "String",
105+
"optional": true,
106+
"_N": 3,
107+
"field_local": true
115108
}
116109
],
117110
"subclass": true,

presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def member_name(name):
170170
def special(filepath, current_class, key, classes, depends):
171171
classes[current_class].class_name = current_class
172172
(status, stdout, stderr) = classes[current_class][key] = util.run(
173-
"../../velox/scripts/license-header.py --header ../../license.header --remove "
173+
"../../velox/scripts/checks/license-header.py --header ../../license.header --remove "
174174
+ filepath
175175
)
176176
classes[current_class][key] = stdout

0 commit comments

Comments
 (0)