summaryrefslogtreecommitdiffstats
path: root/document/src
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-02-15 13:32:13 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-02-15 13:32:13 +0000
commit91ae7785e7fc132d9e3959be5810a488f125ac84 (patch)
tree6263481389ab0176d33389a7b99824772da70054 /document/src
parent81999faf9b314681419ac0e00ff921efc5566d90 (diff)
Simplify tensor type used in update tests.
Diffstat (limited to 'document/src')
-rw-r--r--document/src/tests/documentupdatetestcase.cpp44
-rw-r--r--document/src/vespa/document/base/testdocrepo.cpp2
2 files changed, 25 insertions, 21 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index b351299f2d1..b71c270d3e8 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -914,17 +914,21 @@ struct TensorUpdateFixture {
Document::UP emptyDoc;
Document updatedDoc;
vespalib::string fieldName;
+ const TensorDataType &tensorDataType;
vespalib::string tensorType;
- TensorDataType tensorDataType;
- TensorUpdateFixture(const vespalib::string &fieldName_ = "tensor",
- const vespalib::string &tensorType_ = "tensor(x{},y{})")
+ const TensorDataType &extractTensorDataType() {
+ const auto &dataType = emptyDoc->getField(fieldName).getDataType();
+ return dynamic_cast<const TensorDataType &>(dataType);
+ }
+
+ TensorUpdateFixture(const vespalib::string &fieldName_ = "sparse_tensor")
: docMan(),
emptyDoc(docMan.createDocument()),
updatedDoc(*emptyDoc),
fieldName(fieldName_),
- tensorType(tensorType_),
- tensorDataType(vespalib::eval::ValueType::from_spec(tensorType))
+ tensorDataType(extractTensorDataType()),
+ tensorType(tensorDataType.getTensorType().to_spec())
{
CPPUNIT_ASSERT(!emptyDoc->getValue(fieldName));
}
@@ -952,8 +956,8 @@ struct TensorUpdateFixture {
}
std::unique_ptr<TensorFieldValue> makeBaselineTensor() {
- return makeTensor(spec().add({{"x", "a"}, {"y", "a"}}, 2)
- .add({{"x", "a"}, {"y", "b"}}, 3));
+ return makeTensor(spec().add({{"x", "a"}}, 2)
+ .add({{"x", "b"}}, 3));
}
void applyUpdate(const ValueUpdate &update) {
@@ -1024,30 +1028,30 @@ void
DocumentUpdateTest::tensor_add_update_can_be_applied()
{
TensorUpdateFixture f;
- f.assertApplyUpdate(f.spec().add({{"x", "a"}, {"y", "a"}}, 2)
- .add({{"x", "a"}, {"y", "b"}}, 3),
+ f.assertApplyUpdate(f.spec().add({{"x", "a"}}, 2)
+ .add({{"x", "b"}}, 3),
- TensorAddUpdate(f.makeTensor(f.spec().add({{"x", "a"}, {"y", "b"}}, 5)
- .add({{"x", "a"}, {"y", "c"}}, 7))),
+ TensorAddUpdate(f.makeTensor(f.spec().add({{"x", "b"}}, 5)
+ .add({{"x", "c"}}, 7))),
- f.spec().add({{"x", "a"}, {"y", "a"}}, 2)
- .add({{"x", "a"}, {"y", "b"}}, 5)
- .add({{"x", "a"}, {"y", "c"}}, 7));
+ f.spec().add({{"x", "a"}}, 2)
+ .add({{"x", "b"}}, 5)
+ .add({{"x", "c"}}, 7));
}
void
DocumentUpdateTest::tensor_modify_update_can_be_applied()
{
TensorUpdateFixture f;
- f.assertApplyUpdate(f.spec().add({{"x", "a"}, {"y", "a"}}, 2)
- .add({{"x", "a"}, {"y", "b"}}, 3),
+ f.assertApplyUpdate(f.spec().add({{"x", "a"}}, 2)
+ .add({{"x", "b"}}, 3),
TensorModifyUpdate(TensorModifyUpdate::Operation::REPLACE,
- f.makeTensor(f.spec().add({{"x", "a"}, {"y", "b"}}, 5)
- .add({{"x", "a"}, {"y", "c"}}, 7))),
+ f.makeTensor(f.spec().add({{"x", "b"}}, 5)
+ .add({{"x", "c"}}, 7))),
- f.spec().add({{"x", "a"}, {"y", "a"}}, 2)
- .add({{"x", "a"}, {"y", "b"}}, 5));
+ f.spec().add({{"x", "a"}}, 2)
+ .add({{"x", "b"}}, 5));
}
void
diff --git a/document/src/vespa/document/base/testdocrepo.cpp b/document/src/vespa/document/base/testdocrepo.cpp
index 5bbb06519ac..c8041d8c254 100644
--- a/document/src/vespa/document/base/testdocrepo.cpp
+++ b/document/src/vespa/document/base/testdocrepo.cpp
@@ -52,7 +52,7 @@ DocumenttypesConfig TestDocRepo::getDefaultConfig() {
.addField("content", DataType::T_STRING)
.addField("rawarray", Array(DataType::T_RAW))
.addField("structarray", structarray_id)
- .addTensorField("tensor", "tensor(x{},y{})"));
+ .addTensorField("sparse_tensor", "tensor(x{})"));
builder.document(type2_id, "testdoctype2",
Struct("testdoctype2.header")
.addField("onlyinchild", DataType::T_INT),