256 std::unique_ptr<heavyai::DistributedSharedMutex> table_mutex;
258 std::string table_key_as_text;
259 for (
auto n : table_key) {
260 table_key_as_text += (!table_key_as_text.empty() ?
"_" :
"") +
std::to_string(
n);
267 auto cb_reload_catalog_metadata = [table_key](
bool write) {
268 if constexpr (T::kind ==
"insert") {
275 *
cat->dcatalogMutex_);
278 if constexpr (T::kind ==
"schema") {
280 auto cb_reload_table_metadata = [table_key, table_key_as_text](
size_t version) {
281 VLOG(2) <<
"reloading table metadata for: table_" << table_key_as_text;
287 *cat->dcatalogMutex_);
293 cb_reload_catalog_metadata,
294 cb_reload_table_metadata};
295 auto schema_lockfile{
298 (
"table_" + table_key_as_text +
"." + T::kind.data() +
".lockfile")};
299 table_mutex = std::make_unique<heavyai::DistributedSharedMutex>(
300 schema_lockfile.string(), cbs);
301 }
else if constexpr (T::kind ==
"data" || T::kind ==
"insert") {
303 auto cb_reload_table_data = [table_key, table_key_as_text](
size_t version) {
304 VLOG(2) <<
"invalidating table caches for new version " <<
version
305 <<
" of: table_" << table_key_as_text;
308 table_key[CHUNK_KEY_DB_IDX]);
314 auto rows_lockfile{std::filesystem::path(
g_base_path) /
316 (
"table_" + table_key_as_text +
".rows.lockfile")};
317 std::shared_ptr<heavyai::DistributedSharedMutex> rows_mutex =
318 std::make_shared<heavyai::DistributedSharedMutex>(
319 rows_lockfile.string(),
320 cb_reload_table_data);
323 auto cb_reload_row_data = [table_key, rows_mutex](
bool ) {
328 auto cb_notify_about_row_data = [table_key, rows_mutex](
bool write) {
337 cb_reload_catalog_metadata,
340 cb_notify_about_row_data};
344 (
"table_" + table_key_as_text +
"." + T::kind.data() +
".lockfile")};
346 std::make_unique<heavyai::DistributedSharedMutex>(table_lockfile.string(), cbs);
348 UNREACHABLE() <<
"unexpected lockmgr kind: " << T::kind;
const std::string kDataDirectoryName
size_t write(FILE *f, const size_t offset, const size_t size, const int8_t *buf)
Writes the specified number of bytes to the offset position in file f from buf.
std::shared_lock< T > shared_lock
static SysCatalog & instance()
std::unique_lock< T > unique_lock
#define CHUNK_KEY_TABLE_IDX
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
const std::string kCatalogDirectoryName
const std::string kLockfilesDirectoryName