feat: add executor future helpers and metrics utilities by lucasfang · Pull Request #47 · apache/paimon-cpp · GitHub
Skip to content

feat: add executor future helpers and metrics utilities - #47

Merged
leaves12138 merged 2 commits into
apache:mainfrom
lucasfang:migrate
Jun 4, 2026
Merged

feat: add executor future helpers and metrics utilities#47
leaves12138 merged 2 commits into
apache:mainfrom
lucasfang:migrate

Conversation

@lucasfang

@lucasfang lucasfang commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Linked issue: No linked issue

This change adds shared runtime utility implementations and test coverage under src/paimon/common.

Included changes:

  • Executor Future helpers:
    • Adds src/paimon/common/executor/future.h for submitting callables through an Executor and returning std::future results.
    • Adds helpers to collect typed future results and wait for void futures.
    • Adds DefaultExecutorTest coverage for async submission, result collection, exception propagation, immediate shutdown, and ignored submissions after shutdown.
  • Factory and IO hook tests:
    • Adds FactoryCreatorTest coverage for factory creator registration and lookup behavior.
    • Adds IOHookTest coverage for IO hook registration behavior.
  • Metrics utilities:
    • Adds the public metrics interface in include/paimon/metrics.h.
    • Adds histogram and histogram windowing implementations.
    • Adds metrics implementation helpers.
    • Adds unit coverage for histogram, histogram windowing, and metrics implementation behavior.

Tests

Not run. Local compile, CMake, and gtest environment checks are not part of this PR description.

Test coverage included in this change:

  • DefaultExecutorTest
  • FactoryCreatorTest
  • IOHookTest
  • HistogramTest
  • HistogramWindowingTest
  • MetricsImplTest

API and Format

This change adds the public metrics API in include/paimon/metrics.h.

No storage format or protocol changes.

Documentation

No documentation changes required.

Generative AI tooling

Generated-by: Aone Copilot

Copilot AI review requested due to automatic review settings June 4, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a C++ metrics implementation (counters/gauges/windowed histograms) with JSON serialization, plus a small async Via() helper and associated unit tests.

Changes:

  • Introduce MetricsImpl with counter/gauge/histogram support, merge/overwrite, and ToString() JSON output.
  • Add HistogramImpl and HistogramWindowingImpl (windowed aggregation) with cloning/merging behavior.
  • Add new unit tests for metrics, histograms, executors, IO hook, and factory creator.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/paimon/common/metrics/metrics_impl.h Declares MetricsImpl API for counters/gauges/histograms and merge/overwrite.
src/paimon/common/metrics/metrics_impl.cpp Implements metrics storage, histogram handling, and JSON serialization.
src/paimon/common/metrics/metrics_impl_test.cpp Tests counters/gauges merge/overwrite and ToString() behavior.
src/paimon/common/metrics/histogram.h Adds internal histogram interfaces and HistogramImpl API.
src/paimon/common/metrics/histogram.cpp Implements histogram bucket mapping, aggregation, percentiles, clone/merge.
src/paimon/common/metrics/histogram_test.cpp Tests histogram stats, merge/clone, and metrics histogram integration.
src/paimon/common/metrics/histogram_windowing.h Declares time-windowed histogram implementation.
src/paimon/common/metrics/histogram_windowing.cpp Implements window advancement/reset, merge/clone for windowed histograms.
src/paimon/common/metrics/histogram_windowing_test.cpp Tests windowed histogram advancement/reset/merge/clone behavior.
src/paimon/common/executor/future.h Adds Via(), CollectAll(), and Wait() helpers for async execution.
src/paimon/common/executor/default_executor_test.cpp Tests executor behavior and the new future helpers.
src/paimon/common/factories/io_hook_test.cpp Adds tests for IOHook singleton and modes.
src/paimon/common/factories/factory_creator_test.cpp Adds tests for factory registration/creation and registered types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +87 to +88
double min_ = std::numeric_limits<double>::infinity();
double max_ = 0;
Comment on lines +193 to +194
double upper = (i < limits.size()) ? limits[i] : s.max;
double lower = (i == 0) ? std::min(s.min, 0.0) : limits[i - 1];
Comment on lines +50 to +53
void TearDown() override {
factory_creator_->~FactoryCreator();
new (factory_creator_) FactoryCreator();
}
Comment on lines +26 to +30
uint64_t HistogramWindowingImpl::NowMicros() {
return std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
}
Comment on lines +216 to +217
doc.AddMember(rapidjson::Value(kv.first, allocator), rapidjson::Value(kv.second),
allocator);
Comment on lines +224 to +225
doc.AddMember(rapidjson::Value(name + ".count", allocator), rapidjson::Value(s.count),
allocator);

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed PR #47 after the public metrics interface was added. I did not find any remaining blockers. Approved.

@leaves12138
leaves12138 merged commit 2c6dbe1 into apache:main Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants