summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-09-01 13:34:34 +0000
committerArne Juul <arnej@verizonmedia.com>2020-09-01 13:34:34 +0000
commit618dd98341a131cd40e70cf8a150948284ad55e1 (patch)
tree948b5afa8fbced39b1fd6dcff676976708c8759e
parent1e3ffd7130e44e696281ed7f8ccda28180cf2538 (diff)
even simpler executor for direct tensor attributes
-rw-r--r--searchlib/src/vespa/searchlib/features/CMakeLists.txt1
-rw-r--r--searchlib/src/vespa/searchlib/features/attributefeature.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.cpp23
-rw-r--r--searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.h20
4 files changed, 50 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/features/CMakeLists.txt b/searchlib/src/vespa/searchlib/features/CMakeLists.txt
index 93fead713f4..7bb4849bb87 100644
--- a/searchlib/src/vespa/searchlib/features/CMakeLists.txt
+++ b/searchlib/src/vespa/searchlib/features/CMakeLists.txt
@@ -11,6 +11,7 @@ vespa_add_library(searchlib_features OBJECT
debug_attribute_wait.cpp
debug_wait.cpp
dense_tensor_attribute_executor.cpp
+ direct_tensor_attribute_executor.cpp
distancefeature.cpp
distancetopathfeature.cpp
documenttestutils.cpp
diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.cpp b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
index 78804513ab7..7c0ed1147f7 100644
--- a/searchlib/src/vespa/searchlib/features/attributefeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
@@ -5,11 +5,13 @@
#include "valuefeature.h"
#include "constant_tensor_executor.h"
#include "dense_tensor_attribute_executor.h"
+#include "direct_tensor_attribute_executor.h"
#include "tensor_attribute_executor.h"
#include <vespa/searchcommon/common/undefinedvalues.h>
#include <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchlib/tensor/dense_tensor_attribute.h>
+#include <vespa/searchlib/tensor/direct_tensor_attribute.h>
#include <vespa/searchlib/fef/indexproperties.h>
#include <vespa/searchlib/attribute/singlenumericattribute.h>
#include <vespa/searchlib/attribute/multinumericattribute.h>
@@ -24,6 +26,7 @@ using search::attribute::BasicType;
using search::attribute::CollectionType;
using search::attribute::ConstCharContent;
using search::tensor::DenseTensorAttribute;
+using search::tensor::DirectTensorAttribute;
using search::attribute::IntegerContent;
using search::attribute::FloatContent;
using search::tensor::ITensorAttribute;
@@ -469,6 +472,9 @@ createTensorAttributeExecutor(const IAttributeVector *attribute, const vespalib:
if (tensorType.is_dense()) {
return stash.create<DenseTensorAttributeExecutor>(tensorAttribute);
}
+ if (auto direct = dynamic_cast<const DirectTensorAttribute *>(tensorAttribute)) {
+ return stash.create<DirectTensorAttributeExecutor>(*direct);
+ }
return stash.create<TensorAttributeExecutor>(tensorAttribute);
}
diff --git a/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.cpp b/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.cpp
new file mode 100644
index 00000000000..cd0f4d4d356
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.cpp
@@ -0,0 +1,23 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "direct_tensor_attribute_executor.h"
+#include <vespa/searchlib/tensor/direct_tensor_attribute.h>
+#include <vespa/eval/tensor/tensor.h>
+
+namespace search {
+namespace features {
+
+DirectTensorAttributeExecutor::
+DirectTensorAttributeExecutor(const DirectTensorAttribute &attribute)
+ : _attribute(attribute)
+{
+}
+
+void
+DirectTensorAttributeExecutor::execute(uint32_t docId)
+{
+ outputs().set_object(0, _attribute.get_tensor_ref(docId));
+}
+
+} // namespace features
+} // namespace search
diff --git a/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.h b/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.h
new file mode 100644
index 00000000000..e311fba076e
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/features/direct_tensor_attribute_executor.h
@@ -0,0 +1,20 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/searchlib/fef/featureexecutor.h>
+
+namespace search::tensor { class DirectTensorAttribute; }
+namespace search::features {
+
+class DirectTensorAttributeExecutor : public fef::FeatureExecutor
+{
+public:
+ using DirectTensorAttribute = search::tensor::DirectTensorAttribute;
+ DirectTensorAttributeExecutor(const DirectTensorAttribute &attribute);
+ void execute(uint32_t docId) override;
+private:
+ const DirectTensorAttribute &_attribute;
+};
+
+}