Skip to content

Commit 456112c

Browse files
committed
fix
1 parent 989a544 commit 456112c

17 files changed

Lines changed: 452 additions & 221 deletions

include/paimon/file_store_commit.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class PAIMON_EXPORT FileStoreCommit {
8383

8484
/// Overwrite from manifest committable and partition.
8585
///
86-
/// @param partitions A single partition maps each partition key to a partition value. Depending
86+
/// @param partition A single partition maps each partition key to a partition value. Depending
8787
/// on the user-defined statement, the partition might not include all partition keys. Also
8888
/// note that this partition does not necessarily equal to the partitions of the newly added
8989
/// key-values. This is just the partition to be cleaned up.
@@ -92,22 +92,22 @@ class PAIMON_EXPORT FileStoreCommit {
9292
/// @param watermark An optional event-time watermark used to indicate the progress of data
9393
/// processing. Default is std::nullopt.
9494
/// @return Result of the operation.
95-
virtual Status Overwrite(const std::vector<std::map<std::string, std::string>>& partitions,
95+
virtual Status Overwrite(const std::map<std::string, std::string>& partition,
9696
const std::vector<std::shared_ptr<CommitMessage>>& commit_messages,
9797
int64_t commit_identifier,
9898
std::optional<int64_t> watermark = std::nullopt) = 0;
9999

100100
/// This is a temporary interface for internal use. It will be removed in a future version.
101101
/// Please do not rely on it for long-term use.
102102
///
103-
/// @param partitions Description of the partitions.
103+
/// @param partition Description of the partition.
104104
/// @param commit_messages Description of the commit messages.
105105
/// @param commit_identifier Unique identifier.
106106
/// @param watermark An optional event-time watermark used to indicate the progress of data
107107
/// processing. Default is std::nullopt.
108108
/// @return Result of the operation.
109109
virtual Result<int32_t> FilterAndOverwrite(
110-
const std::vector<std::map<std::string, std::string>>& partitions,
110+
const std::map<std::string, std::string>& partition,
111111
const std::vector<std::shared_ptr<CommitMessage>>& commit_messages,
112112
int64_t commit_identifier, std::optional<int64_t> watermark = std::nullopt) = 0;
113113

src/paimon/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ set(PAIMON_CORE_SRCS
289289
core/operation/append_only_file_store_write.cpp
290290
core/operation/commit/conflict_detection.cpp
291291
core/operation/commit/commit_scanner.cpp
292+
core/operation/commit/commit_changes_provider.cpp
293+
core/operation/commit/overwrite_changes_provider.cpp
292294
core/operation/commit/row_id_column_conflict_checker.cpp
293295
core/operation/commit/manifest_entry_changes.cpp
294296
core/operation/commit/row_tracking_commit_utils.cpp

src/paimon/core/manifest/manifest_committable.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ class ManifestCommittable {
4040
: ManifestCommittable(identifier, std::nullopt) {}
4141

4242
ManifestCommittable(int64_t identifier, std::optional<int64_t> watermark)
43-
: ManifestCommittable(identifier, watermark, {}, {}, {}) {}
43+
: ManifestCommittable(identifier, watermark, {}, {}) {}
4444

4545
ManifestCommittable(int64_t identifier, std::optional<int64_t> watermark,
46-
const std::map<int32_t, int64_t>& log_offsets,
4746
const std::map<std::string, std::string>& properties,
4847
const std::vector<std::shared_ptr<CommitMessage>>& commit_messages)
4948
: identifier_(identifier),
5049
watermark_(watermark),
51-
log_offsets_(log_offsets),
5250
properties_(properties),
5351
commit_messages_(commit_messages) {}
5452

@@ -60,10 +58,6 @@ class ManifestCommittable {
6058
return watermark_;
6159
}
6260

63-
const std::map<int32_t, int64_t>& LogOffsets() const {
64-
return log_offsets_;
65-
}
66-
6761
const std::map<std::string, std::string>& Properties() const {
6862
return properties_;
6963
}
@@ -86,29 +80,22 @@ class ManifestCommittable {
8680
std::string watermark_str =
8781
watermark_ == std::nullopt ? "null" : std::to_string(watermark_.value());
8882

89-
std::vector<std::string> log_offsets_str;
90-
log_offsets_str.reserve(log_offsets_.size());
91-
for (const auto& [key, value] : log_offsets_) {
92-
log_offsets_str.emplace_back(fmt::format("{}: {}", key, value));
93-
}
94-
9583
std::vector<std::string> properties_str;
9684
properties_str.reserve(properties_.size());
9785
for (const auto& [key, value] : properties_) {
9886
properties_str.emplace_back(fmt::format("{}: {}", key, value));
9987
}
10088

10189
return fmt::format(
102-
"ManifestCommittable {{identifier = {}, watermark = {}, logOffsets = {}, "
90+
"ManifestCommittable {{identifier = {}, watermark = {}, "
10391
"commitMessages = {}, properties = {}}}",
104-
identifier_, watermark_str, fmt::join(log_offsets_str, ", "),
105-
fmt::join(commit_messages_str, ", "), fmt::join(properties_str, ", "));
92+
identifier_, watermark_str, fmt::join(commit_messages_str, ", "),
93+
fmt::join(properties_str, ", "));
10694
}
10795

10896
private:
10997
int64_t identifier_;
11098
std::optional<int64_t> watermark_;
111-
std::map<int32_t, int64_t> log_offsets_;
11299
std::map<std::string, std::string> properties_;
113100
std::vector<std::shared_ptr<CommitMessage>> commit_messages_;
114101
};

src/paimon/core/manifest/manifest_committable_test.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@ namespace paimon::test {
2929

3030
class ManifestCommittableTest : public testing::Test {
3131
private:
32-
bool IsEqualMap(const std::map<int32_t, int64_t>& actual_map,
33-
const std::map<int32_t, int64_t>& expected_map) {
34-
if (expected_map.size() != actual_map.size()) {
35-
return false;
36-
}
37-
for (const auto& kv : expected_map) {
38-
const auto& key = kv.first;
39-
const auto& value = kv.second;
40-
auto iter = actual_map.find(key);
41-
if (iter != actual_map.end()) {
42-
if (iter->second == value) {
43-
continue;
44-
} else {
45-
return false;
46-
}
47-
} else {
48-
return false;
49-
}
50-
}
51-
return true;
52-
}
53-
5432
std::vector<std::shared_ptr<CommitMessage>> GetCommitMessages(const std::string& path,
5533
int32_t version) const {
5634
auto file_system = std::make_shared<LocalFileSystem>();
@@ -99,26 +77,23 @@ TEST_F(ManifestCommittableTest, TestSimple) {
9977
ASSERT_EQ(committable.Watermark().value(), 456);
10078
}
10179
{
102-
std::map<int32_t, int64_t> log_offsets = {{123, 444}, {234, 555}};
10380
std::map<std::string, std::string> properties = {};
10481
std::vector<std::shared_ptr<CommitMessage>> msgs =
10582
GetCommitMessages(paimon::test::GetDataDir() +
10683
"/orc/append_09.db/append_09/commit_messages/commit_messages-01",
10784
/*version=*/3);
108-
ManifestCommittable committable(/*identifier=*/123, /*watermark=*/456, log_offsets,
109-
properties, msgs);
110-
ASSERT_TRUE(IsEqualMap(committable.LogOffsets(), log_offsets));
85+
ManifestCommittable committable(/*identifier=*/123, /*watermark=*/456, properties, msgs);
86+
ASSERT_EQ(committable.Properties(), properties);
11187
ASSERT_TRUE(IsEqualMsgs(msgs, committable.FileCommittables()));
11288
}
11389
{
114-
std::map<int32_t, int64_t> log_offsets = {};
11590
std::map<std::string, std::string> properties = {{"key1", "value1"}, {"key2", "value2"}};
11691
std::vector<std::shared_ptr<CommitMessage>> msgs =
11792
GetCommitMessages(paimon::test::GetDataDir() +
11893
"/orc/append_09.db/append_09/commit_messages/commit_messages-01",
11994
/*version=*/3);
12095
ManifestCommittable committable(/*identifier=*/123, /*watermark=*/456,
121-
/*log_offsets=*/{}, properties, msgs);
96+
properties, msgs);
12297
ASSERT_EQ(committable.Properties(), properties);
12398
ASSERT_TRUE(IsEqualMsgs(msgs, committable.FileCommittables()));
12499
}

src/paimon/core/operation/abstract_file_store_write.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ int32_t AbstractFileStoreWrite::GetDefaultBucketNum() const {
281281

282282
Result<std::shared_ptr<RestoreFiles>> AbstractFileStoreWrite::ScanExistingFileMetas(
283283
const BinaryRow& partition, int32_t bucket) const {
284-
PAIMON_ASSIGN_OR_RAISE(auto part_values,
284+
std::vector<std::pair<std::string, std::string>> part_values;
285+
PAIMON_ASSIGN_OR_RAISE(part_values,
285286
file_store_path_factory_->GeneratePartitionVector(partition));
286287
std::map<std::string, std::string> part_values_map;
287288
for (const auto& [key, value] : part_values) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2024-present Alibaba Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "paimon/core/operation/commit/commit_changes_provider.h"
18+
19+
#include <utility>
20+
21+
namespace paimon {
22+
23+
StaticCommitChangesProvider::StaticCommitChangesProvider(
24+
const std::vector<ManifestEntry>& delta_files,
25+
const std::vector<ManifestEntry>& changelog_files,
26+
const std::vector<IndexManifestEntry>& index_entries)
27+
: delta_files_(delta_files),
28+
changelog_files_(changelog_files),
29+
index_entries_(index_entries) {}
30+
31+
Status StaticCommitChangesProvider::Provide(const std::optional<Snapshot>&,
32+
std::vector<ManifestEntry>* delta_files,
33+
std::vector<ManifestEntry>* changelog_files,
34+
std::vector<IndexManifestEntry>* index_entries) const {
35+
*delta_files = delta_files_;
36+
*changelog_files = changelog_files_;
37+
*index_entries = index_entries_;
38+
return Status::OK();
39+
}
40+
41+
} // namespace paimon
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2024-present Alibaba Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <functional>
20+
#include <optional>
21+
#include <vector>
22+
23+
#include "paimon/core/manifest/index_manifest_entry.h"
24+
#include "paimon/core/manifest/manifest_entry.h"
25+
#include "paimon/core/snapshot.h"
26+
#include "paimon/result.h"
27+
#include "paimon/status.h"
28+
29+
namespace paimon {
30+
31+
class CommitChangesProvider {
32+
public:
33+
virtual ~CommitChangesProvider() = default;
34+
35+
virtual Status Provide(const std::optional<Snapshot>& latest_snapshot,
36+
std::vector<ManifestEntry>* delta_files,
37+
std::vector<ManifestEntry>* changelog_files,
38+
std::vector<IndexManifestEntry>* index_entries) const = 0;
39+
};
40+
41+
class StaticCommitChangesProvider final : public CommitChangesProvider {
42+
public:
43+
StaticCommitChangesProvider(const std::vector<ManifestEntry>& delta_files,
44+
const std::vector<ManifestEntry>& changelog_files,
45+
const std::vector<IndexManifestEntry>& index_entries);
46+
47+
Status Provide(const std::optional<Snapshot>& latest_snapshot,
48+
std::vector<ManifestEntry>* delta_files,
49+
std::vector<ManifestEntry>* changelog_files,
50+
std::vector<IndexManifestEntry>* index_entries) const override;
51+
52+
private:
53+
const std::vector<ManifestEntry>& delta_files_;
54+
const std::vector<ManifestEntry>& changelog_files_;
55+
const std::vector<IndexManifestEntry>& index_entries_;
56+
};
57+
58+
} // namespace paimon

0 commit comments

Comments
 (0)