abstract_replication_strategy.hh: de-virtualize natural_endpoints_depend_on_token

We are going to use this function in vnode_erm::get_natural_endpoints,
so for efficiency it's better to have fewer virtual calls.
This commit is contained in:
Petr Gusev
2023-05-20 20:04:35 +04:00
parent e0bc98a217
commit 99ff1fefe5
5 changed files with 8 additions and 7 deletions

View File

@@ -67,6 +67,7 @@ protected:
replication_strategy_type _my_type;
bool _per_table = false;
bool _uses_tablets = false;
bool _natural_endpoints_depend_on_token = true;
template <typename... Args>
void err(const char* fmt, Args&&... args) const {
@@ -92,7 +93,7 @@ public:
// Evaluates to true iff calculate_natural_endpoints
// returns different results for different tokens.
virtual bool natural_endpoints_depend_on_token() const noexcept { return true; }
bool natural_endpoints_depend_on_token() const noexcept { return _natural_endpoints_depend_on_token; }
// The returned vector has size O(number of normal token owners), which is O(number of nodes in the cluster).
// Note: it is not guaranteed that the function will actually yield. If the complexity of a particular implementation

View File

@@ -17,7 +17,9 @@
namespace locator {
everywhere_replication_strategy::everywhere_replication_strategy(const replication_strategy_config_options& config_options) :
abstract_replication_strategy(config_options, replication_strategy_type::everywhere_topology) {}
abstract_replication_strategy(config_options, replication_strategy_type::everywhere_topology) {
_natural_endpoints_depend_on_token = false;
}
future<endpoint_set> everywhere_replication_strategy::calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const {
auto eps = tm.get_all_endpoints();

View File

@@ -18,8 +18,6 @@ class everywhere_replication_strategy : public abstract_replication_strategy {
public:
everywhere_replication_strategy(const replication_strategy_config_options& config_options);
virtual bool natural_endpoints_depend_on_token() const noexcept override { return false; }
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
virtual void validate_options(const gms::feature_service&) const override { /* noop */ }

View File

@@ -15,7 +15,9 @@
namespace locator {
local_strategy::local_strategy(const replication_strategy_config_options& config_options) :
abstract_replication_strategy(config_options, replication_strategy_type::local) {}
abstract_replication_strategy(config_options, replication_strategy_type::local) {
_natural_endpoints_depend_on_token = false;
}
future<endpoint_set> local_strategy::calculate_natural_endpoints(const token& t, const token_metadata& tm) const {
return make_ready_future<endpoint_set>(endpoint_set({utils::fb_utilities::get_broadcast_address()}));

View File

@@ -27,8 +27,6 @@ public:
virtual ~local_strategy() {};
virtual size_t get_replication_factor(const token_metadata&) const override;
virtual bool natural_endpoints_depend_on_token() const noexcept override { return false; }
virtual future<endpoint_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
virtual void validate_options(const gms::feature_service&) const override;