コード例 #1
0
ファイル: logger_workload.cpp プロジェクト: YangMann/peloton
void BuildLog(oid_t db_oid, oid_t table_oid) {
  std::chrono::time_point<std::chrono::system_clock> start, end;
  std::chrono::duration<double, std::milli> elapsed_milliseconds;

  // Build a pool
  auto logging_pool = new VarlenPool(BACKEND_TYPE_MM);

  // Create db
  CreateDatabase(db_oid);
  auto& manager = catalog::Manager::GetInstance();
  storage::Database* db = manager.GetDatabaseWithOid(db_oid);

  // Create table, drop it and create again
  // so that table can have a newly added tile group and
  // not just the default tile group
  storage::DataTable* table = CreateUserTable(db_oid, table_oid);
  db->AddTable(table);

  // Tuple count
  oid_t per_backend_tuple_count = state.tuple_count / state.backend_count;

  // Create Tuples
  auto tuples =
      CreateTuples(table->GetSchema(), per_backend_tuple_count, logging_pool);

  //===--------------------------------------------------------------------===//
  // ACTIVE PROCESSING
  //===--------------------------------------------------------------------===//

  start = std::chrono::system_clock::now();

  // Execute the workload to build the log
  std::vector<std::thread> thread_group;
  oid_t num_threads = state.backend_count;

  // Launch a group of threads
  for (uint64_t thread_itr = 0; thread_itr < num_threads; ++thread_itr) {
    thread_group.push_back(std::thread(RunBackends, table, tuples));
  }

  // Join the threads with the main thread
  for (uint64_t thread_itr = 0; thread_itr < num_threads; ++thread_itr) {
    thread_group[thread_itr].join();
  }

  end = std::chrono::system_clock::now();
  elapsed_milliseconds = end - start;

  // Build log time
  if (state.experiment_type == EXPERIMENT_TYPE_ACTIVE ||
      state.experiment_type == EXPERIMENT_TYPE_WAIT) {
    WriteOutput(elapsed_milliseconds.count());
  } else if (state.experiment_type == EXPERIMENT_TYPE_STORAGE) {
    auto log_file_size = GetLogFileSize();
    LOG_INFO("Log file size :: %lu", log_file_size);
    WriteOutput(log_file_size);
  }

  // Clean up data
  for (auto tuple : tuples) {
    delete tuple;
  }

  // Check the tuple count if needed
  if (state.check_tuple_count) {
    oid_t total_expected = 0;
    CheckTupleCount(db_oid, table_oid, total_expected);
  }

  // We can only drop the table in case of WAL
  if (IsBasedOnWriteAheadLogging(peloton_logging_mode) == true) {
    db->DropTableWithOid(table_oid);
    DropDatabase(db_oid);
  }
}
コード例 #2
0
ファイル: Database.cpp プロジェクト: hjhong/MyDuiLib
	bool CUserMgr::OnCreateTables()
	{// 
		return CreateUserTable();
	}