Skip to content

Commit aaa4b95

Browse files
committed
fix code review
1 parent 738b190 commit aaa4b95

8 files changed

Lines changed: 51 additions & 34 deletions

src/paimon/core/core_options.cpp

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/paimon/core/core_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class PAIMON_EXPORT CoreOptions {
153153

154154
private:
155155
struct Impl;
156-
157156
std::unique_ptr<Impl> impl_;
158157
};
159158

src/paimon/core/mergetree/compact/first_row_merge_function_wrapper.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#pragma once
1818

19+
#include <cassert>
20+
#include <functional>
1921
#include <memory>
2022
#include <optional>
2123
#include <utility>
@@ -49,7 +51,11 @@ class FirstRowMergeFunctionWrapper : public MergeFunctionWrapper<KeyValue> {
4951
Reset();
5052
return result;
5153
}
52-
assert(result);
54+
if (!result) {
55+
Reset();
56+
return Status::Invalid(
57+
"In FirstRowMergeFunctionWrapper when call GetResult, there must have a result");
58+
}
5359
PAIMON_ASSIGN_OR_RAISE(bool contains, contains_(result.value().key));
5460
if (contains) {
5561
// empty

src/paimon/core/mergetree/compact/lookup_changelog_merge_function_wrapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616

1717
#pragma once
1818

19+
#include <algorithm>
20+
#include <functional>
1921
#include <memory>
2022
#include <optional>
23+
#include <string>
2124
#include <utility>
2225

2326
#include "paimon/core/deletionvectors/bucketed_dv_maintainer.h"

src/paimon/core/mergetree/compact/lookup_merge_tree_compact_rewriter_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,6 @@ TEST_F(LookupMergeTreeCompactRewriterTest, TestRewriteLookupChangelogWithOutputL
11341134
ASSERT_OK_AND_ASSIGN(auto runs, GenerateSortedRuns({file0, file1}));
11351135

11361136
// When output_level is 0, RewriteLookupChangelog should return false
1137-
// This tests the condition at line 59 in changelog_merge_tree_rewriter.cpp
11381137
ASSERT_OK_AND_ASSIGN(auto compact_result, rewriter->Rewrite(
11391138
/*output_level=*/0, /*drop_delete=*/true, runs));
11401139
ASSERT_EQ(2, compact_result.Before().size());

src/paimon/core/mergetree/compact/merge_tree_compact_rewriter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ class MergeTreeCompactRewriter : public CompactRewriter {
9292
KeyValueRollingFileWriter* rolling_writer,
9393
std::vector<std::shared_ptr<KeyValueMergeReader>>* reader_holders_ptr);
9494

95-
private:
96-
Result<std::shared_ptr<DataFilePathFactory>> CreateDataFilePathFactory(
97-
const std::string& format);
98-
9995
protected:
10096
CoreOptions options_;
10197
std::unique_ptr<MergeFileSplitRead> merge_file_split_read_;
10298

99+
private:
100+
Result<std::shared_ptr<DataFilePathFactory>> CreateDataFilePathFactory(
101+
const std::string& format);
102+
103103
private:
104104
std::shared_ptr<MemoryPool> pool_;
105105
BinaryRow partition_;

src/paimon/core/mergetree/lookup_levels.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class LookupLevels {
5757
const SortedRun& level);
5858

5959
Status Close() {
60-
// TODDO(xinyu.lxy): invalid cache
60+
// TODO(xinyu.lxy): invalid cache
6161
lookup_file_cache_.clear();
6262
return Status::OK();
6363
}

src/paimon/core/utils/file_store_path_factory_cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616

1717
#pragma once
1818

19+
#include <map>
20+
#include <string>
21+
#include <vector>
22+
1923
#include "paimon/core/core_options.h"
2024
#include "paimon/core/schema/table_schema.h"
2125
#include "paimon/core/utils/file_store_path_factory.h"
2226
#include "paimon/memory/memory_pool.h"
2327
#include "paimon/result.h"
24-
2528
namespace paimon {
2629
class FileStorePathFactoryCache {
2730
public:

0 commit comments

Comments
 (0)