-
Notifications
You must be signed in to change notification settings - Fork 22
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
json-ld response formatting #399
Merged
Merged
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 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
Oops, something went wrong.
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.
We're passing both the
context
value and the compacting functioncompact
here. Was there an issue with adding the new 2-arity function to compact data maps by accepting both a context and the data value that needs compacting?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.
The
json-ld/compact-fn
function take a context and optionally a "used-atom" to track which context entries are used. It then transforms the supplied context and closes over the result in order to do efficient compaction and returns a single-arity function that takes an iri.I considered adding another arity to the returned compact-fn that would accept a context along with the iri, but that forces us to re-transform the context for every compaction, an operation that can be quite costly if the context is large. So I elected to do the more clumsy approach of passing both.
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.
Now that I think about it, though, if we did go with the 2-arity compact-fn it would be called in multiple places with the same context, so if we added an LRU cache of size 1 in front of it that could make the code more elegant and not incur the penalty of re-processing the context for each compaction. Or just use a delay?
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.
The atom isn't used for any of the compacting functions in this pull request; it's only used for commits.
As I mentioned on our last call, I think we should define a new function that takes a context and data needed to be compacted using that context and returns the compacted data for these usages, and we should only pass the context through these call stacks, not any compacting functions.
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.
My understanding is that
compact
is called multiple times in the same call stack, and doing the work to compact is expensive, which is why we rely on thecompact-fn
to do the expensive work once.In the the
fluree.db.query.exec.select
namespace it looks like each of the different Selectors can callcompact
to format the results, and my understanding is that several Selectors may be called during one query. If that's the case, then re-creating thecompact-fn
for each of those calls could get expensive.But! My understanding of how Selectors work may be wrong - if only one of them is used than we would only have one compact-fn per query.
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.
No, your understanding is correct. I think we can leave the extra contexts in for now possibly to re-think how we do the compaction and expansion later.