-
Notifications
You must be signed in to change notification settings - Fork 32
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
refactor(zql): callable relationships #3629
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bencher Report
Click to view all benchmark results
|
Bencher Report
Click to view all benchmark results
|
79f311f
to
e5f86e6
Compare
e5f86e6
to
2bcec65
Compare
2bcec65
to
da36f04
Compare
9df484d
to
19894b1
Compare
19894b1
to
9cc0cd8
Compare
e5d4576
to
cc73c6b
Compare
What's one more layer of indirection between friends 🙃 |
07dcb86
to
d74e321
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.
LGTM.
Doesn't look like much logic changed (except for exists and some wrapping of the relationship in join
with a lambda), mostly just changing how invocations of relationships work.
lmk if I missed a significant change.
*/ | ||
export type ChildChange = { | ||
type: 'child'; | ||
row: Row; | ||
node: Node; |
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.
🎉
Do we need to do something with FanIn/FanOut when it has no output? |
Good point... yeah I think my change is not quite right because I wasn't thinking about FanIn/FanOut... a single Filter shouldn't decide to drain the node because other Filter's may let it through... hmmm |
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.
yield node; | ||
} else { | ||
drainStreams(node); |
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.
oh yeah, I don't understand why we have to drainStreams
here and in filter
.
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 was an existing problem with cleanup, that I realized while updating tests for this change.
Cleanup is lazy/stream based so that it can be limited by take. Cleanup relies on something downstream draining the streams for the cleanup to actually happen.
If an operator filters out a node (as Exist or Filter does) that node is not going to reach the thing downstream that normally would drain the streams, and the cleanup for that part of the tree won't happen. The idea behind this change was to ensure the cleanup by draining the node's stream at the point it is filtered out.
My change is not quite right though, as now the node may get drained multiple times when we have a FanIn/FanOut as multiple filter/exists operators may filter it (each of them draining it), but then it may still get passed downstream if another branch does not filter it (for it to be drained another time).
Still thinking about how to address it.
cc @arv
The
Exist
operators#fetchNodeForRow
is quite expensive and is a work around for the fact thatNode
's relationships can only be consumed a single time. In order to read the relevant relationship,Exist
has to fetch from source the parentNode
. This fetch is pure overhead, we are fetching a row we already have.This change updates
Node
's relationships to be callable, so that they can be consumed multiple times.Node
's type changes fromto
This change also updates
ChildChange
to have anode: Node
rather than arow: Row
so that the relationships needed byExist
are also available onChildChange
. Now allChange
types useNode
rather thanRow
.Finally this addresses an issue with cleanup where Node's filtered by
Exists
orFilter
were not being drained (as they never reach view-apply-change which does the draining). Added draining to cleanup inExists
andFilter
forNode
s not yielded to downstream.