diff options
-rw-r--r-- | searchlib/src/vespa/searchlib/fef/featureexecutor.h | 4 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/fef/rank_program.cpp | 8 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/fef/rank_program.h | 17 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/array.h | 1 |
4 files changed, 16 insertions, 14 deletions
diff --git a/searchlib/src/vespa/searchlib/fef/featureexecutor.h b/searchlib/src/vespa/searchlib/fef/featureexecutor.h index 1b9e219ccaa..f7645675112 100644 --- a/searchlib/src/vespa/searchlib/fef/featureexecutor.h +++ b/searchlib/src/vespa/searchlib/fef/featureexecutor.h @@ -26,7 +26,7 @@ public: class Inputs { vespalib::ConstArrayRef<const NumberOrObject *> _inputs; public: - Inputs() : _inputs(nullptr, 0) {} + Inputs() : _inputs() {} void bind(vespalib::ConstArrayRef<const NumberOrObject *> inputs) { _inputs = inputs; } feature_t get_number(size_t idx) const { return _inputs[idx]->as_number; @@ -43,7 +43,7 @@ public: class Outputs { vespalib::ArrayRef<NumberOrObject> _outputs; public: - Outputs() : _outputs(nullptr, 0) {} + Outputs() : _outputs() {} void bind(vespalib::ArrayRef<NumberOrObject> outputs) { _outputs = outputs; } void set_number(size_t idx, feature_t value) { _outputs[idx].as_number = value; diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.cpp b/searchlib/src/vespa/searchlib/fef/rank_program.cpp index 5c1c3a74a6d..9860a0972cf 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.cpp +++ b/searchlib/src/vespa/searchlib/fef/rank_program.cpp @@ -105,6 +105,7 @@ RankProgram::add_unboxing_executors(vespalib::ArrayRef<NumberOrObject> features, void RankProgram::compile() { + std::vector<FeatureExecutor *> program; std::set<const NumberOrObject *> is_calculated; for (size_t i = 0; i < _executors.size(); ++i) { FeatureExecutor &executor = *_executors[i]; @@ -120,9 +121,10 @@ RankProgram::compile() is_calculated.insert(outputs.get_raw(out_idx)); } } else { - _program.push_back(&executor); + program.push_back(&executor); } } + _program = _stash.copy_array<FeatureExecutor *>(program); } FeatureResolver @@ -149,8 +151,9 @@ RankProgram::resolve(const BlueprintResolver::FeatureMap &features, bool unbox_s RankProgram::RankProgram(BlueprintResolver::SP resolver) : _resolver(resolver), - _program(), + _match_data(), _stash(), + _program(), _executors(), _unboxed_seeds() { @@ -171,7 +174,6 @@ RankProgram::setup(const MatchDataLayout &mdl_in, size_t total_features = count_features(); vespalib::ArrayRef<NumberOrObject> features = _stash.create_array<NumberOrObject>(total_features); const auto &specs = _resolver->getExecutorSpecs(); - _executors.reserve(specs.size()); for (uint32_t i = 0; i < specs.size(); ++i) { size_t num_inputs = specs[i].inputs.size(); vespalib::ArrayRef<const NumberOrObject *> inputs = _stash.create_array<const NumberOrObject *>(num_inputs); diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.h b/searchlib/src/vespa/searchlib/fef/rank_program.h index 4e267e74c1c..029f021762f 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.h +++ b/searchlib/src/vespa/searchlib/fef/rank_program.h @@ -30,12 +30,12 @@ private: using MappedValues = std::map<const NumberOrObject *, const NumberOrObject *>; - BlueprintResolver::SP _resolver; - std::vector<FeatureExecutor *> _program; - MatchData::UP _match_data; - vespalib::Stash _stash; - std::vector<FeatureExecutor *> _executors; - MappedValues _unboxed_seeds; + BlueprintResolver::SP _resolver; + MatchData::UP _match_data; + vespalib::Stash _stash; + vespalib::ArrayRef<FeatureExecutor *> _program; + std::vector<FeatureExecutor *> _executors; + MappedValues _unboxed_seeds; size_t count_features() const; @@ -68,9 +68,8 @@ public: /** * Set up this rank program by creating the needed feature * executors and wiring them together. This function will also - * create the MatchData to be used for iterator unpacking and - * feature calculation as well as pre-calculating all constant - * features. + * create the MatchData to be used for iterator unpacking as well + * as pre-calculating all constant features. **/ void setup(const MatchDataLayout &mdl, const IQueryEnvironment &queryEnv, diff --git a/vespalib/src/vespa/vespalib/util/array.h b/vespalib/src/vespa/vespalib/util/array.h index 4baee42a329..4016a1dbf3c 100644 --- a/vespalib/src/vespa/vespalib/util/array.h +++ b/vespalib/src/vespa/vespalib/util/array.h @@ -25,6 +25,7 @@ public: ArrayRef(T * v, size_t sz) : _v(v), _sz(sz) { } ArrayRef(std::vector<T> & v) : _v(&v[0]), _sz(v.size()) { } inline ArrayRef(Array<T> &v); + ArrayRef() : _v(nullptr), _sz(0) {} T & operator [] (size_t i) { return _v[i]; } const T & operator [] (size_t i) const { return _v[i]; } size_t size() const { return _sz; } |