Skip to content
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

Selector explore implementation #402

Merged
merged 10 commits into from
May 11, 2020
Merged

Conversation

austinabell
Copy link
Contributor

Summary of changes
Changes introduced in this pull request:

  • Logic for exploring selectors for progressing with traversing the ipld. I'm closely matching go-prime-ipld for now, but will likely change it in the next PR when I implement the last part of this (traversal) and have full functionality tested

I wrote the tests in json with a runner to be able to test against go impl and provide a language agnostic test suite (I believe JS selectors are in progress rn too)

#241 for reference to spec and go impl

Reference issue to close (if applicable)

Closes

Other information and links

Copy link
Contributor

@timvermeulen timvermeulen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Austin! Understandable that you closely follow the Go implementation, though the interests/explore setup seems a bit convoluted on first readthrough. I think we'll probably end up with more clones (of Selector) than necessary because of this. Might be interesting to experiment with this after implementation/testing is done.

ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
ipld/src/selector/mod.rs Outdated Show resolved Hide resolved
@austinabell
Copy link
Contributor Author

Looks good Austin! Understandable that you closely follow the Go implementation, though the interests/explore setup seems a bit convoluted on first readthrough. I think we'll probably end up with more clones (of Selector) than necessary because of this. Might be interesting to experiment with this after implementation/testing is done.

Yeah that was what I mentioned I was going to do, I don't like the current setup but going to wait until after full functionality tests before refactoring. I have some ideas but counterproductive to make now since we need to match the specific implementation in go

pub fn explore(self, _ipld: &Ipld, _p: &PathSegment) -> Option<Selector> {
// TODO
todo!()
pub fn explore(self, ipld: &Ipld, p: &PathSegment) -> Option<Selector> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, I only had a question on is selector a heavy enum? If the answer is yes what do you think about a reference?

It would also be interested(although abit premature right now) to see selector implement an iterator so that we could use it more lazily

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure what you mean by heavy enum, care to elaborate? Yeah it would definitely be a more idiomatic interface to have this as an iterator, but I will hold off until the functionality is fully tested (in next PR). Great suggestion!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been more clear sorry! Something that occupies a lot of data, I guess what I am getting at is asking if the clones are going to be expensive but then again that is also a premature optimization

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in practice it'll be very small (depends on the construction of the selector) but since it's recursive, there is no cap on the size.

Unfortunately the clones are intended (as far as I can see) because of the certain branches which would modify selectors with requiring the previous to not be mutated. This is something I will explore very in depth to make sure there is not a more efficient way around this once I have a testsuite verifying all functionality.

@austinabell austinabell merged commit 91a7e65 into master May 11, 2020
@austinabell austinabell deleted the austin/ipld/selectorexplore branch May 11, 2020 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants