This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 6dfcb12d6 [tablet] clean-up on Tablet::UpdateLastReadTime()
6dfcb12d6 is described below
commit 6dfcb12d65290a484d96ec5adfbc7d84889be380
Author: Alexey Serbin <[email protected]>
AuthorDate: Sat Nov 26 15:47:37 2022 -0800
[tablet] clean-up on Tablet::UpdateLastReadTime()
Tablet::UpdateLastReadTime() was marked 'const' while it wasn't so
semantically, but the comment in the header file was claiming it's
necessary. However, it turned out that's not so as of now, and this
patch reduces the confusion. I also took the liberty to make formatting
changes in the constructor to comply with the C++ code style guide.
This patch doesn't contain any functional changes.
This is a follow-up to ca957fb86736b1e07b18d80fdfa4e41c191e7072.
Change-Id: Iaf204d50bb3ee470790cefae983e6fb7b5a21c98
Reviewed-on: http://gerrit.cloudera.org:8080/19280
Tested-by: Kudu Jenkins
Reviewed-by: Yifan Zhang <[email protected]>
---
src/kudu/tablet/tablet.cc | 36 ++++++++++++++++++------------------
src/kudu/tablet/tablet.h | 6 ++----
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 592c7c868..e60443ff5 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -271,23 +271,23 @@ Tablet::Tablet(scoped_refptr<TabletMetadata> metadata,
shared_ptr<MemTracker> parent_mem_tracker,
MetricRegistry* metric_registry,
scoped_refptr<LogAnchorRegistry> log_anchor_registry)
- : key_schema_(metadata->schema()->CreateKeyProjection()),
- metadata_(std::move(metadata)),
- log_anchor_registry_(std::move(log_anchor_registry)),
- mem_trackers_(tablet_id(), std::move(parent_mem_tracker)),
- next_mrs_id_(0),
- clock_(clock),
- txn_participant_(metadata_),
- rowsets_flush_sem_(1),
- state_(kInitialized),
- last_write_time_(MonoTime::Now()),
- last_read_time_(MonoTime::Now()),
- last_update_workload_stats_time_(MonoTime::Now()),
- last_scans_started_(0),
- last_rows_mutated_(0),
- last_read_score_(0.0),
- last_write_score_(0.0) {
- CHECK(schema()->has_column_ids());
+ : key_schema_(metadata->schema()->CreateKeyProjection()),
+ metadata_(std::move(metadata)),
+ log_anchor_registry_(std::move(log_anchor_registry)),
+ mem_trackers_(tablet_id(), std::move(parent_mem_tracker)),
+ next_mrs_id_(0),
+ clock_(clock),
+ txn_participant_(metadata_),
+ rowsets_flush_sem_(1),
+ state_(kInitialized),
+ last_read_time_(MonoTime::Now()),
+ last_write_time_(last_read_time_),
+ last_update_workload_stats_time_(last_read_time_),
+ last_scans_started_(0),
+ last_rows_mutated_(0),
+ last_read_score_(0.0),
+ last_write_score_(0.0) {
+ CHECK(schema()->has_column_ids());
compaction_policy_.reset(CreateCompactionPolicy());
if (metric_registry) {
@@ -2410,7 +2410,7 @@ uint64_t Tablet::LastReadElapsedSeconds() const {
return static_cast<uint64_t>((MonoTime::Now() -
last_read_time_).ToSeconds());
}
-void Tablet::UpdateLastReadTime() const {
+void Tablet::UpdateLastReadTime() {
std::lock_guard<rw_spinlock> l(last_rw_time_lock_);
last_read_time_ = MonoTime::Now();
}
diff --git a/src/kudu/tablet/tablet.h b/src/kudu/tablet/tablet.h
index 607d5aeba..47ca3b5bc 100644
--- a/src/kudu/tablet/tablet.h
+++ b/src/kudu/tablet/tablet.h
@@ -522,9 +522,7 @@ class Tablet {
std::vector<KeyRange>* ranges);
// Update the last read operation timestamp.
- // NOTE: It's a const function, because we have to call it in Iterator,
where Tablet is a const
- // variable there.
- void UpdateLastReadTime() const;
+ void UpdateLastReadTime();
// Collect and update recent workload statistics for the tablet.
// Return the current workload score of the tablet.
@@ -847,8 +845,8 @@ class Tablet {
// Lock protecting access to 'last_write_time_' and 'last_read_time_'.
mutable rw_spinlock last_rw_time_lock_;
+ MonoTime last_read_time_;
MonoTime last_write_time_;
- mutable MonoTime last_read_time_;
// NOTE: it's important that this is the first member to be destructed. This
// ensures we do not attempt to collect metrics while calling the destructor.