Skip to content

Commit e823b74

Browse files
committed
Fix duplicate symbol issues by replacing cgo usage with direct use of
protobuf encoded export Signed-off-by: Dom Del Nano <[email protected]>
1 parent 9ab85a7 commit e823b74

File tree

6 files changed

+369
-12
lines changed

6 files changed

+369
-12
lines changed

src/e2e_test/vizier/planner/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pl_go_test(
3535
"//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
3636
"//src/carnot/planner/plannerpb:service_pl_go_proto",
3737
"//src/carnot/udfspb:udfs_pl_go_proto",
38-
"//src/e2e_test/vizier/planner/dump_schemas/godumpschemas",
38+
"//src/e2e_test/vizier/planner/dump_schemas/schemas",
3939
"//src/table_store/schemapb:schema_pl_go_proto",
4040
"//src/utils",
4141
"//src/vizier/funcs/go",

src/e2e_test/vizier/planner/all_scripts_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"px.dev/pixie/src/carnot/planner/distributedpb"
4343
"px.dev/pixie/src/carnot/planner/plannerpb"
4444
"px.dev/pixie/src/carnot/udfspb"
45-
"px.dev/pixie/src/e2e_test/vizier/planner/dump_schemas/godumpschemas"
45+
"px.dev/pixie/src/e2e_test/vizier/planner/dump_schemas/schemas"
4646
"px.dev/pixie/src/table_store/schemapb"
4747
"px.dev/pixie/src/utils"
4848
funcs "px.dev/pixie/src/vizier/funcs/go"
@@ -207,7 +207,16 @@ func scriptToQueryRequest(s *script) (*plannerpb.QueryRequest, error) {
207207
}
208208

209209
func loadSchemas() (*schemapb.Schema, error) {
210-
return godumpschemas.DumpSchemas()
210+
schema := &schemapb.Schema{}
211+
b, err := schemas.Asset("src/e2e_test/vizier/planner/dump_schemas/data/schema.pb")
212+
if err != nil {
213+
return nil, err
214+
}
215+
err = proto.Unmarshal(b, schema)
216+
if err != nil {
217+
return nil, err
218+
}
219+
return schema, nil
211220
}
212221

213222
func makePEMCarnotInfo(id uuid.UUID) *distributedpb.CarnotInfo {

src/e2e_test/vizier/planner/dump_schemas/BUILD.bazel

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,23 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
load("//bazel:pl_build_system.bzl", "pl_cc_library")
17+
load("//bazel:pl_build_system.bzl", "pl_cc_binary")
1818

1919
package(default_visibility = ["//src/e2e_test/vizier/planner:__subpackages__"])
2020

21-
pl_cc_library(
22-
name = "dump_schemas",
23-
srcs = [
24-
"dump_schemas.cc",
25-
"dump_schemas.h",
26-
],
27-
hdrs = ["dump_schemas.h"],
21+
pl_cc_binary(
22+
name = "export_schemas",
23+
srcs = ["export_schemas.cc"],
24+
stamp = -1,
2825
deps = [
29-
"//src/shared/schema:cc_library",
3026
"//src/stirling:cc_library",
3127
"//src/table_store/schema:cc_library",
3228
],
3329
)
30+
31+
genrule(
32+
name = "schema_pb",
33+
outs = ["data/schema.pb"],
34+
cmd = "$(location :export_schemas) --out_file_path $@ &>/dev/null",
35+
tools = [":export_schemas"],
36+
)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2018- The Pixie Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
19+
#include <fstream>
20+
#include <iostream>
21+
#include <string>
22+
23+
#include "src/stirling/stirling.h"
24+
#include "src/table_store/schema/schema.h"
25+
26+
DEFINE_string(out_file_path, "schema.pb", "The file to save the serialized Schema");
27+
28+
int main(int argc, char** argv) {
29+
px::EnvironmentGuard env_guard(&argc, argv);
30+
31+
auto source_registry = px::stirling::CreateProdSourceRegistry();
32+
auto sources = source_registry->sources();
33+
34+
absl::flat_hash_map<std::string, px::table_store::schema::Relation> rel_map;
35+
for (const auto& reg_element : sources) {
36+
for (auto schema : reg_element.schema) {
37+
px::table_store::schema::Relation relation;
38+
for (const auto& element : schema.elements()) {
39+
relation.AddColumn(element.type(), std::string(element.name()), element.stype(),
40+
element.desc());
41+
}
42+
rel_map[schema.name()] = relation;
43+
}
44+
}
45+
46+
px::table_store::schemapb::Schema schema_pb;
47+
PX_CHECK_OK(px::table_store::schema::Schema::ToProto(&schema_pb, rel_map));
48+
49+
std::ofstream out_schema;
50+
out_schema.open(FLAGS_out_file_path);
51+
schema_pb.SerializeToOstream(&out_schema);
52+
out_schema.close();
53+
54+
return 0;
55+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2018- The Pixie Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
18+
load("//bazel:pl_build_system.bzl", "pl_bindata")
19+
20+
package(default_visibility = ["//src/e2e_test/vizier/planner:__subpackages__"])
21+
22+
pl_bindata(
23+
name = "schema_bindata",
24+
srcs = ["//src/e2e_test/vizier/planner/dump_schemas:schema_pb"],
25+
package = "schemas",
26+
strip_bin_dir = True,
27+
)
28+
29+
go_library(
30+
name = "schemas",
31+
# keep
32+
srcs = [":schema_bindata"],
33+
importpath = "px.dev/pixie/src/e2e_test/vizier/planner/dump_schemas/schemas",
34+
)

0 commit comments

Comments
 (0)