diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-12-01 15:10:59 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-12-02 14:14:12 +0000 |
commit | 919ec00a9948c24f645daafbaea94183cc931397 (patch) | |
tree | 11417c16a7ee0aa1274e1605e21e43b62ccad3ac /searchcore/src/tests/proton | |
parent | 2966d36270a364b0d1421fa3c5dfffdca7a8a26d (diff) |
use SimpleValue instead of EngineOrFactory
Diffstat (limited to 'searchcore/src/tests/proton')
8 files changed, 47 insertions, 42 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index c98127f4daf..8076e3d05e9 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -7,8 +7,9 @@ #include <vespa/document/update/arithmeticvalueupdate.h> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/update/documentupdate.h> -#include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/eval/value.h> +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/test/value_compare.h> #include <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/searchcommon/attribute/iattributevector.h> @@ -82,7 +83,7 @@ using std::string; using vespalib::ForegroundTaskExecutor; using vespalib::ForegroundThreadExecutor; using vespalib::SequencedTaskExecutorObserver; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; @@ -644,7 +645,7 @@ TEST_F(FilterAttributeManagerTest, readable_attribute_vector_filters_attributes) namespace { Value::UP make_tensor(const TensorSpec &spec) { - return EngineOrFactory::get().from_spec(spec); + return SimpleValue::from_spec(spec); } const vespalib::string sparse_tensor = "tensor(x{},y{})"; @@ -668,7 +669,7 @@ Document::UP createTensorPutDoc(DocBuilder &builder, const Value &tensor) { return builder.startDocument("id:ns:searchdocument::1"). startAttributeField("a1"). - addTensor(EngineOrFactory::get().copy(tensor)).endField().endDocument(); + addTensor(SimpleValue::from_value(tensor)).endField().endDocument(); } } @@ -712,7 +713,7 @@ TEST_F(AttributeWriterTest, handles_tensor_assign_update) .add({{"x", "8"}, {"y", "9"}}, 11)); TensorDataType xySparseTensorDataType(vespalib::eval::ValueType::from_spec(sparse_tensor)); TensorFieldValue new_value(xySparseTensorDataType); - new_value = EngineOrFactory::get().copy(*new_tensor); + new_value = SimpleValue::from_value(*new_tensor); upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) .addUpdate(AssignValueUpdate(new_value))); DummyFieldUpdateCallback onUpdate; diff --git a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp index 5e6d8cf1659..c74c93a376a 100644 --- a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp +++ b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp @@ -22,8 +22,10 @@ #include <vespa/document/update/tensor_add_update.h> #include <vespa/document/update/tensor_modify_update.h> #include <vespa/document/update/tensor_remove_update.h> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/searchcore/proton/common/attribute_updater.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/reference_attribute.h> @@ -50,10 +52,10 @@ using search::tensor::ITensorAttribute; using search::tensor::DenseTensorAttribute; using search::tensor::SerializedTensorAttribute; using search::tensor::TensorAttribute; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; +using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; -using vespalib::eval::TensorSpec; namespace search { @@ -411,7 +413,7 @@ getTensorDataType(const vespalib::string &spec) std::unique_ptr<Value> makeTensor(const TensorSpec &spec) { - return EngineOrFactory::get().from_spec(spec); + return SimpleValue::from_spec(spec); } std::unique_ptr<TensorFieldValue> @@ -441,7 +443,7 @@ struct TensorFixture : public Fixture { } void assertTensor(const TensorSpec &expSpec) { - auto actual = EngineOrFactory::get().to_spec(*attribute->getTensor(1)); + auto actual = spec_from_value(*attribute->getTensor(1)); EXPECT_EQUAL(expSpec, actual); } }; diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 04258b3989f..5741a844ded 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -2,7 +2,8 @@ #include <tests/proton/common/dummydbowner.h> #include <vespa/config/helper/configgetter.hpp> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> #include <vespa/document/repo/documenttyperepo.h> @@ -59,7 +60,7 @@ using storage::spi::Timestamp; using vespa::config::search::core::ProtonConfig; using vespa::config::content::core::BucketspacesConfig; using vespalib::eval::TensorSpec; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; using namespace vespalib::slime; typedef std::unique_ptr<GeneralResult> GeneralResultPtr; @@ -139,7 +140,7 @@ getDocTypeName() } vespalib::eval::Value::UP make_tensor(const TensorSpec &spec) { - return EngineOrFactory::get().from_spec(spec); + return SimpleValue::from_spec(spec); } vespalib::string asVstring(vespalib::Memory str) { @@ -334,7 +335,7 @@ assertTensor(const vespalib::eval::Value::UP & exp, const std::string & fieldNam EXPECT_EQUAL(exp.get() == nullptr, data.size == 0u); if (exp) { vespalib::nbostream x(data.data, data.size); - auto tensor = EngineOrFactory::get().decode(x); + auto tensor = SimpleValue::from_stream(x); EXPECT_TRUE(tensor.get() != nullptr); EXPECT_EQUAL(*exp, *tensor); } diff --git a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp index 6c7efda9a69..86f0e8fdcf8 100644 --- a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp +++ b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp @@ -45,7 +45,8 @@ #include <vespa/vespalib/data/slime/json_format.h> #include <vespa/vespalib/data/slime/binary_format.h> #include <vespa/searchlib/util/slime_output_raw_buf_adapter.h> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> #include <vespa/vespalib/data/slime/slime.h> @@ -93,10 +94,10 @@ using search::linguistics::TERM; using vespa::config::search::SummarymapConfig; using vespa::config::search::SummarymapConfigBuilder; using vespalib::Slime; +using vespalib::eval::SimpleValue; +using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; -using vespalib::eval::TensorSpec; -using vespalib::eval::EngineOrFactory; using vespalib::geo::ZCurve; using vespalib::slime::Cursor; using vespalib::string; @@ -676,7 +677,7 @@ Test::requireThatPredicateIsPrinted() } Value::UP make_tensor(const TensorSpec &spec) { - return EngineOrFactory::get().from_spec(spec); + return SimpleValue::from_spec(spec); } void diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index ed3bb3253c9..d06da31b415 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -5,7 +5,7 @@ #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/update/documentupdate.h> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/simple_value.h> #include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> @@ -58,7 +58,7 @@ using storage::spi::UpdateResult; using vespalib::ThreadStackExecutor; using vespalib::ThreadStackExecutorBase; using vespalib::makeClosure; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; @@ -330,13 +330,13 @@ struct UpdateContext { auto fieldValue = field.createValue(); if (fieldName == "tensor") { dynamic_cast<TensorFieldValue &>(*fieldValue) = - EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})"). - add({{"x","8"},{"y","9"}}, 11)); + SimpleValue::from_spec(TensorSpec("tensor(x{},y{})"). + add({{"x","8"},{"y","9"}}, 11)); } else if (fieldName == "tensor2") { auto tensorFieldValue = std::make_unique<TensorFieldValue>(tensor1DType); *tensorFieldValue = - EngineOrFactory::get().from_spec(TensorSpec("tensor(x{})"). - add({{"x","8"}}, 11)); + SimpleValue::from_spec(TensorSpec("tensor(x{})"). + add({{"x","8"}}, 11)); fieldValue = std::move(tensorFieldValue); } else { fieldValue->assign(document::StringFieldValue("new value")); diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 3bd5b36aa86..0278aba41d9 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -32,8 +32,9 @@ #include <vespa/searchcore/proton/matching/match_params.h> #include <vespa/searchcore/proton/matching/match_tools.h> #include <vespa/searchcore/proton/matching/match_context.h> +#include <vespa/eval/eval/simple_value.h> #include <vespa/eval/eval/tensor_spec.h> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/log/log.h> @@ -58,8 +59,8 @@ using storage::spi::Timestamp; using search::fef::indexproperties::hitcollector::HeapSize; using vespalib::nbostream; +using vespalib::eval::SimpleValue; using vespalib::eval::TensorSpec; -using vespalib::eval::EngineOrFactory; void inject_match_phase_limiting(Properties &setup, const vespalib::string &attribute, size_t max_hits, bool descending) { @@ -666,9 +667,8 @@ TEST("require that summary features are filled") { EXPECT_TRUE(!f[2].is_double()); EXPECT_TRUE(f[2].is_data()); { - auto engine = EngineOrFactory::get(); nbostream buf(f[2].as_data().data, f[2].as_data().size); - auto actual = engine.to_spec(*engine.decode(buf)); + auto actual = spec_from_value(*SimpleValue::from_stream(buf)); auto expect = TensorSpec("tensor(x[3])").add({{"x", 0}}, 0).add({{"x", 1}}, 1).add({{"x", 2}}, 2); EXPECT_EQUAL(actual, expect); } diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp index 4c2ae99c9cd..7b545344e9b 100644 --- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp +++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp @@ -1,7 +1,8 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/eval/eval/tensor_spec.h> -#include <vespa/eval/eval/engine_or_factory.h> #include <vespa/searchcore/proton/matching/requestcontext.h> #include <vespa/searchlib/attribute/attribute_blueprint_params.h> #include <vespa/searchlib/fef/properties.h> @@ -13,7 +14,7 @@ using search::attribute::IAttributeContext; using search::attribute::IAttributeFunctor; using search::attribute::IAttributeVector; using search::fef::Properties; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; using vespalib::eval::TensorSpec; using vespalib::eval::Value; using namespace proton; @@ -37,7 +38,7 @@ private: void insert_tensor_in_properties(const vespalib::string& tensor_name, const Value& tensor_value) { vespalib::nbostream stream; - EngineOrFactory::get().encode(tensor_value, stream); + encode_value(tensor_value, stream); _props.add(tensor_name, vespalib::stringref(stream.data(), stream.size())); } @@ -48,14 +49,14 @@ public: _attr_ctx(), _props(), _request_ctx(_doom, _attr_ctx, _props, AttributeBlueprintParams()), - _query_tensor(EngineOrFactory::get().from_spec(TensorSpec("tensor(x[2])") - .add({{"x", 0}}, 3).add({{"x", 1}}, 5))) + _query_tensor(SimpleValue::from_spec(TensorSpec("tensor(x[2])") + .add({{"x", 0}}, 3).add({{"x", 1}}, 5))) { insert_tensor_in_properties("my_tensor", *_query_tensor); _props.add("my_string", "foo bar"); } TensorSpec expected_query_tensor() const { - return EngineOrFactory::get().to_spec(*_query_tensor); + return spec_from_value(*_query_tensor); } Value::UP get_query_tensor(const vespalib::string& tensor_name) const { return _request_ctx.get_query_tensor(tensor_name); @@ -67,7 +68,7 @@ TEST_F(RequestContextTest, query_tensor_can_be_retrieved) auto tensor = get_query_tensor("my_tensor"); ASSERT_TRUE(tensor); EXPECT_TRUE(tensor->is_tensor()); - EXPECT_EQ(expected_query_tensor(), EngineOrFactory::get().to_spec(*tensor)); + EXPECT_EQ(expected_query_tensor(), spec_from_value(*tensor)); } TEST_F(RequestContextTest, non_existing_query_tensor_returns_nullptr) diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp index 019e1bce40a..058374cfc59 100644 --- a/searchcore/src/tests/proton/server/documentretriever_test.cpp +++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp @@ -20,7 +20,8 @@ #include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/documenttyperepo.h> -#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/simple_value.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> #include <vespa/persistence/spi/bucket.h> @@ -88,7 +89,7 @@ using storage::spi::Timestamp; using storage::spi::test::makeSpiBucket; using vespalib::make_string; using vespalib::string; -using vespalib::eval::EngineOrFactory; +using vespalib::eval::SimpleValue; using vespalib::eval::TensorSpec; using vespalib::eval::ValueType; using vespalib::eval::Value; @@ -110,10 +111,8 @@ const char dyn_field_nas[] = "dynamic null attr string field"; // in document, n const char position_field[] = "position_field"; vespalib::string dyn_field_tensor("dynamic_tensor_field"); vespalib::string tensor_spec("tensor(x{})"); -std::unique_ptr<Value> static_tensor = - EngineOrFactory::get().from_spec(TensorSpec(tensor_spec).add({{"x", "1"}}, 1.5)); -std::unique_ptr<Value> dynamic_tensor = - EngineOrFactory::get().from_spec(TensorSpec(tensor_spec).add({{"x", "2"}}, 3.5)); +std::unique_ptr<Value> static_tensor = SimpleValue::from_spec(TensorSpec(tensor_spec).add({{"x", "1"}}, 1.5)); +std::unique_ptr<Value> dynamic_tensor = SimpleValue::from_spec(TensorSpec(tensor_spec).add({{"x", "2"}}, 3.5)); const char zcurve_field[] = "position_field_zcurve"; const char position_array_field[] = "position_array"; const char zcurve_array_field[] = "position_array_zcurve"; @@ -169,7 +168,7 @@ struct MyDocumentStore : proton::test::DummyDocumentStore { doc->set(zcurve_field, static_zcurve_value); doc->setValue(dyn_field_p, static_value_p); TensorFieldValue tensorFieldValue(tensorDataType); - tensorFieldValue = EngineOrFactory::get().copy(*static_tensor); + tensorFieldValue = SimpleValue::from_value(*static_tensor); doc->setValue(dyn_field_tensor, tensorFieldValue); if (_set_position_struct_field) { FieldValue::UP fv = PositionDataType::getInstance().createFieldValue(); |