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

Fix ydn-db#90: traverse() call func parameter even if tree is empty. #1

Merged
merged 2 commits into from
Oct 20, 2016

Conversation

mehdirande
Copy link
Contributor

In traverse, and reverse Traverse methods, on an empty tree, or if there is no node with value >= to the start value, the func parameter is not called.
In the scan method in the same context, func method is called.
In ydn.db.core.req.SimpleCursor, if the func parameter of buffer is not called the onSuccess callback is never called and the result state is never set to 'ready'.
This fix call func function with a null parameter if tree is empty or if there is no node with value >= to the start value.

Calling func with null parameter seems to be the way to go since the last line of traverse is already "func(null); // let know, no more traversal" So calling func with a null parameter should already be supported and means that there is no result to the request.

In traverse, and reverse Traverse methods, on an empty tree, or if there
is no node with value >= to the start value, the func parameter is not called.
In the scan method in the same context, func method is called.
In ydn.db.core.req.SimpleCursor, if the func parameter of buffer is not
called the onSuccess callback is never called and the result state is
never set to 'ready'.
This fix call func function with a null parameter if tree is empty or if
there is no node with value >= to the start value.
ada1971 was a misfire, sorry, this commit add call to func in traverse
method and use null parameter instead of undefined. Using null seems to
be more consistent with the last line of traverse and reverseTraverse
methods.
@mehdirande
Copy link
Contributor Author

Sorry the PR was incomplete, i messed up with my local / remote branch. 047795b add the call to func in traverse and use null parameter as described in the PR initial comment.

@yathit yathit merged commit fa217e7 into yathit:master Oct 20, 2016
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