Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/302#discussion_r141769721 --- Diff: query_execution/ExecutionStats.hpp --- @@ -0,0 +1,210 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + **/ + +#ifndef QUICKSTEP_QUERY_EXECUTION_EXECUTION_STATS_HPP_ +#define QUICKSTEP_QUERY_EXECUTION_EXECUTION_STATS_HPP_ + +#include <algorithm> +#include <cstddef> +#include <cstdint> +#include <deque> +#include <memory> +#include <unordered_map> +#include <utility> + +#include "utility/Macros.hpp" + +#include "glog/logging.h" + +namespace quickstep { + +/** \addtogroup QueryExecution + * @{ + */ + +/** + * @brief Record the execution stats of a query. + **/ +class ExecutionStats { + public: + /** + * @brief Constructor + * + * @param max_entries The maximum number of entries we remember for each + * operator. + **/ + explicit ExecutionStats(const std::size_t max_entries) + : max_entries_(max_entries) {} + + /** + * @brief Get the number of active operators in stats. + **/ + const std::size_t getNumActiveOperators() const { + return active_operators_.size(); + } + + /** + * @brief Check if there are stats present for at least one active operator. + **/ + inline bool hasStats() const { + for (auto it = active_operators_.begin(); it != active_operators_.end(); ++it) { + if (it->second->hasStatsForOperator()) { + return true; + } + } + return false; + } + + /** + * @brief Get the current stats for the query. + * + * @return A pair - 1st element is total time, 2nd element is total number of + * WorkOrders for the whole query. + **/ + std::pair<std::uint64_t, std::uint64_t> getCurrentStatsForQuery() const { --- End diff -- We may typedef `std::pair<std::uint64_t, std::uint64_t>`.
---