Use CHECK in TypedValueVectorCompare|Equal
Reviewers: mtomic, llugovic Reviewed By: mtomic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2066
This commit is contained in:
parent
e4fd49a530
commit
64a05bc972
@ -4,6 +4,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#include "database/graph_db_accessor.hpp"
|
#include "database/graph_db_accessor.hpp"
|
||||||
#include "query/exceptions.hpp"
|
#include "query/exceptions.hpp"
|
||||||
#include "query/frontend/ast/ast.hpp"
|
#include "query/frontend/ast/ast.hpp"
|
||||||
@ -50,7 +52,7 @@ class TypedValueVectorCompare final {
|
|||||||
const std::vector<TypedValue, TAllocator> &c2) const {
|
const std::vector<TypedValue, TAllocator> &c2) const {
|
||||||
// ordering is invalid if there are more elements in the collections
|
// ordering is invalid if there are more elements in the collections
|
||||||
// then there are in the ordering_ vector
|
// then there are in the ordering_ vector
|
||||||
DCHECK(c1.size() <= ordering_.size() && c2.size() <= ordering_.size())
|
CHECK(c1.size() <= ordering_.size() && c2.size() <= ordering_.size())
|
||||||
<< "Collections contain more elements then there are orderings";
|
<< "Collections contain more elements then there are orderings";
|
||||||
|
|
||||||
auto c1_it = c1.begin();
|
auto c1_it = c1.begin();
|
||||||
|
@ -56,25 +56,19 @@
|
|||||||
|
|
||||||
namespace query::plan {
|
namespace query::plan {
|
||||||
|
|
||||||
bool TypedValueVectorEqual::operator()(
|
|
||||||
const std::vector<TypedValue> &left,
|
|
||||||
const std::vector<TypedValue> &right) const {
|
|
||||||
DCHECK(left.size() == right.size())
|
|
||||||
<< "TypedValueVector comparison should only be done over vectors "
|
|
||||||
"of the same size";
|
|
||||||
return std::equal(left.begin(), left.end(), right.begin(),
|
|
||||||
TypedValue::BoolEqual{});
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TypedValueVectorAllocatorEqual {
|
// Custom equality function for a vector of typed values.
|
||||||
bool operator()(
|
// Used in unordered_maps in Aggregate and Distinct operators.
|
||||||
const std::vector<TypedValue, utils::Allocator<TypedValue>> &left,
|
struct TypedValueVectorEqual {
|
||||||
const std::vector<TypedValue, utils::Allocator<TypedValue>> &right)
|
template <class TAllocator>
|
||||||
const {
|
bool operator()(const std::vector<TypedValue, TAllocator> &left,
|
||||||
return std::equal(left.begin(), left.end(), right.begin(), right.end(),
|
const std::vector<TypedValue, TAllocator> &right) const {
|
||||||
TypedValue::BoolEqual());
|
CHECK(left.size() == right.size())
|
||||||
|
<< "TypedValueVector comparison should only be done over vectors "
|
||||||
|
"of the same size";
|
||||||
|
return std::equal(left.begin(), left.end(), right.begin(),
|
||||||
|
TypedValue::BoolEqual{});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2489,7 +2483,7 @@ class AggregateCursor : public Cursor {
|
|||||||
std::vector<TypedValue, utils::Allocator<TypedValue>>, TypedValue,
|
std::vector<TypedValue, utils::Allocator<TypedValue>>, TypedValue,
|
||||||
TypedValue::Hash>,
|
TypedValue::Hash>,
|
||||||
// custom equality
|
// custom equality
|
||||||
TypedValueVectorAllocatorEqual,
|
TypedValueVectorEqual,
|
||||||
utils::Allocator<
|
utils::Allocator<
|
||||||
std::pair<const std::vector<TypedValue, utils::Allocator<TypedValue>>,
|
std::pair<const std::vector<TypedValue, utils::Allocator<TypedValue>>,
|
||||||
AggregationValue>>>
|
AggregationValue>>>
|
||||||
@ -3242,7 +3236,7 @@ class DistinctCursor : public Cursor {
|
|||||||
utils::FnvCollection<
|
utils::FnvCollection<
|
||||||
std::vector<TypedValue, utils::Allocator<TypedValue>>, TypedValue,
|
std::vector<TypedValue, utils::Allocator<TypedValue>>, TypedValue,
|
||||||
TypedValue::Hash>,
|
TypedValue::Hash>,
|
||||||
TypedValueVectorAllocatorEqual,
|
TypedValueVectorEqual,
|
||||||
utils::Allocator<std::vector<TypedValue, utils::Allocator<TypedValue>>>>
|
utils::Allocator<std::vector<TypedValue, utils::Allocator<TypedValue>>>>
|
||||||
seen_rows_;
|
seen_rows_;
|
||||||
};
|
};
|
||||||
|
@ -1541,17 +1541,6 @@ has been cached will be reconstructed before Pull returns.
|
|||||||
(:serialize (:slk))
|
(:serialize (:slk))
|
||||||
(:clone))
|
(:clone))
|
||||||
|
|
||||||
#>cpp
|
|
||||||
/**
|
|
||||||
* Custom equality function for a vector of typed values.
|
|
||||||
* Used in unordered_maps in Aggregate and Distinct operators.
|
|
||||||
*/
|
|
||||||
struct TypedValueVectorEqual {
|
|
||||||
bool operator()(const std::vector<TypedValue> &left,
|
|
||||||
const std::vector<TypedValue> &right) const;
|
|
||||||
};
|
|
||||||
cpp<#
|
|
||||||
|
|
||||||
(lcp:define-class aggregate (logical-operator)
|
(lcp:define-class aggregate (logical-operator)
|
||||||
((input "std::shared_ptr<LogicalOperator>" :scope :public
|
((input "std::shared_ptr<LogicalOperator>" :scope :public
|
||||||
:slk-save #'slk-save-operator-pointer
|
:slk-save #'slk-save-operator-pointer
|
||||||
|
Loading…
Reference in New Issue
Block a user