@@ -248,6 +248,37 @@ class ConfigParser {
248248 return Status::OK ();
249249 }
250250
251+ // parse file.format.per.level
252+ Status ParseFileFormatPerLevel (
253+ std::map<int32_t , std::shared_ptr<FileFormat>>* file_format_per_level_ptr) const {
254+ auto & file_format_per_level = *file_format_per_level_ptr;
255+ std::string file_format_per_level_str;
256+ PAIMON_RETURN_NOT_OK (
257+ ParseString (Options::FILE_FORMAT_PER_LEVEL, &file_format_per_level_str));
258+ if (!file_format_per_level_str.empty ()) {
259+ auto level2format =
260+ StringUtils::Split (file_format_per_level_str, std::string (" ," ), std::string (" :" ));
261+ for (const auto & single_level : level2format) {
262+ if (single_level.size () != 2 ) {
263+ return Status::Invalid (fmt::format (
264+ " fail to parse key {}, value {} (usage example: 0:avro,3:parquet)" ,
265+ Options::FILE_FORMAT_PER_LEVEL, file_format_per_level_str));
266+ }
267+ auto level = StringUtils::StringToValue<int32_t >(single_level[0 ]);
268+ if (!level || level.value () < 0 ) {
269+ return Status::Invalid (
270+ fmt::format (" fail to parse level {} from string to int in {}" ,
271+ single_level[0 ], Options::FILE_FORMAT_PER_LEVEL));
272+ }
273+ std::shared_ptr<FileFormat> file_format;
274+ PAIMON_RETURN_NOT_OK (ParseObject<FileFormatFactory>(
275+ " _no_use" , /* default_identifier=*/ single_level[1 ], &file_format));
276+ file_format_per_level[level.value ()] = file_format;
277+ }
278+ }
279+ return Status::OK ();
280+ }
281+
251282 bool ContainsKey (const std::string& key) const {
252283 return config_map_.find (key) != config_map_.end ();
253284 }
@@ -599,31 +630,7 @@ Result<CoreOptions> CoreOptions::FromMap(
599630 PAIMON_RETURN_NOT_OK (parser.ParseMemorySize (Options::CACHE_PAGE_SIZE, &impl->cache_page_size ));
600631
601632 // parse file.format.per.level
602- std::string file_format_per_level_str;
603- PAIMON_RETURN_NOT_OK (
604- parser.ParseString (Options::FILE_FORMAT_PER_LEVEL, &file_format_per_level_str));
605- if (!file_format_per_level_str.empty ()) {
606- auto level2format =
607- StringUtils::Split (file_format_per_level_str, std::string (" ," ), std::string (" :" ));
608- for (const auto & single_level : level2format) {
609- if (single_level.size () != 2 ) {
610- return Status::Invalid (
611- fmt::format (" fail to parse key {}, value {} (usage example: 0:avro,3:parquet)" ,
612- Options::FILE_FORMAT_PER_LEVEL, file_format_per_level_str));
613- }
614- auto level = StringUtils::StringToValue<int32_t >(single_level[0 ]);
615- if (!level || level.value () < 0 ) {
616- return Status::Invalid (
617- fmt::format (" fail to parse level {} from string to int in {}" , single_level[0 ],
618- Options::FILE_FORMAT_PER_LEVEL));
619- }
620- std::shared_ptr<FileFormat> file_format;
621- PAIMON_RETURN_NOT_OK (parser.ParseObject <FileFormatFactory>(
622- " _no_use" , /* default_identifier=*/ single_level[1 ], &file_format));
623- impl->file_format_per_level [level.value ()] = file_format;
624- }
625- }
626-
633+ PAIMON_RETURN_NOT_OK (parser.ParseFileFormatPerLevel (&impl->file_format_per_level ));
627634 return options;
628635}
629636
0 commit comments