summaryrefslogtreecommitdiffstats
path: root/common/storage_lmdb.cpp
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-11 00:53:25 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-11 01:02:59 +0100
commitf67cd267cfded13ce5dbf235e2c91036b8d52cfb (patch)
tree2bdd0e51bc0b115ec442b9d02a37225f204b8272 /common/storage_lmdb.cpp
parent5cb0aa5f9dd9973f9dcf091f767a5af7f61ed51f (diff)
downloadsink-f67cd267cfded13ce5dbf235e2c91036b8d52cfb.tar.gz
sink-f67cd267cfded13ce5dbf235e2c91036b8d52cfb.zip
keep the databases separate
otherwise, to keep all the dbs in the same file we need to call mdb_env_set_maxdbs before mdb_env_open ... and even then the docs say: "Currently a moderate number of slots are cheap but a huge number gets expensive: 7-120 words per transaction, and every mdb_dbi_open() does a linear search of the opened slots." Ugh. that and the mem mapping probably gets screwed oever .. whatever. this way hawd works again :)
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r--common/storage_lmdb.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp
index 9832853..d5c70eb 100644
--- a/common/storage_lmdb.cpp
+++ b/common/storage_lmdb.cpp
@@ -36,14 +36,15 @@ Storage::Private::Private(const QString &s, const QString &n, AccessMode m)
36 readTransaction(false), 36 readTransaction(false),
37 firstOpen(true) 37 firstOpen(true)
38{ 38{
39 const QString fullPath(storageRoot + '/' + name);
39 QDir dir; 40 QDir dir;
40 dir.mkdir(storageRoot); 41 dir.mkdir(fullPath);
41 42
42 //create file 43 //create file
43 if (mdb_env_create(&env)) { 44 if (mdb_env_create(&env)) {
44 // TODO: handle error 45 // TODO: handle error
45 } else { 46 } else {
46 int rc = mdb_env_open(env, storageRoot.toStdString().data(), 0, 0664); 47 int rc = mdb_env_open(env, fullPath.toStdString().data(), 0, 0664);
47 48
48 if (rc) { 49 if (rc) {
49 std::cerr << "mdb_env_open: " << rc << " " << mdb_strerror(rc) << std::endl; 50 std::cerr << "mdb_env_open: " << rc << " " << mdb_strerror(rc) << std::endl;
@@ -335,13 +336,13 @@ void Storage::readAll(const std::function<bool(void *key, int keySize, void *dat
335 336
336qint64 Storage::diskUsage() const 337qint64 Storage::diskUsage() const
337{ 338{
338 QFileInfo info(d->storageRoot + "/data.mdb"); 339 QFileInfo info(d->storageRoot + '/' + d->name + "/data.mdb");
339 return info.size(); 340 return info.size();
340} 341}
341 342
342void Storage::removeFromDisk() const 343void Storage::removeFromDisk() const
343{ 344{
344 QDir dir(d->storageRoot); 345 QDir dir(d->storageRoot + '/' + d->name);
345 dir.remove("data.mdb"); 346 dir.remove("data.mdb");
346 dir.remove("lock.mdb"); 347 dir.remove("lock.mdb");
347} 348}