aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-02-10 14:17:03 +0100
committerGitHub <noreply@github.com>2020-02-10 14:17:03 +0100
commite0718e3a25613b4d9c031ce8039304e7a8d58227 (patch)
tree7b6de967e57d2bbc9a2e9d8aa5163d45446e858a
parent221584a7a0e12644e88bf5e2e6a0fec423c760c3 (diff)
parente85dbd6fda70f409f5ec3d01049ac661affba47b (diff)
Merge pull request #12124 from vespa-engine/balder/set-constants-once
Set constants once.
-rw-r--r--searchlib/src/vespa/searchlib/common/location.h8
-rw-r--r--searchlib/src/vespa/searchlib/features/attributefeature.cpp54
2 files changed, 33 insertions, 29 deletions
diff --git a/searchlib/src/vespa/searchlib/common/location.h b/searchlib/src/vespa/searchlib/common/location.h
index 96821e204e2..616bf577f0a 100644
--- a/searchlib/src/vespa/searchlib/common/location.h
+++ b/searchlib/src/vespa/searchlib/common/location.h
@@ -2,12 +2,12 @@
#pragma once
-#include <vespa/vespalib/geo/zcurve.h>
#include "documentlocations.h"
+#include <vespa/vespalib/geo/zcurve.h>
+
#include <vespa/vespalib/stllike/string.h>
-namespace search {
-namespace common {
+namespace search::common {
class Location : public DocumentLocations
{
@@ -51,5 +51,3 @@ private:
};
}
-}
-
diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.cpp b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
index 519dcf874a2..4e5bda9cb18 100644
--- a/searchlib/src/vespa/searchlib/features/attributefeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
@@ -108,6 +108,13 @@ public:
* @param attribute The attribute vector to use.
*/
SingleAttributeExecutor(const T & attribute) : _attribute(attribute) { }
+ void handle_bind_outputs(vespalib::ArrayRef<fef::NumberOrObject> outputs_in) override {
+ fef::FeatureExecutor::handle_bind_outputs(outputs_in);
+ auto o = outputs().get_bound();
+ o[1].as_number = 0; // weight
+ o[2].as_number = 0; // contains
+ o[3].as_number = 1; // count
+ }
void execute(uint32_t docId) override;
};
@@ -120,13 +127,15 @@ private:
const T & _attribute;
uint32_t _idx;
public:
- /**
- * Constructs an executor.
- *
- * @param attribute The attribute vector to use.
- */
MultiAttributeExecutor(const T & attribute, uint32_t idx) : _attribute(attribute), _idx(idx) { }
void execute(uint32_t docId) override;
+ void handle_bind_outputs(vespalib::ArrayRef<fef::NumberOrObject> outputs_in) override {
+ fef::FeatureExecutor::handle_bind_outputs(outputs_in);
+ auto o = outputs().get_bound();
+ o[1].as_number = 0; // weight
+ o[2].as_number = 0; // contains
+ o[3].as_number = 0; // count
+ }
};
class CountOnlyAttributeExecutor : public fef::FeatureExecutor {
@@ -134,13 +143,15 @@ private:
const attribute::IAttributeVector & _attribute;
public:
- /**
- * Constructs an executor.
- *
- * @param attribute The attribute vector to use.
- */
CountOnlyAttributeExecutor(const attribute::IAttributeVector & attribute) : _attribute(attribute) { }
void execute(uint32_t docId) override;
+ void handle_bind_outputs(vespalib::ArrayRef<fef::NumberOrObject> outputs_in) override {
+ fef::FeatureExecutor::handle_bind_outputs(outputs_in);
+ auto o = outputs().get_bound();
+ o[0].as_number = 0; // value
+ o[1].as_number = 0; // weight
+ o[2].as_number = 0; // contains
+ }
};
/**
* Implements the executor for fetching values from a single or array attribute vector
@@ -150,8 +161,8 @@ class AttributeExecutor : public fef::FeatureExecutor {
private:
const attribute::IAttributeVector * _attribute;
attribute::BasicType::Type _attrType;
- uint32_t _idx;
- T _buffer; // used when fetching values from the attribute
+ uint32_t _idx;
+ T _buffer; // used when fetching values from the attribute
feature_t _defaultCount;
public:
@@ -163,6 +174,13 @@ public:
*/
AttributeExecutor(const attribute::IAttributeVector * attribute, uint32_t idx);
void execute(uint32_t docId) override;
+ void handle_bind_outputs(vespalib::ArrayRef<fef::NumberOrObject> outputs_in) override {
+ fef::FeatureExecutor::handle_bind_outputs(outputs_in);
+ auto o = outputs().get_bound();
+ o[1].as_number = 0; // weight
+ o[2].as_number = 0; // contains
+ o[3].as_number = _defaultCount; // count
+ }
};
@@ -200,9 +218,6 @@ SingleAttributeExecutor<T>::execute(uint32_t docId)
o[0].as_number = __builtin_expect(attribute::isUndefined(v), false)
? attribute::getUndefined<feature_t>()
: util::getAsFeature(v);
- o[1].as_number = 0; // weight
- o[2].as_number = 0; // contains
- o[3].as_number = 1; // contains
}
template <typename T>
@@ -214,18 +229,12 @@ MultiAttributeExecutor<T>::execute(uint32_t docId)
auto o = outputs().get_bound();
o[0].as_number = __builtin_expect(_idx < numValues, true) ? values[_idx].value() : 0;
- o[1].as_number = 0; // weight
- o[2].as_number = 0; // contains
- o[3].as_number = 0; // count
}
void
CountOnlyAttributeExecutor::execute(uint32_t docId)
{
auto o = outputs().get_bound();
- o[0].as_number = 0; // value
- o[1].as_number = 0; // weight
- o[2].as_number = 0; // contains
o[3].as_number = _attribute.getValueCount(docId); // count
}
@@ -252,9 +261,6 @@ AttributeExecutor<T>::execute(uint32_t docId)
}
auto o = outputs().get_bound();
o[0].as_number = value; // value
- o[1].as_number = 0; // weight
- o[2].as_number = 0; // contains
- o[3].as_number = _defaultCount; // count
}