Skip to content

Commit a1c5e72

Browse files
committed
Always load binary
1 parent af8a228 commit a1c5e72

File tree

5 files changed

+6
-29
lines changed

5 files changed

+6
-29
lines changed

include/substrait/common/Io.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ enum class PlanFileFormat {
3030
* amount of memory that it consumed on disk.
3131
*
3232
* \param input_filename The filename containing the plan to convert.
33-
* \param force_binary If true, the plan will be opened as a binary file.
34-
* Required on Windows to avoid text mode line-ending translation.
3533
* \return If loading was successful, returns a plan. If loading was not
3634
* successful this is a status containing a list of parse errors in the status's
3735
* message.
3836
*/
3937
absl::StatusOr<::substrait::proto::Plan> loadPlan(
40-
std::string_view input_filename,
41-
bool force_binary = false);
38+
std::string_view input_filename);
4239

4340
/*
4441
* \brief Writes the provided plan to disk.

src/substrait/common/Io.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ PlanFileFormat detectFormat(std::string_view content) {
3737
} // namespace
3838

3939
absl::StatusOr<::substrait::proto::Plan> loadPlan(
40-
std::string_view input_filename,
41-
bool forceBinary) {
42-
auto contentOrError =
43-
textplan::readFromFile(input_filename.data(), forceBinary);
40+
std::string_view input_filename) {
41+
auto contentOrError = textplan::readFromFile(input_filename.data());
4442
if (!contentOrError.ok()) {
4543
return contentOrError.status();
4644
}

src/substrait/common/tests/IoTest.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,7 @@ TEST_P(SaveAndLoadTestFixture, SaveAndLoad) {
8787
read->mutable_named_table()->add_names("table_name");
8888
auto status = ::io::substrait::savePlan(plan, tempFilename, encoding);
8989
ASSERT_TRUE(status.ok()) << "Save failed.\n" << status;
90-
91-
#ifdef _WIN32
92-
// Windows cannot rely on io::substrait::loadPlan to detect the file format,
93-
// since it needs to a-priori specify how the file should be loaded.
94-
bool forceBinary = encoding == PlanFileFormat::kBinary;
95-
auto result = ::io::substrait::loadPlan(tempFilename, forceBinary);
96-
#else
9790
auto result = ::io::substrait::loadPlan(tempFilename);
98-
#endif
99-
10091
ASSERT_TRUE(result.ok()) << "Load failed.\n" << result.status();
10192
ASSERT_THAT(
10293
*result,

src/substrait/textplan/converter/LoadBinary.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,8 @@ class StringErrorCollector : public google::protobuf::io::ErrorCollector {
4242

4343
} // namespace
4444

45-
absl::StatusOr<std::string> readFromFile(
46-
std::string_view msgPath,
47-
bool forceBinary) {
48-
std::ifstream file;
49-
if (forceBinary)
50-
file.open(std::string{msgPath}, std::ios::binary);
51-
else
52-
file.open(std::string{msgPath}, std::ios::in);
53-
45+
absl::StatusOr<std::string> readFromFile(std::string_view msgPath) {
46+
std::ifstream file(std::string{msgPath}, std::ios::binary);
5447
if (file.fail()) {
5548
auto currDir = std::filesystem::current_path().string();
5649
return absl::ErrnoToStatus(

src/substrait/textplan/converter/LoadBinary.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ namespace io::substrait::textplan {
1414

1515
// Read the contents of a file from disk. 'forceBinary' enables file reading in
1616
// binary mode.
17-
absl::StatusOr<std::string> readFromFile(
18-
std::string_view msgPath,
19-
bool forceBinary = false);
17+
absl::StatusOr<std::string> readFromFile(std::string_view msgPath);
2018

2119
// Reads a plan from a json-encoded text proto.
2220
// Returns a list of errors if the file cannot be parsed.

0 commit comments

Comments
 (0)