-
Notifications
You must be signed in to change notification settings - Fork 94
feat: enable handling of URNs alongside URIs #522
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc8fc8a
chore: bump substrait version to v0.75.0
benbellick 3ee953c
feat(core): uri -> urn + add urn validation
benbellick c7639b3
refactor: move BidiMap to another file to be shared
benbellick 7fd825a
feat(core): graceful uri <-> urn handling
benbellick 30b2df8
fix: fix compilation by using DEFAULT_COLLECTION
benbellick 89ce8ec
fix: address @vbarua comments
benbellick 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
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,65 @@ | ||
| package io.substrait.extension; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| /** We don't depend on guava... */ | ||
| public class BidiMap<T1, T2> { | ||
|
benbellick marked this conversation as resolved.
|
||
| private final Map<T1, T2> forwardMap; | ||
| private final Map<T2, T1> reverseMap; | ||
|
|
||
| BidiMap(Map<T1, T2> forwardMap) { | ||
| this.forwardMap = forwardMap; | ||
| this.reverseMap = new HashMap<>(); | ||
| for (Map.Entry<T1, T2> entry : forwardMap.entrySet()) { | ||
| reverseMap.put(entry.getValue(), entry.getKey()); | ||
| } | ||
| } | ||
|
|
||
| BidiMap() { | ||
| this.forwardMap = new HashMap<>(); | ||
| this.reverseMap = new HashMap<>(); | ||
| } | ||
|
|
||
| T2 get(T1 t1) { | ||
| return forwardMap.get(t1); | ||
| } | ||
|
|
||
| T1 reverseGet(T2 t2) { | ||
| return reverseMap.get(t2); | ||
| } | ||
|
|
||
| /** | ||
| * Associates the specified values in both directions. Throws if either value is already mapped to | ||
| * a different value. | ||
| */ | ||
| void put(T1 t1, T2 t2) { | ||
| T2 existingForward = forwardMap.get(t1); | ||
| T1 existingReverse = reverseMap.get(t2); | ||
|
|
||
| if (existingForward != null && !existingForward.equals(t2)) { | ||
| throw new IllegalArgumentException("Key already exists in map with different value"); | ||
| } | ||
| if (existingReverse != null && !existingReverse.equals(t1)) { | ||
| throw new IllegalArgumentException("Key already exists in map with different value"); | ||
| } | ||
|
|
||
| forwardMap.put(t1, t2); | ||
| reverseMap.put(t2, t1); | ||
| } | ||
|
|
||
| void merge(BidiMap<T1, T2> other) { | ||
| for (Map.Entry<T1, T2> entry : other.forwardEntrySet()) { | ||
| put(entry.getKey(), entry.getValue()); | ||
| } | ||
| } | ||
|
|
||
| Set<Map.Entry<T1, T2>> forwardEntrySet() { | ||
| return forwardMap.entrySet(); | ||
| } | ||
|
|
||
| Set<Map.Entry<T2, T1>> reverseEntrySet() { | ||
| return reverseMap.entrySet(); | ||
| } | ||
| } | ||
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
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.
This already existed in ExtensionCollector.java as a private class. Instead, I have moved it into a separate file so that we can also leverage it for a bijection between uris and urns for migration purposes.