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

Range skips zero in iterator. #1

Closed
nodech opened this issue Apr 2, 2018 · 2 comments
Closed

Range skips zero in iterator. #1

nodech opened this issue Apr 2, 2018 · 2 comments

Comments

@nodech
Copy link
Member

nodech commented Apr 2, 2018

DB Layout for key:

  e: bdb.key('e', ['uint32']),

Range Usage:

    return db.range({
      gte: layout.e.min(),
      lte: layout.e.max(),
      parse: key => layout.e.parse(key)
    });

If there's 0 written in that field, iterator.parse skips that value.
Issue comes from here: https://github.com/bcoin-org/bdb/blob/master/lib/db.js#L1162

We need some convention, what you need to return from parser to skip that value.

E.g. null or undefined.

It will probably skip zero string and other falsy values )))

@chjj

I can just return buffers and parse on my own. but still I think we need some convention when to skip in iterator.

@chjj
Copy link
Member

chjj commented Apr 6, 2018

I would say if (item != null) is the answer (not null or undefined). Will fix.

@nodech
Copy link
Member Author

nodech commented Apr 6, 2018

cool. I just didn't decide on convention or I would make PR.

@chjj chjj closed this as completed in fac4bf0 Apr 6, 2018
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

No branches or pull requests

2 participants