0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd::db: Add support for direct SST file ingestion.

This commit is contained in:
Jason Volk 2018-09-21 15:08:57 -07:00
parent 452f9a9abb
commit 7834c86360
3 changed files with 68 additions and 0 deletions

View file

@ -59,6 +59,7 @@ namespace ircd::db
void del(column &, const string_view &key, const sopts & = {});
// [SET] Other operations
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 & = {});

View file

@ -7580,6 +7580,30 @@ ircd::db::setopt(column &column,
};
}
void
ircd::db::ingest(column &column,
const string_view &path)
{
database &d(column);
database::column &c(column);
rocksdb::IngestExternalFileOptions opts;
opts.allow_global_seqno = false;
opts.allow_blocking_flush = false;
const std::vector<std::string> files
{
{ std::string{path} }
};
const std::lock_guard<decltype(write_mutex)> lock{write_mutex};
const ctx::uninterruptible::nothrow ui;
throw_on_error
{
d.d->IngestExternalFile(c, files, opts)
};
}
void
ircd::db::del(column &column,
const string_view &key,

View file

@ -1893,6 +1893,49 @@ catch(const std::out_of_range &e)
return true;
}
bool
console_cmd__db__ingest(opt &out, const string_view &line)
try
{
const params param{line, " ",
{
"dbname", "column", "path"
}};
const auto dbname
{
param.at("dbname")
};
const auto colname
{
param.at("column")
};
const auto path
{
param.at("path")
};
auto &database
{
db::database::get(dbname)
};
db::column column
{
database, colname
};
db::ingest(column, path);
return true;
}
catch(const std::out_of_range &e)
{
out << "No open database by that name" << std::endl;
return true;
}
bool
console_cmd__db__files(opt &out, const string_view &line)
try