Skip to content

Commit b7d8f52

Browse files
authored
fix: fix compile and format (#143)
1 parent e0cf3f5 commit b7d8f52

195 files changed

Lines changed: 34282 additions & 238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,12 @@ function(paimon_enforce_patched_dependency_policy)
421421
elseif(_arrow_source STREQUAL "AUTO")
422422
message(STATUS "Forcing Arrow_SOURCE to BUNDLED because paimon-cpp requires "
423423
"project-specific Arrow patches")
424-
set(Arrow_SOURCE "BUNDLED"
424+
set(Arrow_SOURCE
425+
"BUNDLED"
425426
CACHE STRING "Dependency source for Arrow" FORCE)
426-
set(Arrow_SOURCE "BUNDLED" PARENT_SCOPE)
427+
set(Arrow_SOURCE
428+
"BUNDLED"
429+
PARENT_SCOPE)
427430
endif()
428431

429432
if(PAIMON_ENABLE_ORC)
@@ -435,9 +438,12 @@ function(paimon_enforce_patched_dependency_policy)
435438
elseif(_orc_source STREQUAL "AUTO")
436439
message(STATUS "Forcing ORC_SOURCE to BUNDLED because paimon-cpp requires "
437440
"project-specific ORC patches")
438-
set(ORC_SOURCE "BUNDLED"
441+
set(ORC_SOURCE
442+
"BUNDLED"
439443
CACHE STRING "Dependency source for ORC" FORCE)
440-
set(ORC_SOURCE "BUNDLED" PARENT_SCOPE)
444+
set(ORC_SOURCE
445+
"BUNDLED"
446+
PARENT_SCOPE)
441447
endif()
442448
endif()
443449
endfunction()

include/paimon/file_store_write.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
2019
#pragma once
2120

2221
#include <cstdint>

include/paimon/metrics.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,68 @@ struct PAIMON_EXPORT HistogramStats {
4646
};
4747

4848
/// Abstract interface for collecting and managing performance metrics in Paimon operations.
49+
///
50+
/// This class provides a unified interface for tracking various performance metrics
51+
/// such as counters for read/write operations, I/O statistics, and other operational
52+
/// measurements. It serves as the base class for concrete implementations like `MetricsImpl`.
4953
class PAIMON_EXPORT Metrics {
5054
public:
5155
virtual ~Metrics() = default;
5256

5357
/// Set the value of a specific counter metric.
58+
/// @param metric_name The name/key of the metric to set.
59+
/// @param metric_value The value to set for this metric.
5460
virtual void SetCounter(const std::string& metric_name, uint64_t metric_value) = 0;
5561

5662
/// Get the current value of a specific counter metric.
63+
/// @param metric_name The name/key of the metric to retrieve.
64+
/// @return The current value of the metric, or `Status::KeyError` if the metric doesn't exist.
5765
virtual Result<uint64_t> GetCounter(const std::string& metric_name) const = 0;
5866

5967
/// Get all counter metrics as a map.
68+
/// @return A map containing all metric names and their current values.
6069
virtual std::map<std::string, uint64_t> GetAllCounters() const = 0;
6170

6271
/// Add a sample to a histogram metric.
72+
/// @param metric_name The name/key of the histogram metric.
73+
/// @param value The observed value.
6374
virtual void ObserveHistogram(const std::string& metric_name, double value) = 0;
6475

6576
/// Get histogram statistics snapshot.
77+
/// @return `Status::KeyError` if the histogram doesn't exist.
6678
virtual Result<HistogramStats> GetHistogramStats(const std::string& metric_name) const = 0;
6779

6880
/// Get all histogram statistics snapshots.
6981
virtual std::map<std::string, HistogramStats> GetAllHistogramStats() const = 0;
7082

71-
/// Set the value of a specific gauge metric.
83+
/// Set the value of a specific gauge metric (current state metric).
84+
/// @param metric_name The name/key of the gauge metric to set.
85+
/// @param metric_value The value to set for this gauge metric (double, not just integer).
7286
virtual void SetGauge(const std::string& metric_name, double metric_value) = 0;
7387

74-
/// Get the current value of a specific gauge metric.
88+
/// Get the current value of a specific gauge metric (current state metric).
89+
/// @param metric_name The name/key of the gauge metric to retrieve.
90+
/// @return The current value of the gauge metric, or `Status::KeyError` if the metric doesn't
91+
/// exist.
7592
virtual Result<double> GetGauge(const std::string& metric_name) const = 0;
7693

7794
/// Get all gauge metrics as a map.
95+
/// @return A map containing all gauge metric names and their current values.
7896
virtual std::map<std::string, double> GetAllGauges() const = 0;
7997

8098
/// Merge metrics from another Metrics instance into this one.
99+
///
100+
/// For metrics that exist in both instances, the values are added together.
101+
/// For metrics that only exist in the other instance, they are copied over.
102+
/// This operation is useful for aggregating metrics from multiple sources.
103+
///
104+
/// @param other The other Metrics instance to merge from. If `other` is nullptr or same as
105+
/// this, no operation is performed.
81106
virtual void Merge(const std::shared_ptr<Metrics>& other) = 0;
82107

83108
/// Convert all metrics to a JSON string representation.
109+
/// @return A JSON string containing all metric names and values, e.g.,
110+
/// `{"metric1":100,"metric2":200}`.
84111
virtual std::string ToString() const = 0;
85112
};
86113

include/paimon/write_context.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* limitations under the License.
1717
*/
1818

19-
2019
#pragma once
2120

2221
#include <cstdint>

src/paimon/common/data/binary_array_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ TEST(BinaryArrayTest, TestFromLongArray) {
335335
R"([[123, null], [789], [12345], [12]])")
336336
.ValueOrDie();
337337
auto list_array = arrow::internal::checked_pointer_cast<arrow::ListArray>(f1);
338-
auto array = ColumnarArray(list_array->values(), pool, /*offset=*/0, 2);
338+
auto array = ColumnarArray(list_array->values().get(), pool, /*offset=*/0, 2);
339339

340340
BinaryArray ret = BinaryArray::FromLongArray(&array, pool.get());
341341

@@ -366,7 +366,7 @@ TEST(BinaryArrayTest, TestFromAllNullLongArray) {
366366
R"([[null, null], [789], [12345], [12]])")
367367
.ValueOrDie();
368368
auto list_array = arrow::internal::checked_pointer_cast<arrow::ListArray>(f1);
369-
auto array = ColumnarArray(list_array->values(), pool, /*offset=*/0, 2);
369+
auto array = ColumnarArray(list_array->values().get(), pool, /*offset=*/0, 2);
370370

371371
BinaryArray ret = BinaryArray::FromLongArray(&array, pool.get());
372372

src/paimon/common/data/binary_row.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
namespace paimon {
3333
const int64_t BinaryRow::FIRST_BYTE_ZERO =
3434
(SystemByteOrder() == ByteOrder::PAIMON_LITTLE_ENDIAN)
35-
? static_cast<int64_t>(~0xFFULL)
36-
: static_cast<int64_t>(~(0xFFULL << 56));
35+
? static_cast<int64_t>(~static_cast<uint64_t>(0xFF))
36+
: static_cast<int64_t>(~(static_cast<uint64_t>(0xFF) << 56));
3737

3838
const BinaryRow& BinaryRow::EmptyRow() {
3939
static const BinaryRow empty_row = GetEmptyRow();

src/paimon/common/executor/future.h

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,42 @@
3131

3232
namespace paimon {
3333

34-
/// Submits a function to be executed asynchronously on a given executor and returns a future.
34+
/// Submits a function to be executed asynchronously on a given executor and returns a
35+
/// future.
3536
///
36-
/// This function wraps the provided callable and submits it to the provided executor. The function
37-
/// captures the result using a std::promise, which is used to fulfill the returned std::future. If
38-
/// the callable throws an exception, the exception is captured and set in the promise.
37+
/// This function wraps the provided callable (`func`) and submits it to the provided `executor`.
38+
/// The function captures the result of `func` using a `std::promise`, which is used to fulfill
39+
/// the returned `std::future`. If the callable throws an exception, the exception is captured
40+
/// and set in the `promise`.
41+
///
42+
/// @tparam Func The type of the callable function.
43+
/// @param executor The executor to run the function on. Must provide an `Add` method for task
44+
/// submission.
45+
/// @param func The function to execute asynchronously. Can be any callable object.
46+
/// @return std::future<decltype(func())> A future that holds the result of the function
47+
/// execution.
48+
///
49+
/// @note If `func` returns `void`, the returned future is of type `std::future<void>`.
3950
template <typename Func>
40-
auto Via(Executor* executor, Func&& func) -> std::future<std::invoke_result_t<Func>> {
41-
using ResultType = std::invoke_result_t<Func>;
51+
auto Via(Executor* executor, Func&& func) -> std::future<decltype(func())> {
52+
using ResultType = decltype(func());
4253

54+
// Check if func is callable (invocable)
4355
static_assert(std::is_invocable_v<Func>, "func must be callable");
4456

57+
// Check if func is an empty std::function
4558
if constexpr (std::is_constructible_v<std::function<void()>, Func>) {
4659
std::function<void()> test_func = func;
4760
if (!test_func) {
4861
assert(false && "func cannot be an empty std::function");
4962
}
5063
}
5164

65+
// Create a promise to store the result or exception.
5266
auto promise = std::make_shared<std::promise<ResultType>>();
53-
auto future = promise->get_future();
67+
auto future = promise->get_future(); // Retrieve the future associated with the promise.
5468

69+
// Wrap the task and submit it to the executor.
5570
executor->Add([promise, func = std::forward<Func>(func)]() mutable {
5671
try {
5772
if constexpr (std::is_void_v<ResultType>) {
@@ -69,18 +84,34 @@ auto Via(Executor* executor, Func&& func) -> std::future<std::invoke_result_t<Fu
6984
}
7085

7186
/// Collects the results of multiple futures.
87+
///
88+
/// This function waits for all provided futures to complete and collects their results.
89+
/// The results are returned in a `std::vector`, preserving the order of the input futures.
90+
///
91+
/// @tparam T The type of the result stored in the futures.
92+
/// @param futures A container of futures (e.g., std::vector<std::future<T>>).
93+
/// @return std::vector<T> A vector of results corresponding to the input futures.
94+
///
95+
/// @note If `T` is `void`, use Wait function instead.
7296
template <typename T>
7397
std::vector<T> CollectAll(std::vector<std::future<T>>& futures) {
7498
std::vector<T> results;
75-
results.reserve(futures.size());
99+
results.reserve(futures.size()); // Reserve space to avoid reallocation.
76100
for (auto& future : futures) {
77-
results.push_back(future.get());
101+
results.push_back(future.get()); // Wait for each future and collect the result.
78102
}
79103

80104
return results;
81105
}
82106

83-
/// Waits for all futures with void return type to complete.
107+
/// Waits for all futures with `void` return type to complete.
108+
///
109+
/// This function waits for each provided `std::future<void>` to complete.
110+
/// It ensures that all asynchronous operations have finished execution.
111+
///
112+
/// @param futures A container of `std::future<void>` (e.g., `std::vector<std::future<void>>`).
113+
///
114+
/// @note Use this function when dealing with futures that do not return a value.
84115
inline void Wait(std::vector<std::future<void>>& futures) {
85116
for (auto& future : futures) {
86117
if (future.valid()) {

src/paimon/common/sst/sst_file_io_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ TEST_P(SstFileIOTest, TestSimple) {
173173
ASSERT_EQ("looooooooooong-值-15", string15);
174174
}
175175

176-
TEST_P(SstFileIOTest, TestJavaCompatibility) {
176+
TEST_P(SstFileIOTest, DISABLED_TestJavaCompatibility) {
177177
auto param = GetParam();
178178

179179
// key range [1_000_000, 2_000_000], value is equal to the key

0 commit comments

Comments
 (0)