diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-27 11:27:02 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-27 11:27:02 +0000 |
commit | 0a0670c449c7da08727e767c2000a08f1ec15563 (patch) | |
tree | 02ab389675a670693f164ddff6147aab107fcfae /searchcommon | |
parent | 88ac24cb3aa5602e3755acb612c4c0fefef17d55 (diff) |
Refactor parameters for predicate attributes.
Diffstat (limited to 'searchcommon')
4 files changed, 76 insertions, 24 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/config.cpp b/searchcommon/src/vespa/searchcommon/attribute/config.cpp index 4d1cd540033..e7a4c28b27a 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/config.cpp +++ b/searchcommon/src/vespa/searchcommon/attribute/config.cpp @@ -18,10 +18,7 @@ Config::Config() : _fastAccess(false), _growStrategy(), _compactionStrategy(), - _arity(8), - _lower_bound(LLONG_MIN), - _upper_bound(LLONG_MAX), - _dense_posting_list_threshold(0.4), + _predicateParams(), _tensorType(vespalib::eval::ValueType::error_type()) { } @@ -40,10 +37,7 @@ Config::Config(BasicType bt, _fastAccess(false), _growStrategy(), _compactionStrategy(), - _arity(8), - _lower_bound(LLONG_MIN), - _upper_bound(LLONG_MAX), - _dense_posting_list_threshold(0.4), + _predicateParams(), _tensorType(vespalib::eval::ValueType::error_type()) { } diff --git a/searchcommon/src/vespa/searchcommon/attribute/config.h b/searchcommon/src/vespa/searchcommon/attribute/config.h index 7a5919620bf..be2a1d2777d 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/config.h +++ b/searchcommon/src/vespa/searchcommon/attribute/config.h @@ -7,6 +7,7 @@ #include <vespa/searchcommon/common/growstrategy.h> #include <vespa/searchcommon/common/compaction_strategy.h> #include <vespa/eval/eval/value_type.h> +#include "predicate_params.h" namespace search { namespace attribute { @@ -25,10 +26,7 @@ public: CollectionType collectionType() const { return _type; } bool fastSearch() const { return _fastSearch; } bool huge() const { return _huge; } - uint32_t arity() const { return _arity; } - int64_t lower_bound() const { return _lower_bound; } - int64_t upper_bound() const { return _upper_bound; } - double dense_posting_list_threshold() const { return _dense_posting_list_threshold; } + const PredicateParams &predicateParams() const { return _predicateParams; } vespalib::eval::ValueType tensorType() const { return _tensorType; } /** @@ -67,10 +65,7 @@ public: const CompactionStrategy &getCompactionStrategy() const { return _compactionStrategy; } void setHuge(bool v) { _huge = v; } void setFastSearch(bool v) { _fastSearch = v; } - void setArity(uint32_t v) { _arity = v; } - void setBounds(int64_t lower, int64_t upper) { _lower_bound = lower; - _upper_bound = upper; } - void setDensePostingListThreshold(double v) { _dense_posting_list_threshold = v; } + void setPredicateParams(const PredicateParams &v) { _predicateParams = v; } void setTensorType(const vespalib::eval::ValueType &tensorType_in) { _tensorType = tensorType_in; } @@ -124,10 +119,7 @@ public: _fastAccess == b._fastAccess && _growStrategy == b._growStrategy && _compactionStrategy == b._compactionStrategy && - _arity == b._arity && - _lower_bound == b._lower_bound && - _upper_bound == b._upper_bound && - _dense_posting_list_threshold == b._dense_posting_list_threshold && + _predicateParams == b._predicateParams && (_basicType.type() != BasicType::Type::TENSOR || _tensorType == b._tensorType); } @@ -143,10 +135,7 @@ private: bool _fastAccess; GrowStrategy _growStrategy; CompactionStrategy _compactionStrategy; - uint32_t _arity; - int64_t _lower_bound; - int64_t _upper_bound; - double _dense_posting_list_threshold; + PredicateParams _predicateParams; vespalib::eval::ValueType _tensorType; }; } // namespace attribute diff --git a/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h b/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h new file mode 100644 index 00000000000..1aed2dad72c --- /dev/null +++ b/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h @@ -0,0 +1,37 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace search { +namespace attribute { + +/* + * Persistent parameters for predicate attributes. + */ +class PersistentPredicateParams { + uint32_t _arity; + int64_t _lower_bound; + int64_t _upper_bound; + +public: + PersistentPredicateParams() + : _arity(8), + _lower_bound(std::numeric_limits<int64_t>::min()), + _upper_bound(std::numeric_limits<int64_t>::max()) + { + } + uint32_t arity() const { return _arity; } + int64_t lower_bound() const { return _lower_bound; } + int64_t upper_bound() const { return _upper_bound; } + void setArity(uint32_t v) { _arity = v; } + void setBounds(int64_t lower, int64_t upper) { _lower_bound = lower; _upper_bound = upper; } + + bool operator==(const PersistentPredicateParams &rhs) const { + return ((_arity == rhs._arity) && + (_lower_bound == rhs._lower_bound) && + (_upper_bound == rhs._upper_bound)); + } +}; + +} // namespace attribute +} // namespace search diff --git a/searchcommon/src/vespa/searchcommon/attribute/predicate_params.h b/searchcommon/src/vespa/searchcommon/attribute/predicate_params.h new file mode 100644 index 00000000000..8e8e0605b17 --- /dev/null +++ b/searchcommon/src/vespa/searchcommon/attribute/predicate_params.h @@ -0,0 +1,32 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "persistent_predicate_params.h" + +namespace search { +namespace attribute { + +/* + * Parameters for predicate attributes. + */ +class PredicateParams : public PersistentPredicateParams +{ + double _dense_posting_list_threshold; +public: + PredicateParams() + : PersistentPredicateParams(), + _dense_posting_list_threshold(0.4) + { + } + + double dense_posting_list_threshold() const { return _dense_posting_list_threshold; } + void setDensePostingListThreshold(double v) { _dense_posting_list_threshold = v; } + bool operator==(const PredicateParams &rhs) const { + return (PersistentPredicateParams::operator==(rhs) && + (_dense_posting_list_threshold == rhs._dense_posting_list_threshold)); + } +}; + +} // namespace attribute +} // namespace search |