-
Notifications
You must be signed in to change notification settings - Fork 26
Consolidate index metadata extraction and prepare for nameservice-based index tracking #1146
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
| (ns fluree.db.index.metadata | ||
| (:require [fluree.db.constants :as const] | ||
| [fluree.db.util :as util :refer [get-first get-first-value]])) | ||
|
|
||
| #?(:clj (set! *warn-on-reflection* true)) | ||
|
|
||
| (defn index-metadata | ||
| "Returns a canonical index metadata map from either an internal commit map | ||
| or an expanded JSON-LD commit. The result is either nil (no index) or | ||
| {:address <string> :t <int>}. | ||
|
|
||
| Accepts either: | ||
| - Internal commit map: {:index {:address <addr> :data {:t <int>}}} | ||
| - Expanded JSON-LD commit: f:index → { f:address, f:data → { f:t }}" | ||
| [commit-or-jsonld] | ||
| (let [internal-address (get-in commit-or-jsonld [:index :address]) | ||
| internal-t (get-in commit-or-jsonld [:index :data :t])] | ||
| (if (or internal-address internal-t) | ||
| (when internal-address | ||
| {:address internal-address | ||
| :t internal-t}) | ||
| (let [idx (get-first commit-or-jsonld const/iri-index) | ||
| jsonld-addr (some-> idx (get-first-value const/iri-address)) | ||
| jsonld-data (get-first idx const/iri-data) | ||
| jsonld-t (some-> jsonld-data (get-first-value const/iri-fluree-t))] | ||
| (when jsonld-addr | ||
| {:address jsonld-addr | ||
| :t jsonld-t}))))) | ||
|
|
||
| (defn index-address | ||
| "Returns the index address from a commit map or JSON-LD commit, or nil." | ||
| [commit-or-jsonld] | ||
| (some-> (index-metadata commit-or-jsonld) :address)) | ||
|
|
||
| (defn index-t | ||
| "Returns the index t from a commit map or JSON-LD commit, or nil." | ||
| [commit-or-jsonld] | ||
| (some-> (index-metadata commit-or-jsonld) :t)) | ||
|
|
||
|
|
This file contains hidden or 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 hidden or 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.
Right now we broadcast new indexes by publishing a new commit that includes an updated index map. I agree that we shouldn't overload these methods and that the latest commit and latest index should live in different data structures on the nameservice.
Does this pr add another way to publish new indexes since the index information is now stripped from the commit document?
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.
It was already ignored in the commit -- during load it gets it from the nameservice. So the commit index reference is not used at all.