size_t WriteBehindFrontendLogger::WriteLogRecords(
    std::vector<txn_id_t> committed_txn_list) {
  size_t written_log_record_count = 0;

  // Write out the log records of all the committed transactions to log file
  for (txn_id_t txn_id : committed_txn_list) {
    // Locate the transaction log list for this txn id
    auto txn_log_list =
        global_peloton_log_record_pool.SearchLogRecordList(txn_id);
    if (txn_log_list == nullptr) {
      continue;
    }

    written_log_record_count += txn_log_list->size();

    // Write out all the records in the list
    for (size_t txn_log_list_itr = 0; txn_log_list_itr < txn_log_list->size();
         txn_log_list_itr++) {
      // Write out the log record
      TupleRecord *record = txn_log_list->at(txn_log_list_itr);
      fwrite(record->GetMessage(), sizeof(char), record->GetMessageLength(),
             log_file);
    }
  }

  // No need to flush now, will flush later in WriteTxnLog
  return written_log_record_count;
}
size_t WriteBehindFrontendLogger::WriteLogRecords(
    std::vector<txn_id_t> committed_txn_list) {
  size_t total_txn_log_records = 0;

  // Write out the log records of all the committed transactions to log file
  for (txn_id_t txn_id : committed_txn_list) {
    // Locate the transaction log list for this txn id
    auto exists_txn_log_list =
        global_peloton_log_record_pool.ExistsTxnLogRecordList(txn_id);
    if (exists_txn_log_list == false) {
      continue;
    }

    auto &txn_log_record_list =
        global_peloton_log_record_pool.txn_log_table[txn_id];
    size_t txn_log_record_list_size = txn_log_record_list.size();
    total_txn_log_records += txn_log_record_list_size;

    // Write out all the records in the list
    for (size_t txn_log_list_itr = 0;
         txn_log_list_itr < txn_log_record_list_size; txn_log_list_itr++) {
      TupleRecord *record = txn_log_record_list.at(txn_log_list_itr).get();

      // Write out the log record
      fwrite(record->GetMessage(), sizeof(char), record->GetMessageLength(),
             log_file);
    }
  }

  // No need to flush now, will flush later in WriteTxnLog
  return total_txn_log_records;
}