summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-15 22:00:45 +0200
committerGitHub <noreply@github.com>2020-06-15 22:00:45 +0200
commit39d7728ad2efcf72bffa02b7e0d03bbe672ced1d (patch)
treed88684a09c7bb3155896aee3dfc595477b4ac6e9 /searchlib
parentba5d6c161d9d4ff9bd3a3f8237102a688558febe (diff)
Revert "Two phase put in attribute writer"
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/index/doctypebuilder.cpp42
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.h5
3 files changed, 26 insertions, 23 deletions
diff --git a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp
index 4656a5e9edd..a7ad475d6aa 100644
--- a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp
+++ b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp
@@ -10,36 +10,38 @@ using namespace document;
namespace search::index {
namespace {
-DataType::Type convert(Schema::DataType type) {
+TensorDataType tensorDataType(vespalib::eval::ValueType::from_spec("tensor(x{}, y{})"));
+
+const DataType *convert(Schema::DataType type) {
switch (type) {
case schema::DataType::BOOL:
case schema::DataType::UINT2:
case schema::DataType::UINT4:
case schema::DataType::INT8:
- return DataType::T_BYTE;
+ return DataType::BYTE;
case schema::DataType::INT16:
- return DataType::T_SHORT;
+ return DataType::SHORT;
case schema::DataType::INT32:
- return DataType::T_INT;
+ return DataType::INT;
case schema::DataType::INT64:
- return DataType::T_LONG;
+ return DataType::LONG;
case schema::DataType::FLOAT:
- return DataType::T_FLOAT;
+ return DataType::FLOAT;
case schema::DataType::DOUBLE:
- return DataType::T_DOUBLE;
+ return DataType::DOUBLE;
case schema::DataType::STRING:
- return DataType::T_STRING;
+ return DataType::STRING;
case schema::DataType::RAW:
- return DataType::T_RAW;
+ return DataType::RAW;
case schema::DataType::BOOLEANTREE:
- return DataType::T_PREDICATE;
+ return DataType::PREDICATE;
case schema::DataType::TENSOR:
- return DataType::T_TENSOR;
+ return &tensorDataType;
default:
break;
}
assert(!"Unknown datatype in schema");
- return DataType::MAX;
+ return 0;
}
void
@@ -140,12 +142,12 @@ document::DocumenttypesConfig DocTypeBuilder::makeConfig() const {
if (usf != usedFields.end()) {
continue; // taken as index field
}
- auto type_id = convert(field.getDataType());
- if (type_id == DataType::T_TENSOR) {
- header_struct.addTensorField(field.getName(), field.get_tensor_spec());
+ const DataType *primitiveType = convert(field.getDataType());
+ if (primitiveType->getId() == DataType::T_TENSOR) {
+ header_struct.addTensorField(field.getName(), dynamic_cast<const TensorDataType &>(*primitiveType).getTensorType().to_spec());
} else {
header_struct.addField(field.getName(), type_cache.getType(
- type_id, field.getCollectionType()));
+ primitiveType->getId(), field.getCollectionType()));
}
usedFields.insert(field.getName());
}
@@ -156,12 +158,12 @@ document::DocumenttypesConfig DocTypeBuilder::makeConfig() const {
if (usf != usedFields.end()) {
continue; // taken as index field or attribute field
}
- auto type_id = convert(field.getDataType());
- if (type_id == DataType::T_TENSOR) {
- header_struct.addTensorField(field.getName(), field.get_tensor_spec());
+ const DataType *primitiveType(convert(field.getDataType()));
+ if (primitiveType->getId() == DataType::T_TENSOR) {
+ header_struct.addTensorField(field.getName(), dynamic_cast<const TensorDataType &>(*primitiveType).getTensorType().to_spec());
} else {
header_struct.addField(field.getName(), type_cache.getType(
- type_id, field.getCollectionType()));
+ primitiveType->getId(), field.getCollectionType()));
}
usedFields.insert(field.getName());
}
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index 6cf4f6d2689..f8db11ae9d8 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -263,7 +263,7 @@ TensorAttribute::prepare_set_tensor(DocId docid, const Tensor& tensor) const
void
TensorAttribute::complete_set_tensor(DocId docid, const Tensor& tensor,
- std::unique_ptr<PrepareResult> prepare_result)
+ std::future<std::unique_ptr<PrepareResult>> prepare_result)
{
(void) docid;
(void) tensor;
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
index 8380e485172..f752b9f7f2e 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
@@ -7,6 +7,7 @@
#include "tensor_store.h"
#include <vespa/searchlib/attribute/not_implemented_attribute.h>
#include <vespa/vespalib/util/rcuvector.h>
+#include <future>
namespace search::tensor {
@@ -65,9 +66,9 @@ public:
* Performs the complete step in a two-phase operation to set a tensor for a document.
*
* This function is only called by the attribute writer thread.
- * It uses the result from the prepare step to do the modifying changes.
+ * It must wait for the result from the prepare step (via the future) before it does the modifying changes.
*/
- virtual void complete_set_tensor(DocId docid, const Tensor& tensor, std::unique_ptr<PrepareResult> prepare_result);
+ virtual void complete_set_tensor(DocId docid, const Tensor& tensor, std::future<std::unique_ptr<PrepareResult>> prepare_result);
virtual void compactWorst() = 0;
};