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 /searchlib | |
parent | cfeefa8456632146b99c8133e8321523ce261840 (diff) |
use factory.from_spec() instead of tensor::makeTensor<T>
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/features/tensor/tensor_test.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
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(); } |