diff options
author | Geir Storli <geirst@oath.com> | 2017-11-07 10:11:05 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2017-11-07 11:41:23 +0000 |
commit | a473f56892e5167c9372dc3f029d2534d480ddff (patch) | |
tree | dc8fff60d2312ea244afb127fb35e9ed19fc370e /searchcore | |
parent | e1ec2b026fe03f011c7f11736a8b43cb3da28082 (diff) |
Add test for batch remove on attribute writer.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/attribute/attribute_test.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index ce0205af29f..125866a1a3e 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -41,6 +41,7 @@ LOG_SETUP("attribute_test"); #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/searchcommon/attribute/iattributevector.h> namespace vespa { namespace config { namespace search {}}} @@ -55,6 +56,7 @@ using proton::ImportedAttributesRepo; using proton::test::AttributeUtils; using search::TuneFileAttributes; using search::attribute::BitVectorSearchCache; +using search::attribute::IAttributeVector; using search::attribute::ImportedAttributeVector; using search::attribute::ReferenceAttribute; using search::index::DummyFileHeaderContext; @@ -69,10 +71,11 @@ using vespalib::tensor::Tensor; using vespalib::tensor::TensorCells; using vespalib::tensor::TensorDimensions; -typedef search::attribute::Config AVConfig; -typedef search::attribute::BasicType AVBasicType; -typedef search::attribute::CollectionType AVCollectionType; -typedef SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> > Int32AttributeVector; +using AVConfig = search::attribute::Config; +using AVBasicType = search::attribute::BasicType; +using AVCollectionType = search::attribute::CollectionType; +using Int32AttributeVector = SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> >; +using LidVector = LidVectorContext::LidVector; namespace { @@ -156,6 +159,9 @@ struct Fixture void remove(SerialNum serialNum, DocumentIdT lid, bool immediateCommit = true) { _aw->remove(serialNum, lid, immediateCommit, emptyCallback); } + void remove(const LidVector &lidVector, SerialNum serialNum, bool immediateCommit = true) { + _aw->remove(lidVector, serialNum, immediateCommit, emptyCallback); + } void commit(SerialNum serialNum) { _aw->forceCommit(serialNum, emptyCallback); } @@ -293,6 +299,12 @@ TEST_F("require that attribute writer handles predicate put", Fixture) EXPECT_TRUE(it.valid()); } +void +assertUndefined(const IAttributeVector &attr, uint32_t docId) +{ + EXPECT_TRUE(search::attribute::isUndefined<int32_t>(attr.getInt(docId))); +} + TEST_F("require that attribute writer handles remove", Fixture) { AttributeVector::SP a1 = f.addAttribute("a1"); @@ -308,8 +320,8 @@ TEST_F("require that attribute writer handles remove", Fixture) f.remove(2, 0); - EXPECT_TRUE(search::attribute::isUndefined<int32_t>(a1->getInt(0))); - EXPECT_TRUE(search::attribute::isUndefined<int32_t>(a2->getInt(0))); + TEST_DO(assertUndefined(*a1, 0)); + TEST_DO(assertUndefined(*a2, 0)); f.remove(2, 0); // same sync token as previous try { @@ -321,6 +333,24 @@ TEST_F("require that attribute writer handles remove", Fixture) } } +TEST_F("require that attribute writer handles batch remove", Fixture) +{ + AttributeVector::SP a1 = f.addAttribute("a1"); + AttributeVector::SP a2 = f.addAttribute("a2"); + fillAttribute(a1, 4, 22, 1); + fillAttribute(a2, 4, 33, 1); + + LidVector lidsToRemove = {1,3}; + f.remove(lidsToRemove, 2); + + TEST_DO(assertUndefined(*a1, 1)); + EXPECT_EQUAL(22, a1->getInt(2)); + TEST_DO(assertUndefined(*a1, 3)); + TEST_DO(assertUndefined(*a2, 1)); + EXPECT_EQUAL(33, a2->getInt(2)); + TEST_DO(assertUndefined(*a2, 3)); +} + void verifyAttributeContent(const AttributeVector & v, uint32_t lid, vespalib::stringref expected) { attribute::ConstCharContent sbuf; |