GithubHelp home page GithubHelp logo

Comments (5)

hoytech avatar hoytech commented on September 23, 2024

Hi! In what way isn't it working right? Do you have a complete test-case we can try?

from lmdbxx.

matija-kovacek-1995 avatar matija-kovacek-1995 commented on September 23, 2024

The code I wrote above is the one I tired. Could be that I am doing something wrong. The data file on the hard disk does not grow bigger. If I use database handle to write into database 1000000 records the file size is about 20 MB, while if I use cursor_put with 1000000 records and flag MDB_MULTIPLE I get an data file of 12KB, and it is empty when I try and read it. I use the three functions below to test it. Before calling each function I close the application.
I guess the repro steps would be:

  1. Create database One at first directory.
  2. Write 1000000 ints into it using databasehandle.put.
  3. Observe the database size.
  4. Read the data from the database.
  5. Create database Two at second directory.
  6. Write 1000000 ints into it using cursor_put and MDB_MULTIPLE
  7. Notice that database size is different
  8. On reading data base it appears to be empty.

I will also attach the functions I use to do this below again it could be just miss usage due to me not understanding something.
LMDB_TESTS.txt

from lmdbxx.

hoytech avatar hoytech commented on September 23, 2024
  • You don't call wtxn.commit() in cursorPut() so nothing is actually committed
  • Once you fix that, I don't think this line is doing what you think:
    std::vector rawData(1000000, std::rand());
    All the elements in the array will contain the same value, so you are setting the same key/value over and over again. Try putting this line after that to ensure they are all different values:
    for (size_t i = 0; i < rawData.size(); i++) rawData[i] = (int)i;
  • Not related, but *index after this will likely result in unaligned memory access:
    const mdb_size_t* index = reinterpret_cast<mdb_size_t*>(key.data());
    ... which may or may not matter depending on your processor. An easier approach is described in my C++17 fork of lmdbxx which I suggest you check out since this one isn't maintained: https://github.com/hoytech/lmdbxx/

from lmdbxx.

matija-kovacek-1995 avatar matija-kovacek-1995 commented on September 23, 2024

Hi, thank you for your time. It works now and I will use the C++ 17 fork going forward.
Again, I am sorry I had to bother you with it next time I will be more careful what I am doing.

from lmdbxx.

hoytech avatar hoytech commented on September 23, 2024

Don't worry about it, I'm glad you got it working.

from lmdbxx.

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.