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

Introduce traversal function that selects links out of a tree. #110

Merged
merged 1 commit into from
Nov 14, 2020

Conversation

warpfork
Copy link
Collaborator

Like it says on the tin.

This is just a quick, simple, handy function to have on hand.

@warpfork
Copy link
Collaborator Author

warpfork commented Nov 13, 2020

It may be interesting to compare this to https://github.com/whyrusleeping/cbor-gen/blob/0b9f6c5fb1636544f94f5087817df99699de49ba/utils.go#L47 -- that function also plucks links out of a block. It's also probably faster and lower overhead if you didn't already otherwise need to parse the block, because it scans over the serial form and only bothers to create in-memory objects for the links. On the other hand, that function also only works with CBOR.

We might be able to create functions a bit closer to those semantics in a codec-agnostic way in go-ipld-prime in the future, too. Some of the tokenization reworking aims to get us closer to able to handle Data Model info as a stream without full tree reification. We'd need a fair amount of further rework to codec implementations to make that fly, though. (Stuff that's on the docket, but probably not landing "today".)

Regardless: this function that does operate on in-memory trees is still reasonable to have in the traversal package -- both immediately, because it's easy; and in the long run even if we did make stream methods with similar outputs, because which is useful is situationally dependent on how much parsing you may have already needed to do for other parts of the situation you're in.

Copy link
Contributor

@ribasushi ribasushi left a comment

Choose a reason for hiding this comment

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

LGTM! Agreed with motivation and limitations notes.

@warpfork warpfork merged commit 04afddf into master Nov 14, 2020
@warpfork warpfork deleted the traversal-select-links branch November 14, 2020 14:06
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants