-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gms): Write back lineage search results to in-memory cache bound to feature flag #6006
Merged
shirshanka
merged 4 commits into
datahub-project:master
from
RyanHolstien:piyushn/fix_lineage_search_caching
Sep 22, 2022
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2a8dd02
fix(gms) Write back lineage search results to in-memory cache
piyushn-stripe 38a6ea6
add feature flag for enabling cache
RyanHolstien 46ea793
review comments: add timestamp to cache entry and warn
RyanHolstien e0434ab
checkstyle
RyanHolstien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -39,7 +39,9 @@ | |
public class LineageSearchService { | ||
private final SearchService _searchService; | ||
private final GraphService _graphService; | ||
@Nullable | ||
private final Cache cache; | ||
private final boolean cacheEnabled; | ||
|
||
private static final String DEGREE_FILTER = "degree"; | ||
private static final String DEGREE_FILTER_INPUT = "degree.keyword"; | ||
|
@@ -71,10 +73,14 @@ public LineageSearchResult searchAcrossLineage(@Nonnull Urn sourceUrn, @Nonnull | |
@Nonnull List<String> entities, @Nullable String input, @Nullable Integer maxHops, @Nullable Filter inputFilters, | ||
@Nullable SortCriterion sortCriterion, int from, int size) { | ||
// Cache multihop result for faster performance | ||
EntityLineageResult lineageResult = cache.get(Pair.of(sourceUrn, direction), EntityLineageResult.class); | ||
EntityLineageResult lineageResult = cacheEnabled ? cache.get(Pair.of(sourceUrn, direction), EntityLineageResult.class) | ||
: null; | ||
if (lineageResult == null) { | ||
maxHops = maxHops != null ? maxHops : 1000; | ||
lineageResult = _graphService.getLineage(sourceUrn, direction, 0, MAX_RELATIONSHIPS, maxHops); | ||
if (cacheEnabled) { | ||
cache.put(Pair.of(sourceUrn, direction), lineageResult); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we drop in the current timestamp into the value section?
that way we can always know when a cache entry was inserted into the cache, at least for debugging purposes. |
||
} | ||
} | ||
|
||
// Filter hopped result based on the set of entities to return and inputFilters before sending to search | ||
|
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a log.warn here if we found something in the cache and if the insert timestamp is from a long time ago (we can default to hard-coded 1 hour for this PR).