From 50bca2343157b232232c906ffe355f159a548356 Mon Sep 17 00:00:00 2001 From: Josh Ventura Date: Wed, 17 Jun 2026 17:48:17 -0700 Subject: [PATCH] refactor(exporter): remove dead MetricFixedString interface method + FixedStringCol class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `MetricFixedString` was added in Feb 2026 (commit 9f89f4) when err_sqlstate was the only column in events_raw of type FixedString(5). It had exactly one caller, exactly one width, and was always going to. PR #99 (merged 2026-06-10) changed err_sqlstate from FixedString(5) to LowCardinality(String) and updated the call site from `exporter->MetricFixedString(5, "err_sqlstate")` to `exporter->TagString("err_sqlstate")`. The interface method became unreferenced. PR #104 (merged 2026-06-04 — before #99) had to reproduce MetricFixedString in clickhouse-c by hand-rolling a `FixedStringCol` class, since clickhouse-c has no built-in FixedString column type unlike clickhouse-cpp. That work was correct when authored — the column was still live — but became orphaned a week later when #99 landed. Nobody noticed. Deletes the now-dead virtual + both impls. The CH-native side loses the 27-line FixedStringCol class entirely; the OTel side loses a 3-line forward to MakeSvCol; the interface loses one virtual declaration. Stats_exporter.cc already doesn't reference it. No behavior change — this was unreachable code. -35 LOC. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/export/clickhouse_exporter.cc | 31 ------------------------------- src/export/exporter_interface.h | 1 - src/export/otel_exporter.cc | 4 ---- 3 files changed, 36 deletions(-) diff --git a/src/export/clickhouse_exporter.cc b/src/export/clickhouse_exporter.cc index cbdb04b..23fe1c6 100644 --- a/src/export/clickhouse_exporter.cc +++ b/src/export/clickhouse_exporter.cc @@ -176,9 +176,6 @@ class ClickHouseExporter : public StatsExporter { shared_ptr> MetricUInt64(string_view name) final { return MakeCol>(name, "UInt64"); } - shared_ptr> MetricFixedString(int len, string_view name) final { - return MakeCol(name, len); - } shared_ptr> RecordInt16(string_view name) final { return MakeCol>(name, "Int16"); @@ -264,34 +261,6 @@ class ClickHouseExporter : public StatsExporter { std::vector offsets_; }; - class FixedStringCol : public Column { - public: - FixedStringCol(ClickHouseExporter* exp, string_view name, int n) - : exp_(exp), - name_(name), - width_(static_cast(n)), - type_name_("FixedString(" + std::to_string(n) + ")") {} - void Append(const string_view& s) final { - const size_t start = data_.size(); - data_.resize(start + width_, '\0'); - std::memcpy(data_.data() + start, s.data(), std::min(s.size(), width_)); - ++rows_; - } - void Crunch() final { exp_->AppendFixed(name_, type_name_.c_str(), data_.data(), rows_); } - void Clear() final { - data_.clear(); - rows_ = 0; - } - - private: - ClickHouseExporter* const exp_; - const std::string name_; - const size_t width_; - const std::string type_name_; - std::vector data_; - size_t rows_ = 0; - }; - template shared_ptr MakeCol(string_view name, Args&&... args) { if (auto it = col_index_.find(name); it != col_index_.end()) { diff --git a/src/export/exporter_interface.h b/src/export/exporter_interface.h index afbc8c9..249e82e 100644 --- a/src/export/exporter_interface.h +++ b/src/export/exporter_interface.h @@ -37,7 +37,6 @@ class StatsExporter { virtual shared_ptr> MetricInt64(string_view name) = 0; virtual shared_ptr> MetricUInt8(string_view name) = 0; virtual shared_ptr> MetricUInt64(string_view name) = 0; - virtual shared_ptr> MetricFixedString(int len, string_view name) = 0; // Records: Data columns you wouldn't want to filter by. virtual shared_ptr> RecordInt16(string_view name) = 0; diff --git a/src/export/otel_exporter.cc b/src/export/otel_exporter.cc index ad9228e..3c7f8d6 100644 --- a/src/export/otel_exporter.cc +++ b/src/export/otel_exporter.cc @@ -170,10 +170,6 @@ class OTelExporter : public StatsExporter { shared_ptr> MetricUInt64(string_view name) final { return MakeIntCol(name); } - shared_ptr> MetricFixedString(int /*len*/, string_view name) final { - return MakeSvCol(name); - } - shared_ptr> RecordInt16(string_view name) final { return MakeIntCol(name); }