Giter Site home page Giter Site logo

Comments (15)

Venemo avatar Venemo commented on August 25, 2024

@Matt-Esch Which methods are you talking about, specifically?

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

@russtee I'm looking forward to getting your feedback about this as well. :)

from node-lmdb.

russtee avatar russtee commented on August 25, 2024

We use lmdb synchronously for all operations whenever possible and the extra code overhead to handle the cursor callbacks seems unnecessary.

LMDB is very fast especially when running on SSD's.

That said on slower machines callbacks could be handy and would fit well into the node streams system for iteration operations.

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

One way to go about this is to create a JavaScript object and return that instead of calling a callback. The proposed object could have a key and data property. Would something like this suit your needs?

For example,

var x = cursor.getCurrentString();
console.log(x.key, x.data);

from node-lmdb.

russtee avatar russtee commented on August 25, 2024

that would work. However do I actually need the key as I would most likely already have it from the cursor iteration function?

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

What do you mean? Can you post some example code of how you would be comfortable using it?

from node-lmdb.

russtee avatar russtee commented on August 25, 2024
for (var c = cursor.goToFirst(); c; c=cursor.goToNext()) {
   var val = cursor.getCurrentBinary();

As a hack/test I changed my local copy of the library to return the value instead of the key when 'convertFunc' was set.

Probably not they way you would want to do it but it seems to work and solves the problem we have.

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

But then this would make it impossible to see the current key.

from node-lmdb.

russtee avatar russtee commented on August 25, 2024

We use the value from goToNext etc. as we always call that prior.

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

I see. Okay, let me think about it a bit more and I'll get back to you guys.

from node-lmdb.

rneilson avatar rneilson commented on August 25, 2024

Let me +1 just returning the value from getCurrentWhichever() -- you'll always have the current key as the return value of cursor.goToWhichever(), and the callback makes any iteration (by loop, or especially by forEach(), map(), reduce(), etc) much clumsier.

from node-lmdb.

rneilson avatar rneilson commented on August 25, 2024

I've submitted PR #78, which I think is a workable compromise. The callback interface is still present, if you need both key and value together, but getCurrentString() and friends return the value instead of the key regardless, meaning they can be used without a callback if desired. Also, there's no extra conversion overhead, since I merely relocated the call to convertFunc(cw->data).

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

Thank you @rneilson for your work. This is much better than what we had before, so it's a step in the right direction. :)

from node-lmdb.

rneilson avatar rneilson commented on August 25, 2024

@Venemo You're quite welcome.

from node-lmdb.

Venemo avatar Venemo commented on August 25, 2024

I believe we can agree to close this issue now, the current API doesn't require the use of callback anymore.

from node-lmdb.

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.