aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
Diffstat (limited to 'external')
-rw-r--r--external/db_drivers/liblmdb/mdb_load.17
-rw-r--r--external/db_drivers/liblmdb/mdb_load.c46
-rw-r--r--external/easylogging++/easylogging++.cc16
-rw-r--r--external/easylogging++/easylogging++.h5
4 files changed, 67 insertions, 7 deletions
diff --git a/external/db_drivers/liblmdb/mdb_load.1 b/external/db_drivers/liblmdb/mdb_load.1
index 712ed0540..ede3702d9 100644
--- a/external/db_drivers/liblmdb/mdb_load.1
+++ b/external/db_drivers/liblmdb/mdb_load.1
@@ -37,6 +37,13 @@ option below.
.BR \-V
Write the library version number to the standard output, and exit.
.TP
+.BR \-a
+Append all records in the order they appear in the input. The input is assumed to already be
+in correctly sorted order and no sorting or checking for redundant values will be performed.
+This option must be used to reload data that was produced by running
+.B mdb_dump
+on a database that uses custom compare functions.
+.TP
.BR \-f \ file
Read from the specified file instead of from the standard input.
.TP
diff --git a/external/db_drivers/liblmdb/mdb_load.c b/external/db_drivers/liblmdb/mdb_load.c
index d1fda4bf5..797c2f979 100644
--- a/external/db_drivers/liblmdb/mdb_load.c
+++ b/external/db_drivers/liblmdb/mdb_load.c
@@ -37,6 +37,7 @@ static int Eof;
static MDB_envinfo info;
static MDB_val kbuf, dbuf;
+static MDB_val k0buf;
#ifdef _WIN32
#define Z "I"
@@ -285,10 +286,15 @@ badend:
static void usage(void)
{
- fprintf(stderr, "usage: %s [-V] [-f input] [-n] [-s name] [-N] [-T] dbpath\n", prog);
+ fprintf(stderr, "usage: %s [-V] [-a] [-f input] [-n] [-s name] [-N] [-T] dbpath\n", prog);
exit(EXIT_FAILURE);
}
+static int greater(const MDB_val *a, const MDB_val *b)
+{
+ return 1;
+}
+
int main(int argc, char *argv[])
{
int i, rc;
@@ -298,7 +304,8 @@ int main(int argc, char *argv[])
MDB_dbi dbi;
char *envname;
int envflags = 0, putflags = 0;
- int dohdr = 0;
+ int dohdr = 0, append = 0;
+ MDB_val prevk;
prog = argv[0];
@@ -306,19 +313,23 @@ int main(int argc, char *argv[])
usage();
}
- /* -f: load file instead of stdin
+ /* -a: append records in input order
+ * -f: load file instead of stdin
* -n: use NOSUBDIR flag on env_open
* -s: load into named subDB
* -N: use NOOVERWRITE on puts
* -T: read plaintext
* -V: print version and exit
*/
- while ((i = getopt(argc, argv, "f:ns:NTV")) != EOF) {
+ while ((i = getopt(argc, argv, "af:ns:NTV")) != EOF) {
switch(i) {
case 'V':
printf("%s\n", MDB_VERSION_STRING);
exit(0);
break;
+ case 'a':
+ append = 1;
+ break;
case 'f':
if (freopen(optarg, "r", stdin) == NULL) {
fprintf(stderr, "%s: %s: reopen: %s\n",
@@ -377,12 +388,17 @@ int main(int argc, char *argv[])
}
kbuf.mv_size = mdb_env_get_maxkeysize(env) * 2 + 2;
- kbuf.mv_data = malloc(kbuf.mv_size);
+ kbuf.mv_data = malloc(kbuf.mv_size * 2);
+ k0buf.mv_size = kbuf.mv_size;
+ k0buf.mv_data = (char *)kbuf.mv_data + kbuf.mv_size;
+ prevk.mv_size = 0;
+ prevk.mv_data = k0buf.mv_data;
while(!Eof) {
MDB_val key, data;
int batch = 0;
flags = 0;
+ int appflag;
if (!dohdr) {
dohdr = 1;
@@ -400,6 +416,11 @@ int main(int argc, char *argv[])
fprintf(stderr, "mdb_open failed, error %d %s\n", rc, mdb_strerror(rc));
goto txn_abort;
}
+ if (append) {
+ mdb_set_compare(txn, dbi, greater);
+ if (flags & MDB_DUPSORT)
+ mdb_set_dupsort(txn, dbi, greater);
+ }
rc = mdb_cursor_open(txn, dbi, &mc);
if (rc) {
@@ -418,7 +439,20 @@ int main(int argc, char *argv[])
goto txn_abort;
}
- rc = mdb_cursor_put(mc, &key, &data, putflags);
+ if (append) {
+ appflag = MDB_APPEND;
+ if (flags & MDB_DUPSORT) {
+ if (prevk.mv_size == key.mv_size && !memcmp(prevk.mv_data, key.mv_data, key.mv_size))
+ appflag = MDB_APPENDDUP;
+ else {
+ memcpy(prevk.mv_data, key.mv_data, key.mv_size);
+ prevk.mv_size = key.mv_size;
+ }
+ }
+ } else {
+ appflag = 0;
+ }
+ rc = mdb_cursor_put(mc, &key, &data, putflags|appflag);
if (rc == MDB_KEYEXIST && putflags)
continue;
if (rc) {
diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc
index 721b2af15..6bc6b2619 100644
--- a/external/easylogging++/easylogging++.cc
+++ b/external/easylogging++/easylogging++.cc
@@ -1961,8 +1961,13 @@ void VRegistry::setCategories(const char* categories, bool clear) {
m_categories.push_back(std::make_pair(ss.str(), level));
};
- if (clear)
+ if (clear) {
m_categories.clear();
+ m_categoriesString.clear();
+ }
+ if (!m_categoriesString.empty())
+ m_categoriesString += ",";
+ m_categoriesString += categories;
if (!categories)
return;
@@ -2001,6 +2006,11 @@ void VRegistry::setCategories(const char* categories, bool clear) {
}
}
+std::string VRegistry::getCategories() {
+ base::threading::ScopedLock scopedLock(lock());
+ return m_categoriesString;
+}
+
// Log levels are sorted in a weird way...
static int priority(Level level) {
if (level == Level::Fatal) return 0;
@@ -3073,6 +3083,10 @@ void Loggers::setCategories(const char* categories, bool clear) {
ELPP->vRegistry()->setCategories(categories, clear);
}
+std::string Loggers::getCategories() {
+ return ELPP->vRegistry()->getCategories();
+}
+
void Loggers::clearCategories(void) {
ELPP->vRegistry()->clearCategories();
}
diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h
index 8f592899e..c55cce755 100644
--- a/external/easylogging++/easylogging++.h
+++ b/external/easylogging++/easylogging++.h
@@ -2488,6 +2488,8 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
void setCategories(const char* categories, bool clear = true);
+ std::string getCategories();
+
void setModules(const char* modules);
bool allowed(Level level, const char* category);
@@ -2518,6 +2520,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
base::type::EnumType* m_pFlags;
std::map<std::string, base::type::VerboseLevel> m_modules;
std::deque<std::pair<std::string, Level>> m_categories;
+ std::string m_categoriesString;
std::string m_filenameCommonPrefix;
};
} // namespace base
@@ -3953,6 +3956,8 @@ class Loggers : base::StaticClass {
static void setVModules(const char* modules);
/// @brief Sets categories as specified (on the fly)
static void setCategories(const char* categories, bool clear = true);
+ /// @brief Gets current categories
+ static std::string getCategories();
/// @brief Clears vmodules
static void clearVModules(void);
/// @brief Clears categories