Unverified Commit ed4d0ae3 authored by htgeis's avatar htgeis Committed by GitHub
Browse files

support more filesystem as the storage for model file (#3730)


Co-authored-by: default avatarjingwei.su <jingwei.su@hulu.com>
parent 31bc196a
...@@ -404,13 +404,13 @@ std::string GBDT::SaveModelToString(int start_iteration, int num_iteration, int ...@@ -404,13 +404,13 @@ std::string GBDT::SaveModelToString(int start_iteration, int num_iteration, int
bool GBDT::SaveModelToFile(int start_iteration, int num_iteration, int feature_importance_type, const char* filename) const { bool GBDT::SaveModelToFile(int start_iteration, int num_iteration, int feature_importance_type, const char* filename) const {
/*! \brief File to write models */ /*! \brief File to write models */
std::ofstream output_file; auto writer = VirtualFileWriter::Make(filename);
output_file.open(filename, std::ios::out | std::ios::binary); if (!writer->Init()) {
Log::Fatal("Model file %s is not available for writes", filename);
}
std::string str_to_write = SaveModelToString(start_iteration, num_iteration, feature_importance_type); std::string str_to_write = SaveModelToString(start_iteration, num_iteration, feature_importance_type);
output_file.write(str_to_write.c_str(), str_to_write.size()); auto size = writer->Write(str_to_write.c_str(), str_to_write.size());
output_file.close(); return size > 0;
return static_cast<bool>(output_file);
} }
bool GBDT::LoadModelFromString(const char* buffer, size_t len) { bool GBDT::LoadModelFromString(const char* buffer, size_t len) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment