diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-11-27 11:44:10 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-11-27 12:45:30 +0000 |
commit | 5f7755b688fedbec191a06ce3c4c3d6cfb685c14 (patch) | |
tree | 4683d716b0ec1d2d9fea63e7cdec351538b5df34 | |
parent | cfeefa8456632146b99c8133e8321523ce261840 (diff) |
use factory.from_spec() instead of tensor::makeTensor<T>
4 files changed, 42 insertions, 43 deletions
diff --git a/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp b/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp index 231fba93d10..067cf4ac649 100644 --- a/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp +++ b/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp @@ -9,16 +9,13 @@ LOG_SETUP("fieldvalue_test"); #include <vespa/document/fieldvalue/tensorfieldvalue.h> #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/eval/value.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/vespalib/testkit/testapp.h> using namespace document; -using namespace vespalib::tensor; using vespalib::eval::TensorSpec; using vespalib::eval::ValueType; using vespalib::eval::EngineOrFactory; -using vespalib::tensor::test::makeTensor; namespace { @@ -33,8 +30,8 @@ vespalib::eval::Value::UP createTensor(const TensorSpec &spec) { std::unique_ptr<vespalib::eval::Value> makeSimpleTensor() { - return makeTensor<vespalib::eval::Value>(TensorSpec("tensor(x{},y{})"). - add({{"x", "4"}, {"y", "5"}}, 7)); + return EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})"). + add({{"x", "4"}, {"y", "5"}}, 7)); } FieldValue::UP clone(FieldValue &fv) { diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index c28a099a990..ed3bb3253c9 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -5,8 +5,9 @@ #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/tensor_spec.h> #include <vespa/eval/eval/value.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/common/feedtoken.h> @@ -57,10 +58,10 @@ using storage::spi::UpdateResult; using vespalib::ThreadStackExecutor; using vespalib::ThreadStackExecutorBase; using vespalib::makeClosure; +using vespalib::eval::EngineOrFactory; using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; -using vespalib::tensor::test::makeTensor; using namespace proton; using namespace search::index; @@ -329,13 +330,13 @@ struct UpdateContext { auto fieldValue = field.createValue(); if (fieldName == "tensor") { dynamic_cast<TensorFieldValue &>(*fieldValue) = - makeTensor<Value>(TensorSpec("tensor(x{},y{})"). - add({{"x","8"},{"y","9"}}, 11)); + EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})"). + add({{"x","8"},{"y","9"}}, 11)); } else if (fieldName == "tensor2") { auto tensorFieldValue = std::make_unique<TensorFieldValue>(tensor1DType); *tensorFieldValue = - makeTensor<Value>(TensorSpec("tensor(x{})"). - add({{"x","8"}}, 11)); + EngineOrFactory::get().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/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp index b93f90b3317..019e1bce40a 100644 --- a/searchcore/src/tests/proton/server/documentretriever_test.cpp +++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp @@ -92,7 +92,6 @@ using vespalib::eval::EngineOrFactory; using vespalib::eval::TensorSpec; using vespalib::eval::ValueType; using vespalib::eval::Value; -using vespalib::eval::test::makeTensor; using namespace document::config_builder; using namespace search::index; @@ -111,8 +110,10 @@ 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 = makeTensor<Value>(TensorSpec(tensor_spec).add({{"x", "1"}}, 1.5)); -std::unique_ptr<Value> dynamic_tensor = makeTensor<Value>(TensorSpec(tensor_spec).add({{"x", "2"}}, 3.5)); +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)); const char zcurve_field[] = "position_field_zcurve"; const char position_array_field[] = "position_array"; const char zcurve_array_field[] = "position_array_zcurve"; diff --git a/searchlib/src/tests/features/tensor/tensor_test.cpp b/searchlib/src/tests/features/tensor/tensor_test.cpp index 116b4ed2bb5..188a1347901 100644 --- a/searchlib/src/tests/features/tensor/tensor_test.cpp +++ b/searchlib/src/tests/features/tensor/tensor_test.cpp @@ -15,8 +15,8 @@ #include <vespa/eval/eval/function.h> #include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/eval/eval/test/value_compare.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/vespalib/objects/nbostream.h> using search::feature_t; @@ -30,10 +30,10 @@ using search::tensor::DirectTensorAttribute; using search::AttributeVector; using vespalib::eval::EngineOrFactory; using vespalib::eval::Function; +using vespalib::eval::spec_from_value; using vespalib::eval::Value; using vespalib::eval::ValueType; using vespalib::eval::TensorSpec; -using vespalib::tensor::test::makeTensor; using AVC = search::attribute::Config; using AVBT = search::attribute::BasicType; @@ -113,10 +113,10 @@ struct ExecFixture DirectTensorAttribute *directAttr = dynamic_cast<DirectTensorAttribute *>(attrs[1].get()); - auto doc_tensor = makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "a"}}, 3) - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7)); + auto doc_tensor = EngineOrFactory::get().from_spec(TensorSpec("tensor(x{})") + .add({{"x", "a"}}, 3) + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7)); tensorAttr->setTensor(1, *doc_tensor); directAttr->set_tensor(1, std::move(doc_tensor)); @@ -138,16 +138,16 @@ struct ExecFixture void setupQueryEnvironment() { setQueryTensor("tensorquery", "tensor(q{})", - makeTensor<Value>(TensorSpec("tensor(q{})") - .add({{"q", "d"}}, 11 ) - .add({{"q", "e"}}, 13 ) - .add({{"q", "f"}}, 17 ))); + EngineOrFactory::get().from_spec(TensorSpec("tensor(q{})") + .add({{"q", "d"}}, 11 ) + .add({{"q", "e"}}, 13 ) + .add({{"q", "f"}}, 17 ))); setQueryTensor("mappedtensorquery", "tensor(x[2])", - makeTensor<Value>(TensorSpec("tensor(x{},y{})") - .add({{"x", "0"},{"y", "0"}}, 11 ) - .add({{"x", "0"},{"y", "1"}}, 13 ) - .add({{"x", "1"},{"y", "0"}}, 17 ))); + EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})") + .add({{"x", "0"},{"y", "0"}}, 11 ) + .add({{"x", "0"},{"y", "1"}}, 13 ) + .add({{"x", "1"},{"y", "0"}}, 17 ))); setQueryTensorType("null", "tensor(q{})"); } const Value &extractTensor(uint32_t docid) { @@ -163,28 +163,28 @@ struct ExecFixture TEST_F("require that tensor attribute can be extracted as tensor in attribute feature", ExecFixture("attribute(tensorattr)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7) - .add({{"x", "a"}}, 3)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x{})") + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7) + .add({{"x", "a"}}, 3), spec_from_value(f.execute())); } TEST_F("require that direct tensor attribute can be extracted in attribute feature", ExecFixture("attribute(directattr)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7) - .add({{"x", "a"}}, 3)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x{})") + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7) + .add({{"x", "a"}}, 3), spec_from_value(f.execute())); } TEST_F("require that tensor from query can be extracted as tensor in query feature", ExecFixture("query(tensorquery)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(q{})") - .add({{"q", "f"}}, 17) - .add({{"q", "d"}}, 11) - .add({{"q", "e"}}, 13)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(q{})") + .add({{"q", "f"}}, 17) + .add({{"q", "d"}}, 11) + .add({{"q", "e"}}, 13), spec_from_value(f.execute())); } TEST_F("require that empty tensor is created if attribute does not exists", @@ -217,9 +217,9 @@ TEST_F("require that empty tensor with correct type is returned by direct tensor TEST_F("require that wrong tensor type from query tensor gives empty tensor", ExecFixture("query(mappedtensorquery)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x[2])") - .add({{"x", 0}}, 0) - .add({{"x", 1}}, 0)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x[2])") + .add({{"x", 0}}, 0) + .add({{"x", 1}}, 0), spec_from_value(f.execute())); } TEST_MAIN() { TEST_RUN_ALL(); } |