Skip to content

what are the different between them #53

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

Closed
AdaJass opened this issue Nov 26, 2022 · 4 comments
Closed

what are the different between them #53

AdaJass opened this issue Nov 26, 2022 · 4 comments

Comments

@AdaJass
Copy link

AdaJass commented Nov 26, 2022

I'm trying to use levelDB in my program. You have done lots of brilliant jobs to introduce levelDB to nodejs. But I found the repository make me a little confuse. Maybe there should be a graph to make it straight to users which will explain the relationship between them. It just my little suggestion.

I am not sure but I guess their relationships should be like this: the abstract is the version completely written by asyn/await version of js, the leveldown is wrap with convenient interface upon the c++ binary leveldb, and the levelup introduce nodejs promise like feature to leveldown.

@vweevers
Copy link
Member

vweevers commented Nov 26, 2022

The backstory of abstract-level can be found in the FAQ: What is abstract-level?

The short version, that I hope will answer your more specific questions, is this:

  • LevelDB is a C++ project by Google. We're not affiliated with Google.
  • leveldown was a Node.js binding for LevelDB
  • levelup wrapped leveldown in a more convenient interface, later indeed including promises
  • leveldown and levelup are now legacy modules
  • classic-level is effectively a merger of leveldown and levelup. It's thus a binding to LevelDB with a convenient interface. I say effectively because the real story is more nuanced and can be found in the FAQ that I mentioned.

If I instead were to explain the relationships to someone that's new to Level (and thus doesn't have to know about leveldown and levelup), then I would say, using OOP terms:

  • AbstractLevel is an abstract class for a lexicographically sorted key-value database. It handles state, encodings and other generic behaviors that can be implemented in pure JavaScript.
  • ClassicLevel implements that abstract class, using LevelDB for storage.

@vweevers
Copy link
Member

vweevers commented Nov 26, 2022

In case your question is, should I use classic-level or leveldown? Then the answer is classic-level, without a doubt.

Legacy modules like leveldown are no longer maintained. They work perfectly fine, but won't get new features, performance improvements or other updates. Feature-wise, classic-level has the following additional features:

  • Sublevels
  • Support of Uint8Array
  • iterator.nextv() and iterator.all()
  • Built-in TypeScript types

And more features are coming soon:

@AdaJass
Copy link
Author

AdaJass commented Nov 27, 2022

  • AbstractLevel is an abstract class for a lexicographically sorted key-value database. It handles state, encodings and other generic behaviors that can be implemented in pure JavaScript.
  • ClassicLevel implements that abstract class, using LevelDB for storage.

Thanks a lot, I saw the compare with levelDB and rocksDB in internet, it is said rocksDb is the better one. By your mention, I could write code with abstractlevel or classiclevel, but if i want in the future, i could just simply replace the require/import package, it is that right?

will you plan to upgrade the rocksdb package to the abstractlevel style?

@vweevers
Copy link
Member

We don't have a (new) RocksDB binding yet, see Level/abstract-level#14. I can't say when that will happen, it's low priority atm.

But yes, once that's available, you could replace const { ClassicLevel } = require('classic-level') with const { RocksLevel } = require('rocks-level') and you'll get the same interface.

PS. "Better" is subjective. LevelDB is a good choice (and the most popular among Level users) when you want small binaries, a wide range of supported platforms, and good general performance (that isn't optimized for one particular scenario like SSDs). RocksDB does have more features, but the majority are not exposed in our bindings because those features don't fit in the abstract-level interface and RocksDB receives less attention from us.

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