summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahoo-inc.com>2017-05-12 10:15:33 +0000
committerTor Egge <Tor.Egge@yahoo-inc.com>2017-05-12 10:15:33 +0000
commit703129f0917a91c0ae27a5aefce0059477753160 (patch)
tree87d2a73c5e42f6a42ab6dc3342eb06649b56cc87
parent8ae56fe52587f1fc72bac2e6c33658802d57fb59 (diff)
Update attribute filter manager to pass on shrink flush targets.
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_test.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp48
2 files changed, 40 insertions, 13 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp
index 173d8dd2a2a..21761d412a2 100644
--- a/searchcore/src/tests/proton/attribute/attribute_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp
@@ -13,6 +13,7 @@ LOG_SETUP("attribute_test");
#include <vespa/searchcore/proton/attribute/attributemanager.h>
#include <vespa/searchcore/proton/attribute/filter_attribute_manager.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/integerbase.h>
#include <vespa/searchlib/common/idestructorcallback.h>
@@ -550,6 +551,10 @@ TEST_F("require that filter attribute manager can filter attributes", FilterFixt
f._filterMgr.getAttributeList(attrs);
EXPECT_EQUAL(1u, attrs.size());
EXPECT_EQUAL("a2", attrs[0]->getName());
+ searchcorespi::IFlushTarget::List targets = f._filterMgr.getFlushTargets();
+ EXPECT_EQUAL(2u, targets.size());
+ EXPECT_EQUAL("attribute.a2", targets[0]->getName());
+ EXPECT_EQUAL("attributeshrink.a2", targets[1]->getName());
}
TEST_F("require that filter attribute manager can return flushed serial number", FilterFixture)
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
index f2f37fa5c16..128cc74aee4 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
@@ -14,20 +14,38 @@ namespace proton {
namespace {
const vespalib::string FLUSH_TARGET_NAME_PREFIX("attribute.");
+const vespalib::string SHRINK_TARGET_NAME_PREFIX("attributeshrink.");
-bool isAttributeFlushTarget(const IFlushTarget::SP &flushTarget) {
- const vespalib::string &targetName = flushTarget->getName();
- if ((flushTarget->getType() != IFlushTarget::Type::SYNC) ||
- (flushTarget->getComponent() != IFlushTarget::Component::ATTRIBUTE)) {
- return false;
+class FlushTargetFilter
+{
+ const vespalib::string &_prefix;
+ const IFlushTarget::Type _type;
+public:
+ FlushTargetFilter(const vespalib::string &prefix, IFlushTarget::Type type)
+ : _prefix(prefix),
+ _type(type)
+ {
}
- return (targetName.substr(0, FLUSH_TARGET_NAME_PREFIX.size()) == FLUSH_TARGET_NAME_PREFIX);
-}
-vespalib::string attributeFlushTargetAttributeName(const IFlushTarget::SP &flushTarget) {
- const vespalib::string &targetName = flushTarget->getName();
- return targetName.substr(FLUSH_TARGET_NAME_PREFIX.size());
-}
+ ~FlushTargetFilter() { }
+
+ bool match(const IFlushTarget::SP &flushTarget) const {
+ const vespalib::string &targetName = flushTarget->getName();
+ if ((flushTarget->getType() != _type) ||
+ (flushTarget->getComponent() != IFlushTarget::Component::ATTRIBUTE)) {
+ return false;
+ }
+ return (targetName.substr(0, _prefix.size()) == _prefix);
+ }
+
+ vespalib::string attributeName(const IFlushTarget::SP &flushTarget) {
+ const vespalib::string &targetName = flushTarget->getName();
+ return targetName.substr(_prefix.size());
+ }
+};
+
+FlushTargetFilter syncFilter(FLUSH_TARGET_NAME_PREFIX, IFlushTarget::Type::SYNC);
+FlushTargetFilter shrinkFilter(SHRINK_TARGET_NAME_PREFIX, IFlushTarget::Type::GC);
}
@@ -72,8 +90,12 @@ FilterAttributeManager::getFlushTargets() const {
std::vector<searchcorespi::IFlushTarget::SP> list;
list.reserve(completeList.size());
for (const auto &flushTarget : completeList) {
- if (isAttributeFlushTarget(flushTarget)) {
- if (acceptAttribute(attributeFlushTargetAttributeName(flushTarget))) {
+ if (syncFilter.match(flushTarget)) {
+ if (acceptAttribute(syncFilter.attributeName(flushTarget))) {
+ list.push_back(flushTarget);
+ }
+ } else if (shrinkFilter.match(flushTarget)) {
+ if (acceptAttribute(shrinkFilter.attributeName(flushTarget))) {
list.push_back(flushTarget);
}
}