0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::db: Support SST dump tooling.

This commit is contained in:
Jason Volk 2018-09-21 17:12:50 -07:00
parent f2cfa87d49
commit f7da7d9be8
3 changed files with 49 additions and 0 deletions

View file

@ -11,6 +11,11 @@
#pragma once
#define HAVE_IRCD_DB_DATABASE_FILEINFO_H
namespace ircd::db
{
void sst_dump(const vector_view<const string_view> &args);
}
/// Database snapshot object. Maintaining this object will maintain a
/// consistent state of access to the database at the sequence number
/// from when it's acquired.

View file

@ -26,6 +26,7 @@
#include <rocksdb/filter_policy.h>
#include <rocksdb/table.h>
#include <rocksdb/sst_file_manager.h>
#include <rocksdb/sst_dump_tool.h>
#include <rocksdb/compaction_filter.h>
// ircd::db interfaces requiring complete RocksDB (frontside).
@ -2488,6 +2489,36 @@ const noexcept
// database::fileinfo
//
void
ircd::db::sst_dump(const vector_view<const string_view> &args)
{
thread_local char arg[16][256]
{
"./sst_dump"
};
size_t i(0);
char *argv[16] { arg[i++] };
for(; i < 15 && i - 1 < args.size(); ++i)
{
strlcpy(arg[i], args.at(i - 1));
argv[i] = arg[i];
}
argv[i] = nullptr;
rocksdb::SSTDumpTool tool;
const int ret
{
tool.Run(i, argv)
};
if(ret != 0)
throw error
{
"Error from SST dump tool: return value: %d", ret
};
}
//
// fileinfo::vector
//

View file

@ -1936,6 +1936,19 @@ catch(const std::out_of_range &e)
return true;
}
bool
console_cmd__db__sstdump(opt &out, const string_view &line)
{
string_view buf[16];
const vector_view<const string_view> args
{
buf, tokens(line, " ", buf)
};
db::sst_dump(args);
return true;
}
bool
console_cmd__db__files(opt &out, const string_view &line)
try