Coder Social home page Coder Social logo

Comments (5)

vweevers avatar vweevers commented on May 28, 2024

That's reasonable. Would only require work in the constructor.

Slightly easier to achieve in abstract-level because its db.sublevel() method has less overloads. There it could look like db.sublevel(['foo', bar']) as a shortcut for db.sublevel('foo').sublevel('bar').

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

Yea that would be useful, I was also wondering why it requires await or a callback to create a sublevel, when sublevels are just objects, and don't involve any changes to the DB.

In some cases, I have functions that will just create iterators directly to a specific sublevel, and I'm wondering about the performance impact of creating 3/4 deep sublevels every time I call that function.

from subleveldown.

vweevers avatar vweevers commented on May 28, 2024

I was also wondering why it requires await

It doesn't. Can you share a snippet of code where you need await?

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

I had to do it in #109. That's the code I'm using to open sublevels: #109 (comment)

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 28, 2024

Using my sublevel opener above, creating deeply nested sublevels right now costs quite a significant amount of time. My benchmarks show:

  create 1 sublevels:
    87 320 ops/s, ±0.79%   | fastest

  create 2 sublevels:
    45 325 ops/s, ±0.55%   | 48.09% slower

  create 3 sublevels:
    30 294 ops/s, ±0.39%   | 65.31% slower

  create 4 sublevels:
    22 764 ops/s, ±2.34%   | slowest, 73.93% slower

  get via sublevel:
    25 055 ops/s, ±1.36%   | 71.31% slower

  get via key path concatenation:
    54 992 ops/s, ±2.68%   | 37.02% slower

Basically it seems like db.sublevel(['foo', bar']) would be implemented efficiently as db.sublevel('foo!bar') so that the key path is just concatenated rather than creating intermediate sublevel objects.

Right now ! is not even allowed in the parameter due to #111 , so this would have be supported internal to subleveldown.

from subleveldown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.