aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2017-09-06 15:44:04 +0000
committerGeir Storli <geirst@oath.com>2017-09-06 15:45:26 +0000
commit4119e49f014b01395fe67b9d95e4fd3b1616ca3d (patch)
treeb7c26e40f4adcd7779868328a0b36becf80f0dc1 /searchcore/src/tests
parent9a2a64a3bd9a20ce2e5697a450ce5bc4896179b1 (diff)
Make AttributeWriter::forceCommit() clear the search cache of all imported attribute vectors.
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_test.cpp75
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp3
2 files changed, 57 insertions, 21 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp
index ad80f99a6aa..1112cf75570 100644
--- a/searchcore/src/tests/proton/attribute/attribute_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp
@@ -2,44 +2,45 @@
#include <vespa/log/log.h>
LOG_SETUP("attribute_test");
-#include <vespa/fastos/file.h>
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/config-attributes.h>
#include <vespa/document/fieldvalue/document.h>
+#include <vespa/document/predicate/predicate_slime_builder.h>
#include <vespa/document/update/arithmeticvalueupdate.h>
+#include <vespa/document/update/assignvalueupdate.h>
+#include <vespa/eval/tensor/default_tensor.h>
+#include <vespa/eval/tensor/tensor.h>
+#include <vespa/eval/tensor/tensor_factory.h>
+#include <vespa/eval/tensor/types.h>
+#include <vespa/fastos/file.h>
#include <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/attribute/filter_attribute_manager.h>
+#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
+#include <vespa/searchcore/proton/common/hw_info.h>
#include <vespa/searchcore/proton/test/attribute_utils.h>
#include <vespa/searchcorespi/flush/iflushtarget.h>
#include <vespa/searchlib/attribute/attributefactory.h>
+#include <vespa/searchlib/attribute/attributevector.hpp>
+#include <vespa/searchlib/attribute/bitvector_search_cache.h>
+#include <vespa/searchlib/attribute/imported_attribute_vector.h>
#include <vespa/searchlib/attribute/integerbase.h>
+#include <vespa/searchlib/attribute/predicate_attribute.h>
+#include <vespa/searchlib/attribute/singlenumericattribute.hpp>
+#include <vespa/searchlib/common/foregroundtaskexecutor.h>
#include <vespa/searchlib/common/idestructorcallback.h>
+#include <vespa/searchlib/common/sequencedtaskexecutorobserver.h>
#include <vespa/searchlib/index/docbuilder.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
+#include <vespa/searchlib/predicate/predicate_hash.h>
+#include <vespa/searchlib/predicate/predicate_index.h>
+#include <vespa/searchlib/tensor/tensor_attribute.h>
+#include <vespa/searchlib/test/directory_handler.h>
#include <vespa/searchlib/util/filekit.h>
-#include <vespa/searchcore/proton/common/hw_info.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/test/insertion_operators.h>
-
-#include <vespa/document/predicate/predicate_slime_builder.h>
-#include <vespa/document/update/assignvalueupdate.h>
-#include <vespa/searchlib/attribute/attributevector.hpp>
-#include <vespa/searchlib/attribute/predicate_attribute.h>
-#include <vespa/searchlib/predicate/predicate_index.h>
-#include <vespa/searchlib/attribute/singlenumericattribute.hpp>
-#include <vespa/searchlib/predicate/predicate_hash.h>
-#include <vespa/searchlib/common/foregroundtaskexecutor.h>
-#include <vespa/searchlib/common/sequencedtaskexecutorobserver.h>
-#include <vespa/searchlib/test/directory_handler.h>
-#include <vespa/eval/tensor/tensor.h>
-#include <vespa/eval/tensor/types.h>
-#include <vespa/eval/tensor/default_tensor.h>
-#include <vespa/eval/tensor/tensor_factory.h>
-#include <vespa/searchlib/tensor/tensor_attribute.h>
-#include <vespa/config-attributes.h>
-
+#include <vespa/vespalib/testkit/testapp.h>
namespace vespa { namespace config { namespace search {}}}
@@ -50,8 +51,12 @@ using namespace search::index;
using namespace search;
using namespace vespa::config::search;
+using proton::ImportedAttributesRepo;
using proton::test::AttributeUtils;
using search::TuneFileAttributes;
+using search::attribute::BitVectorSearchCache;
+using search::attribute::ImportedAttributeVector;
+using search::attribute::ReferenceAttribute;
using search::index::DummyFileHeaderContext;
using search::index::schema::CollectionType;
using search::predicate::PredicateHash;
@@ -712,6 +717,34 @@ TEST_F("require that attribute writer spreads write over 3 write contexts", Fixt
TEST_DO(putAttributes(f, {0, 1, 2}));
}
+ImportedAttributeVector::SP
+createImportedAttribute(const vespalib::string &name)
+{
+ auto result = std::make_shared<ImportedAttributeVector>(name,
+ ReferenceAttribute::SP(),
+ AttributeVector::SP(),
+ true);
+ result->getSearchCache()->insert("foo", BitVectorSearchCache::Entry::SP());
+ return result;
+}
+
+ImportedAttributesRepo::UP
+createImportedAttributesRepo()
+{
+ auto result = std::make_unique<ImportedAttributesRepo>();
+ result->add("imported_a", createImportedAttribute("imported_a"));
+ result->add("imported_b", createImportedAttribute("imported_b"));
+ return result;
+}
+
+TEST_F("require that AttributeWriter::forceCommit() clears search cache in imported attribute vectors", Fixture)
+{
+ f._m->setImportedAttributes(createImportedAttributesRepo());
+ f.commit(10);
+ EXPECT_EQUAL(0u, f._m->getImportedAttributes()->get("imported_a")->getSearchCache()->size());
+ EXPECT_EQUAL(0u, f._m->getImportedAttributes()->get("imported_b")->getSearchCache()->size());
+}
+
TEST_MAIN()
{
vespalib::rmdir(test_dir, true);
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index 6eb447ac968..4b4e5b955a1 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -384,6 +384,9 @@ struct MyAttributeManager : public proton::IAttributeManager
virtual void setImportedAttributes(std::unique_ptr<ImportedAttributesRepo>) override {
abort();
}
+ virtual const ImportedAttributesRepo *getImportedAttributes() const override {
+ abort();
+ }
};
struct MockLidSpaceCompactionHandler : public ILidSpaceCompactionHandler