Skip to content

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

Merged
warpfork merged 1 commit into
masterfrom
traversal-select-links
Nov 14, 2020
Merged

Introduce traversal function that selects links out of a tree.#110
warpfork merged 1 commit into
masterfrom
traversal-select-links

Conversation

@warpfork

Copy link
Copy Markdown
Collaborator

Like it says on the tin.

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

@warpfork warpfork requested a review from ribasushi November 13, 2020 21:42
@warpfork

warpfork commented Nov 13, 2020

Copy link
Copy Markdown
Collaborator Author

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.

@ribasushi ribasushi left a comment

Copy link
Copy Markdown
Contributor

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