-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33167 from vespa-engine/toregge/add-maintenance-j…
…ob-for-clearing-imported-attribute-search-cache Add maintenance job for clearing imported attribute search cache.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
searchcore/src/vespa/searchcore/proton/server/clear_imported_attribute_search_cache_job.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
|
||
#include "clear_imported_attribute_search_cache_job.h" | ||
#include <vespa/searchcore/proton/attribute/i_attribute_manager.h> | ||
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> | ||
#include <vespa/searchlib/attribute/imported_attribute_vector.h> | ||
|
||
using search::attribute::ImportedAttributeVector; | ||
|
||
namespace proton { | ||
|
||
ClearImportedAttributeSearchCacheJob::ClearImportedAttributeSearchCacheJob(std::shared_ptr<IAttributeManager> mgr, | ||
vespalib::duration visibilityDelay) | ||
: IMaintenanceJob("clear_imported_attribute_search_cache", visibilityDelay, visibilityDelay), | ||
_mgr(std::move(mgr)) | ||
{ | ||
} | ||
|
||
bool | ||
ClearImportedAttributeSearchCacheJob::run() | ||
{ | ||
auto* imported_attributes_repo = _mgr->getImportedAttributes(); | ||
if (imported_attributes_repo != nullptr) { | ||
std::vector<std::shared_ptr<ImportedAttributeVector>> importedAttrs; | ||
imported_attributes_repo->getAll(importedAttrs); | ||
for (const auto &attr : importedAttrs) { | ||
attr->clearSearchCache(); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
void | ||
ClearImportedAttributeSearchCacheJob::onStop() | ||
{ | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
searchcore/src/vespa/searchcore/proton/server/clear_imported_attribute_search_cache_job.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
|
||
#pragma once | ||
|
||
#include "i_maintenance_job.h" | ||
#include <vespa/vespalib/util/time.h> | ||
|
||
namespace proton { | ||
|
||
struct IAttributeManager; | ||
|
||
/** | ||
* Job that regularly clears the search cache for imported attributes. | ||
*/ | ||
class ClearImportedAttributeSearchCacheJob : public IMaintenanceJob | ||
{ | ||
std::shared_ptr<IAttributeManager> _mgr; | ||
public: | ||
ClearImportedAttributeSearchCacheJob(std::shared_ptr<IAttributeManager> mgr, vespalib::duration visibilityDelay); | ||
bool run() override; | ||
void onStop() override; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters