quickstep-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zuyu <...@git.apache.org>
Subject [GitHub] incubator-quickstep pull request #309: Add ProbabilityStore class
Date Mon, 09 Oct 2017 18:23:51 GMT
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/309#discussion_r143522173
  
    --- Diff: query_execution/ProbabilityStore.hpp ---
    @@ -0,0 +1,274 @@
    +/**
    + * 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_PROBABILITY_STORE_HPP_
    +#define QUICKSTEP_QUERY_EXECUTION_PROBABILITY_STORE_HPP_
    +
    +#include <algorithm>
    +#include <cstddef>
    +#include <random>
    +#include <unordered_map>
    +#include <vector>
    +
    +#include "utility/Macros.hpp"
    +
    +#include "glog/logging.h"
    +
    +namespace quickstep {
    +
    +/**
    + * @brief A class that stores the probabilities of objects. We use an integer field
    + *        called "key" to identify each object.
    + *        A probability is expressed as a fraction. All the objects share a common denominator.
    + **/
    +class ProbabilityStore {
    + public:
    +  /**
    +   * @brief Constructor.
    +   **/
    +  ProbabilityStore()
    +      : common_denominator_(1.0) {}
    +
    +  /**
    +   * @brief Get the number of objects in the store.
    +   **/
    +  inline const std::size_t getNumObjects() const {
    +    DCHECK_EQ(individual_probabilities_.size(), cumulative_probabilities_.size());
    --- End diff --
    
    Does it follow the rule that the left side is the checked variable, and the right is the
expected one?


---

Mime
View raw message