169 std::unique_ptr<heavyai::DistributedSharedMutex> table_mutex;
171 std::string table_key_as_text;
172 for (
auto n : table_key) {
173 table_key_as_text += (!table_key_as_text.empty() ?
"_" :
"") +
std::to_string(
n);
180 auto cb_reload_catalog_metadata = [table_key](
bool write) {
181 if constexpr (T::kind ==
"insert") {
188 *
cat->dcatalogMutex_);
191 if constexpr (T::kind ==
"schema") {
193 auto cb_reload_table_metadata = [table_key, table_key_as_text](
size_t version) {
194 VLOG(2) <<
"reloading table metadata for: table_" << table_key_as_text;
200 *cat->dcatalogMutex_);
206 cb_reload_catalog_metadata,
207 cb_reload_table_metadata
209 auto schema_lockfile{
212 (
"table_" + table_key_as_text +
"." + T::kind.data() +
".lockfile")};
214 std::make_unique<heavyai::DistributedSharedMutex>(schema_lockfile.string(), cbs);
215 }
else if constexpr (T::kind ==
"data" || T::kind ==
"insert") {
217 auto cb_reload_table_data = [table_key, table_key_as_text](
size_t version) {
218 VLOG(2) <<
"invalidating table caches for new version " <<
version <<
" of: table_"
219 << table_key_as_text;
222 table_key[CHUNK_KEY_DB_IDX]);
228 auto rows_lockfile{std::filesystem::path(
g_base_path) /
230 (
"table_" + table_key_as_text +
".rows.lockfile")};
231 std::shared_ptr<heavyai::DistributedSharedMutex> rows_mutex =
232 std::make_shared<heavyai::DistributedSharedMutex>(
233 rows_lockfile.string(),
238 auto cb_reload_row_data = [table_key, rows_mutex](
bool write) {
243 auto cb_notify_about_row_data = [table_key, rows_mutex](
bool write) {
252 cb_reload_catalog_metadata,
255 cb_notify_about_row_data
260 (
"table_" + table_key_as_text +
"." + T::kind.data() +
".lockfile")};
262 std::make_unique<heavyai::DistributedSharedMutex>(table_lockfile.string(), cbs);
264 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