File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 22
33std::unordered_map<std::string, par_handle> par_handles;
44
5+ int current_index = 0 ;
6+
57par_handle par_get_db (const std::string &db_name)
68{
7- // std::cout << "File: " << __FILE__ << ", Line: " << __LINE__ << ", Function: " << __func__ << std::endl;
8-
99 // Check if the database is already opened
1010 auto it = par_handles.find (db_name);
1111 if (it != par_handles.end ()) {
1212 return it->second ; // Return the existing handle
1313 }
1414
1515 // Database is not opened yet, proceed to open it
16- const char *volume_name = getenv (PARALLAX_VOLUME_ENV_VAR);
16+
17+ std::string volume_path = " /tmp/root/parallax/default" + std::to_string (current_index);
18+ const char *volume_name = volume_path.c_str ();
1719
1820 par_db_options db_options = { .volume_name = (char *)volume_name,
1921 .db_name = db_name.c_str (),
@@ -43,8 +45,12 @@ par_handle par_get_db(const std::string &db_name)
4345
4446void par_init_db_handles ()
4547{
48+ int num_of_servers = par_get_num_of_servers ();
4649 for (int i = 0 ; i < PARALLAX_DB_COUNT; ++i) {
47- std::string db_name = PARALLAX_GLOBAL_DB + std::to_string (i + 1 );
48- par_get_db (db_name);
50+ current_index = i;
51+ for (int j = 0 ; j < num_of_servers; j++) {
52+ std::string db_name = PARALLAX_GLOBAL_DB + std::to_string (i * num_of_servers + j);
53+ par_get_db (db_name);
54+ }
4955 }
5056}
You can’t perform that action at this time.
0 commit comments