这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tuplex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ if(GENERATE_PDFS)
else()
message(STATUS "PDF generation for ASTs and logical plans disabled. Enable by setting -DGENERATE_PDFS=ON.")
endif()

# suppress "#warning" directive otuput
option(SHOW_EXPLICIT_WARNINGS "Show the output of #warning directives in the code (lots of output)" OFF)
if(SHOW_EXPLICIT_WARNINGS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add message(STATUS "Disabled output of #warning directives in the code, use SHOW_EXPLICIT_WARNINGS to turn all warnings on") or so?

else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cpp")
endif()

###########################################################################
# (1) supported compilers and fixes
###########################################################################
Expand Down
4 changes: 2 additions & 2 deletions tuplex/codegen/include/Pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Pipe {
* @param file_input
* @return return value of the process
*/
int pipe(const std::string& file_input = "");
int pipe(const std::string& file_input = "", const std::string& tmpdir = "/tmp");

/*!
* return value of the command executed
Expand All @@ -45,4 +45,4 @@ class Pipe {
std::string stderr() const { assert(_executed); return _stderr; }
};

#endif //TUPLEX_PIPE_H
#endif //TUPLEX_PIPE_H
30 changes: 21 additions & 9 deletions tuplex/codegen/src/Pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <fstream>
#include <cstdlib>

int Pipe::pipe(const std::string& file_input) {
int Pipe::pipe(const std::string& file_input, const std::string& tmpdir) {

try {

Expand All @@ -41,13 +41,25 @@ int Pipe::pipe(const std::string& file_input) {
// @TODO: global temp dir should be used...
// needs to be a configurable option...

// deprecated
// @TODO
std::string tmppath = std::tmpnam(nullptr);
std::ofstream ofs(tmppath + ".py");
ofs<<file_input;
ofs.close();
cmd += " " + tmppath + ".py";
char* tmpname = new char[tmpdir.size() + 13];
snprintf(tmpname, tmpdir.size() + 13, "%s/pipe-XXXXXX", tmpdir.c_str());
int fd = mkstemp(tmpname);
if (fd < 0) {
Logger::instance().logger("pipe").error(std::string("error while creating temporary file"));
_retval = 1;
return retval();
}

std::FILE* tmp = fdopen(fd, "w");
if (!tmp) {
Logger::instance().logger("pipe").error(std::string("error opening temporary file"));
_retval = 1;
return retval();
}

fwrite(file_input.c_str(), file_input.size(), 1, tmp);
fclose(tmp);
cmd += " " + std::string(tmpname);
}

child c(cmd, std_err > pipe_stderr, std_out > pipe_stdout);
Expand All @@ -71,4 +83,4 @@ int Pipe::pipe(const std::string& file_input) {

_executed = true;
return retval();
}
}
9 changes: 1 addition & 8 deletions tuplex/utils/include/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,6 @@ namespace tuplex {
return "";
}

/*!
* temporary filename
* @return
*/
extern std::string temporaryPathName();


// hashing functions
// based on https://stackoverflow.com/questions/34597260/stdhash-value-on-char-value-and-not-on-memory-address
// and http://www.isthe.com/chongo/tech/comp/fnv/index.html
Expand Down Expand Up @@ -506,4 +499,4 @@ namespace tuplex {
}
}

#endif //TUPLEX_UTILS_H
#endif //TUPLEX_UTILS_H
7 changes: 1 addition & 6 deletions tuplex/utils/src/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,4 @@ namespace tuplex {
os << "|" << std::endl;
}
}

std::string temporaryPathName() {
// reimplement safer...
return std::tmpnam(nullptr);
}
}
}