diff --git a/include/ircd/db/column.h b/include/ircd/db/column.h index 2901789fd..2630c7bde 100644 --- a/include/ircd/db/column.h +++ b/include/ircd/db/column.h @@ -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 &, const int &to_level = -1, const compactor & = {}); void compact(column &, const int &level = -1, const compactor & = {}); diff --git a/ircd/db.cc b/ircd/db.cc index 2e48de849..f278f1885 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -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 files + { + { std::string{path} } + }; + + const std::lock_guard 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, diff --git a/modules/console.cc b/modules/console.cc index 520f6b0ee..f04792dcc 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -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