Пример #1
0
int main(){
	List list_of_elements;
	initiliaze(&list_of_elements);
	printf("length of list is %d\n",list_of_elements.length);

	enqueue(&list_of_elements,65);
	enqueue(&list_of_elements,63);
	enqueue(&list_of_elements,45);

	enqueue(&list_of_elements,56);
	enqueue(&list_of_elements,32);
	enqueue(&list_of_elements,76);
	enqueue(&list_of_elements,98);
	enqueue(&list_of_elements,90);
	enqueue(&list_of_elements,54);
	enqueue(&list_of_elements,32);
	enqueue(&list_of_elements,45);
	enqueue(&list_of_elements,32);
	enqueue(&list_of_elements,76);
	enqueue(&list_of_elements,87);
	enqueue(&list_of_elements,38);

	print_list(&list_of_elements);
	printf("after inserting location is ......");
	// printf("%d",traversing(&list_of_elements,54));
	insert_loc(&list_of_elements,32,102);
	print_list(&list_of_elements);
}
Пример #2
0
TEST_F(LoggingTests, BasicLogManagerTest) {
  peloton_logging_mode = LOGGING_TYPE_INVALID;
  auto &log_manager = logging::LogManager::GetInstance();
  log_manager.DropFrontendLoggers();
  log_manager.SetLoggingStatus(LOGGING_STATUS_TYPE_INVALID);
  // just start, write a few records and exit
  catalog::Schema *table_schema = new catalog::Schema(
      {ExecutorTestsUtil::GetColumnInfo(0), ExecutorTestsUtil::GetColumnInfo(1),
       ExecutorTestsUtil::GetColumnInfo(2),
       ExecutorTestsUtil::GetColumnInfo(3)});
  std::string table_name("TEST_TABLE");

  // Create table.
  bool own_schema = true;
  bool adapt_table = false;
  storage::DataTable *table = storage::TableFactory::GetDataTable(
      12345, 123456, table_schema, table_name, 1, own_schema, adapt_table);

  storage::Database test_db(12345);
  test_db.AddTable(table);
  catalog::Manager::GetInstance().AddDatabase(&test_db);
  concurrency::TransactionManager &txn_manager =
      concurrency::TransactionManagerFactory::GetInstance();
  txn_manager.BeginTransaction();
  ExecutorTestsUtil::PopulateTable(table, 5, true, false, false);
  txn_manager.CommitTransaction();
  peloton_logging_mode = LOGGING_TYPE_NVM_WAL;

  log_manager.SetSyncCommit(true);
  EXPECT_FALSE(log_manager.ContainsFrontendLogger());
  log_manager.StartStandbyMode();
  log_manager.GetFrontendLogger(0)->SetTestMode(true);
  log_manager.StartRecoveryMode();
  log_manager.WaitForModeTransition(LOGGING_STATUS_TYPE_LOGGING, true);
  EXPECT_TRUE(log_manager.ContainsFrontendLogger());
  log_manager.SetGlobalMaxFlushedCommitId(4);
  concurrency::Transaction test_txn;
  cid_t commit_id = 5;
  log_manager.PrepareLogging();
  log_manager.LogBeginTransaction(commit_id);
  ItemPointer insert_loc(table->GetTileGroup(1)->GetTileGroupId(), 0);
  ItemPointer delete_loc(table->GetTileGroup(2)->GetTileGroupId(), 0);
  ItemPointer update_old(table->GetTileGroup(3)->GetTileGroupId(), 0);
  ItemPointer update_new(table->GetTileGroup(4)->GetTileGroupId(), 0);
  log_manager.LogInsert(commit_id, insert_loc);
  log_manager.LogUpdate(commit_id, update_old, update_new);
  log_manager.LogInsert(commit_id, delete_loc);
  log_manager.LogCommitTransaction(commit_id);

  // TODO: Check the flushed commit id
  // since we are doing sync commit we should have reached 5 already
  //EXPECT_EQ(commit_id, log_manager.GetPersistentFlushedCommitId());
  log_manager.EndLogging();
}