//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2017 ArangoDB GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Jan Steemann //////////////////////////////////////////////////////////////////////////////// #ifndef ARANGOD_AQL_OPTIMIZER_RULES_FEATURE_H #define ARANGOD_AQL_OPTIMIZER_RULES_FEATURE_H 1 #include #include "ApplicationFeatures/ApplicationFeature.h" #include "Aql/OptimizerRule.h" namespace arangodb { namespace aql { class OptimizerRulesFeature final : public application_features::ApplicationFeature { friend class Optimizer; public: explicit OptimizerRulesFeature(application_features::ApplicationServer& server); void prepare() override final; void unprepare() override final; /// @brief translate a list of rule ids into rule name static std::vector translateRules(std::vector const&); /// @brief translate a single rule static char const* translateRule(int rule); /// @brief look up the ids of all disabled rules static std::unordered_set getDisabledRuleIds(std::vector const& names); /// @brief register a rule static void registerRule(std::string const& name, RuleFunction func, OptimizerRule::RuleLevel level, std::underlying_type::type flags); private: void addRules(); void addStorageEngineRules(); static void disableRule(std::string const& name, std::unordered_set& disabled); static void enableRule(std::string const& name, std::unordered_set& disabled); /// @brief the rules database static std::map _rules; /// @brief map to look up rule id by name static std::unordered_map> _ruleLookup; }; } // namespace aql } // namespace arangodb #endif