-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add ordering option to getPath #19
Conversation
const search = options.search || breadthFirstSearch() | ||
const search = options.search || blockLinks() |
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.
Ah right, the half-formed idea here was that the search
fn could be used to let a caller pass in a stateful depth first search equivalent to the default "just return all the links in the current block", but i didn't try and implement it to try out that idea.
...all i really needed at the time was a way to pass in a rule for filtering out some links so i could implement car-scope: file dag-scope: entity for a hamt and got carried away.
search
could go away in favour of linkFilter: ([name, cid]) => boolean
or similar, and we could just have this get fn always do depth first. There was no strong reason for the previous default, and we can return depth-first for rnd
as well.
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.
news just in! the transform
function used here doesn't guarantee order of results!
https://github.com/web3-storage/dagula/blob/ceca20a7da7f976777d4e77297eb6aada45f67d9/index.js#L52
Order is determined by when func resolves.
– https://github.com/bustle/streaming-iterables#transform
so for us to guarantee dfs
that would need to switch out for parallelMap
. I didn't check that when I named the default search impl breadth-first, so it was already misleading.
@olizilla used parallelMap for DFS. left transform in place otherwise -- I dunno if the speed optimization matters but I figured as little substantive change to the existing workflow the better :) |
e4fdc87
to
4abb6ca
Compare
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 LGTM but we should remove the search
param (as mentioned here), switch to dfs
by default and rename carScope
to dagScope
before release.
I'll send a follow up PR(s) to get those things done.
@hannahhoward thank you for the contribution ❤️ |
🤖 I have created a release *beep* *boop* --- ## [7.0.0](v6.0.2...v7.0.0) (2023-05-18) ### ⚠ BREAKING CHANGES * remove search option ([#23](#23)) * rename dagScope to carScope ([#21](#21)) ### Features * add ordering option to getPath ([#19](#19)) ([ad25001](ad25001)) * support yamux muxer ([#11](#11)) ([24ef997](24ef997)) ### Bug Fixes * rename dagScope to carScope ([#21](#21)) ([497cc90](497cc90)) ### refactor * remove search option ([#23](#23)) ([9ede86f](9ede86f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Goals
This adds support for depth first traversals to Dagula. It's designed to be in conformance with ipfs/specs#412.
(will update if parameter names change)
Implementation
get
, using recursion for depth-first-search