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

ircd::db: Create an sst utility space; move fileinfo into sst.

This commit is contained in:
Jason Volk 2018-09-22 13:13:05 -07:00
parent f7da7d9be8
commit 99ff78f5c7
5 changed files with 44 additions and 32 deletions

View file

@ -79,7 +79,7 @@ struct ircd::db::database
struct column;
struct env;
struct cache;
struct fileinfo;
struct sst;
std::string name;
uint64_t checkpoint;

View file

@ -9,17 +9,25 @@
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_DB_DATABASE_FILEINFO_H
#define HAVE_IRCD_DB_DATABASE_SST_H
namespace ircd::db
struct ircd::db::database::sst
{
void sst_dump(const vector_view<const string_view> &args);
}
struct info;
/// 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.
struct ircd::db::database::fileinfo
static void dump(const vector_view<const string_view> &args);
};
struct ircd::db::database::sst::writer
{
using key_range = std::pair<string_view, string_view>;
writer(const database &, const column &, const key_range & = {});
};
/// Get info about an SST file.
///
struct ircd::db::database::sst::info
{
struct vector;
@ -35,13 +43,13 @@ struct ircd::db::database::fileinfo
int level {-1};
bool compacting {false};
fileinfo() = default;
fileinfo(rocksdb::LiveFileMetaData &&);
fileinfo(const database &, const string_view &filename);
info() = default;
info(rocksdb::LiveFileMetaData &&);
info(const database &, const string_view &filename);
};
struct ircd::db::database::fileinfo::vector
:std::vector<fileinfo>
struct ircd::db::database::sst::info::vector
:std::vector<info>
{
vector() = default;
explicit vector(const database &);

View file

@ -69,7 +69,7 @@ enum class ircd::db::pos
#include "database/database.h"
#include "database/options.h"
#include "database/snapshot.h"
#include "database/fileinfo.h"
#include "database/sst.h"
#include "cache.h"
#include "opts.h"
#include "column.h"

View file

@ -2486,25 +2486,29 @@ const noexcept
///////////////////////////////////////////////////////////////////////////////
//
// database::fileinfo
// database::sst
//
void
ircd::db::sst_dump(const vector_view<const string_view> &args)
ircd::db::database::sst::dump(const vector_view<const string_view> &args)
{
thread_local char arg[16][256]
static const size_t ARG_MAX {16};
static const size_t ARG_MAX_LEN {256};
thread_local char arg[ARG_MAX][ARG_MAX_LEN]
{
"./sst_dump"
};
size_t i(0);
char *argv[16] { arg[i++] };
for(; i < 15 && i - 1 < args.size(); ++i)
char *argv[ARG_MAX] { arg[i++] };
for(; i < ARG_MAX - 1 && i - 1 < args.size(); ++i)
{
strlcpy(arg[i], args.at(i - 1));
argv[i] = arg[i];
}
argv[i] = nullptr;
argv[i++] = nullptr;
assert(i <= ARG_MAX);
rocksdb::SSTDumpTool tool;
const int ret
@ -2520,10 +2524,10 @@ ircd::db::sst_dump(const vector_view<const string_view> &args)
}
//
// fileinfo::vector
// sst::info::vector
//
ircd::db::database::fileinfo::vector::vector(const database &d)
ircd::db::database::sst::info::vector::vector(const database &d)
{
std::vector<rocksdb::LiveFileMetaData> v;
d.d->GetLiveFilesMetaData(&v);
@ -2540,8 +2544,8 @@ ircd::db::database::fileinfo::vector::vector(const database &d)
// fileinfo::fileinfo
//
ircd::db::database::fileinfo::fileinfo(const database &d,
const string_view &filename)
ircd::db::database::sst::info::info(const database &d,
const string_view &filename)
{
std::vector<rocksdb::LiveFileMetaData> v;
d.d->GetLiveFilesMetaData(&v);
@ -2549,7 +2553,7 @@ ircd::db::database::fileinfo::fileinfo(const database &d,
for(auto &md : v)
if(md.name == filename)
{
new (this) fileinfo(std::move(md));
new (this) info(std::move(md));
return;
}
@ -2561,7 +2565,7 @@ ircd::db::database::fileinfo::fileinfo(const database &d,
};
}
ircd::db::database::fileinfo::fileinfo(rocksdb::LiveFileMetaData &&md)
ircd::db::database::sst::info::info(rocksdb::LiveFileMetaData &&md)
:name{std::move(md.name)}
,path{std::move(md.db_path)}
,column{std::move(md.column_family_name)}

View file

@ -1945,7 +1945,7 @@ console_cmd__db__sstdump(opt &out, const string_view &line)
buf, tokens(line, " ", buf)
};
db::sst_dump(args);
db::database::sst::dump(args);
return true;
}
@ -1986,7 +1986,7 @@ try
<< std::endl;
const auto print{[&out]
(const db::database::fileinfo &f)
(const db::database::sst::info &f)
{
const uint64_t &min_key
{
@ -2018,7 +2018,7 @@ try
{
const auto fileinfos
{
db::database::fileinfo::vector(database)
db::database::sst::info::vector(database)
};
for(const auto &fileinfo : fileinfos)
@ -2032,7 +2032,7 @@ try
if(startswith(colname, "/"))
{
print(db::database::fileinfo{database, colname});
print(db::database::sst::info{database, colname});
return true;
}
@ -2047,7 +2047,7 @@ try
};
for(const auto &file : files)
print(db::database::fileinfo{database, file});
print(db::database::sst::info{database, file});
return true;
}