c22ac38ea2
Summary: - added functionality to `GraphDbAccessor` for cardinality estimates - changed all `GraphDbAccessor::Count...` functions to return `int64_t` - added the need functionality into `LabelPropertyIndex` - modified `SkipList::position_and_count` to accept a custom `equals` function. Equality could not be implemented using only the custom `less` because it compares a templated `TItem` with skiplist element type `T`, and is therefore not symetrical. Reviewers: teon.banek, buda, mislav.bradac Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D521
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
|
|
namespace utils {
|
|
|
|
/**
|
|
* Determines whether the value of bound expression should be included or
|
|
* excluded.
|
|
*/
|
|
enum class BoundType { INCLUSIVE, EXCLUSIVE };
|
|
|
|
/** Defines a bounding value for a range. */
|
|
template <typename TValue>
|
|
class Bound {
|
|
public:
|
|
using Type = BoundType;
|
|
|
|
Bound(TValue value, Type type) : value_(value), type_(type) {}
|
|
|
|
Bound(const Bound &other) = default;
|
|
Bound(Bound &&other) = default;
|
|
|
|
Bound &operator=(const Bound &other) = default;
|
|
Bound &operator=(Bound &&other) = default;
|
|
|
|
/** Value for the bound. */
|
|
const auto &value() const { return value_; }
|
|
/** Whether the bound is inclusive or exclusive. */
|
|
auto type() const { return type_; }
|
|
auto IsInclusive() const { return type_ == BoundType::INCLUSIVE; }
|
|
auto IsExclusive() const { return type_ == BoundType::EXCLUSIVE; }
|
|
|
|
private:
|
|
TValue value_;
|
|
Type type_;
|
|
};
|
|
|
|
/**
|
|
* Creates an inclusive @c Bound.
|
|
*
|
|
* @param value - Bound value
|
|
* @tparam TValue - value type
|
|
*/
|
|
template <typename TValue>
|
|
Bound<TValue> MakeBoundInclusive(TValue value) {
|
|
return Bound<TValue>(value, BoundType::INCLUSIVE);
|
|
};
|
|
|
|
/**
|
|
* Creates an exclusive @c Bound.
|
|
*
|
|
* @param value - Bound value
|
|
* @tparam TValue - value type
|
|
*/
|
|
template <typename TValue>
|
|
Bound<TValue> MakeBoundExclusive(TValue value) {
|
|
return Bound<TValue>(value, BoundType::EXCLUSIVE);
|
|
};
|
|
|
|
} // namespace utils
|