Comments (15)
@Matt-Esch Which methods are you talking about, specifically?
from node-lmdb.
@russtee I'm looking forward to getting your feedback about this as well. :)
from node-lmdb.
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.
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.
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.
What do you mean? Can you post some example code of how you would be comfortable using it?
from node-lmdb.
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.
But then this would make it impossible to see the current key.
from node-lmdb.
We use the value from goToNext etc. as we always call that prior.
from node-lmdb.
I see. Okay, let me think about it a bit more and I'll get back to you guys.
from node-lmdb.
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.
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.
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.
@Venemo You're quite welcome.
from node-lmdb.
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)
- {Question] Environment size and Delete HOT 2
- Modifying unsafe buffers in-place leads to segmentation fault HOT 3
- Build fails with Node 14.15.0, the new LTS release HOT 2
- Asynchronous batch write data types HOT 6
- Process memory balloons on create/close of multiple environments HOT 22
- Create github discussion board or slack for general questions
- Incremental backup and restore HOT 1
- Missing tags and releases on github?
- LMDB file gets created with maximum size when activating useWritemap option HOT 2
- Build errors under Node 16.1.0 HOT 9
- mdb_copy: copying failed, error -30784 (MDB_INCOMPATIBLE: Operation and DB incompatible, or DB flags HOT 2
- mkdirp throws error on running benchmark
- Use of deprecated Buffer in example code
- node-gyp rebuild error HOT 17
- property name readonly in `index.d.ts` should be readOnly HOT 1
- test: the worker thread in fact has no chance of receiving messages from the main thread
- In README.md you forgot to specify which kinds of "numbers" are supported HOT 1
- Append mode is not working correctly for string keys with character codes larger than 255 (MDB_KEYEXIST error) HOT 3
- Automatic map resizing HOT 3
- Program exit on Env.open HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-lmdb.