0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::db: Add src and dst level arguments to db::compact files interface.

This commit is contained in:
Jason Volk 2018-12-12 15:53:16 -08:00
parent 9236eeba75
commit 62874ff498
4 changed files with 18 additions and 9 deletions

View file

@ -63,7 +63,7 @@ namespace ircd::db
void ingest(column &, const string_view &path);
void setopt(column &, const string_view &key, const string_view &val);
void compact(column &, const std::pair<string_view, string_view> &, const int &to_level = -1, const compactor & = {});
void compact(column &, const int &level = -1, const compactor & = {});
void compact(column &, const std::pair<int, int> &level = {-1, -1}, const compactor & = {});
void sort(column &, const bool &blocking = false);
void drop(column &); // danger
}

View file

@ -50,7 +50,7 @@ namespace ircd::db
uint64_t checkpoint(database &);
void resume(database &);
void check(database &);
void compact(database &, const int &level, const compactor & = {});
void compact(database &, const std::pair<int, int> &level, const compactor & = {});
void compact(database &, const compactor & = {});
void sort(database &, const bool &blocking = true);
void flush(database &, const bool &sync = false);

View file

@ -441,7 +441,7 @@ ircd::db::compact(database &d,
void
ircd::db::compact(database &d,
const int &level,
const std::pair<int, int> &level,
const compactor &cb)
{
for(const auto &c : d.columns)
@ -9169,22 +9169,30 @@ ircd::db::sort(column &column,
void
ircd::db::compact(column &column,
const int &level_,
const std::pair<int, int> &level,
const compactor &cb)
{
database::column &c(column);
database &d(*c.d);
const auto &dst_level{level.second};
const auto &src_level{level.first};
rocksdb::ColumnFamilyMetaData cfmd;
d.d->GetColumnFamilyMetaData(c, &cfmd);
for(const auto &level : cfmd.levels)
{
if(level_ != -1 && level.level != level_)
if(src_level != -1 && src_level != level.level)
continue;
if(level.files.empty())
continue;
const auto &to_level
{
dst_level > -1? dst_level : level.level
};
rocksdb::CompactionOptions opts;
opts.output_file_size_limit = 1_GiB; //TODO: conf
@ -9233,7 +9241,7 @@ ircd::db::compact(column &column,
throw_on_error
{
d.d->CompactFiles(opts, c, files, level.level)
d.d->CompactFiles(opts, c, files, to_level)
};
}
}

View file

@ -1560,7 +1560,7 @@ try
{
const params param{line, " ",
{
"dbname", "[colname]", "[level]"
"dbname", "[colname]", "[srclevel]", "[dstlevel]"
}};
const auto dbname
@ -1573,9 +1573,10 @@ try
param[1]
};
const auto level
const std::pair<int, int> level
{
param.at(2, -1)
param.at(2, -1),
param.at(3, -1)
};
auto &database