baibaichen commented on code in PR #8052:
URL: https://github.com/apache/incubator-gluten/pull/8052#discussion_r1866910322
##########
cpp-ch/local-engine/Storages/Output/NormalFileWriter.h:
##########
@@ -230,20 +230,57 @@ class WriteStats : public WriteStatsBase
struct FileNameGenerator
{
- const bool pattern;
- const std::string filename_or_pattern;
+ // Align with org.apache.spark.sql.execution.FileNamePlaceHolder
+ const std::vector<std::string> placeholders = {"{id}", "{bucket}"};
+ // Align with placeholders above
+ const std::vector<bool> need_replaced;
+ const std::string file_pattern;
+
+ FileNameGenerator(const std::string& file_pattern)
+ : file_pattern(file_pattern),
need_replaced(compute_need_replaced(file_pattern))
+ {
+ }
+
+ std::vector<bool> compute_need_replaced(const std::string & file_pattern)
+ {
+ std::vector<bool> result;
+ for(const std::string& placeholder: placeholders)
+ {
+ if (file_pattern.find(placeholder) != std::string::npos)
+ result.push_back(true);
+ else
+ result.push_back(false);
+ }
+ return result;
+ }
+
+ std::string generate(const std::string bucket = "") const
+ {
+ std::string result = file_pattern;
+ if (need_replaced[0])
+ result = pattern_format(placeholders[0],
toString(DB::UUIDHelpers::generateV4()));
+ if (need_replaced[1])
+ result = pattern_format(placeholders[1], bucket);
+ return result;
+ }
- std::string generate() const
+ std::string pattern_format(std::string arg, std::string replacement) const
Review Comment:
参数使用引用
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]