// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include #include namespace search::query { /** * Represents a predicate query, with features and range features. */ class PredicateQueryTerm { static const uint64_t ALL_SUB_QUERIES = 0xffffffffffffffffULL; template class Entry { vespalib::string _key; ValueType _value; uint64_t _sub_query_bitmap; public: Entry(vespalib::stringref key, const ValueType &value, uint64_t sub_query_bitmap = ALL_SUB_QUERIES) noexcept : _key(key), _value(value), _sub_query_bitmap(sub_query_bitmap) {} const vespalib::string & getKey() const { return _key; } const ValueType & getValue() const { return _value; } uint64_t getSubQueryBitmap() const { return _sub_query_bitmap; } bool operator==(const Entry &other) const { return _key == other._key && _value == other._value && _sub_query_bitmap == other._sub_query_bitmap; } }; std::vector> _features; std::vector> _range_features; public: using UP = std::unique_ptr; PredicateQueryTerm() noexcept : _features(), _range_features() {} void addFeature(vespalib::stringref key, vespalib::stringref value, uint64_t sub_query_bitmask = ALL_SUB_QUERIES) { _features.emplace_back(key, value, sub_query_bitmask); } void addRangeFeature(vespalib::stringref key, uint64_t value, uint64_t sub_query_bitmask = ALL_SUB_QUERIES) { _range_features.emplace_back(key, value, sub_query_bitmask); } const std::vector> &getFeatures() const { return _features; } const std::vector> &getRangeFeatures() const { return _range_features; } bool operator==(const PredicateQueryTerm &other) const { return _features == other._features && _range_features == other._range_features; } }; }