<commit_before>#include <iostream>
#include <cstdlib>
#include "../ARIES.h"

using namespace std;

#define LOG_OFFSET (1073741824)
#ifndef FIO
#define NUM_MAX_LOGFILE 1
static const char* log_path = "/work/kamiya/log.dat";
#else
#define NUM_MAX_LOGFILE 50
static const char* log_path = "/dev/fioa";
//static const char* log_path = "/dev/shm/kamiya/log.dat";
#endif

void init();

int main(){
  init();
}

void init(){

  int fd;
  MasterRecord master_record;
  char *ARIES_HOME =  getenv("ARIES_HOME");
  string system_filename = ARIES_HOME;
  system_filename += "/data/system.dat";
  
  if( (fd = open(system_filename.c_str(), O_RDWR | O_SYNC | O_CREAT, 0666 )) == -1 ){
    perror("open");
    exit(1);
  }
  int len1;

  
  if( (len1 = read(fd, &master_record, sizeof(MasterRecord))) == -1 ){
    perror("read");
    exit(1);
  }

  cout << "[before init]" << endl;
  cout << "chkp:" <<  master_record.mr_chkp << ", xid:" << master_record.system_xid << ", last_exit:" << std::boolalpha << master_record.last_exit << endl;

  master_record.mr_chkp=0;
  master_record.system_xid=0;
  master_record.last_exit=true;

  cout << "[after init]" << endl;
  cout << "chkp:" <<  master_record.mr_chkp << ", xid:" << master_record.system_xid << ", last_exit:" << master_record.last_exit << endl;

  lseek(fd, 0, SEEK_SET);
  if( -1 == write(fd, &master_record, sizeof(MasterRecord))) {
    perror("write");
    exit(1);
  }

  close(fd);

#ifndef FIO
  if( (fd = open(log_path, O_WRONLY | O_TRUNC | O_CREAT , 0666)) == -1 ){  
    perror("open");
    exit(1);
  }
#endif
#ifdef FIO
  if( (fd = open(log_path, O_WRONLY , 0666)) == -1 ){  
    perror("open");
    exit(1);
  }
#endif

  for(int i=0;i<NUM_MAX_LOGFILE;i++){

    off_t base = i * LOG_OFFSET;

#ifdef FIO
    printf("###   LogFile #%d is cleared   ###\n",i);
#endif

    lseek(fd, base, SEEK_SET);

    LogHeader lh = {0};
    if(-1 == write(fd, &lh, sizeof(lh))){
      perror("write");
      exit(1);
    }
  }
 
  close(fd);
}
<commit_msg>* initプログラムでマスターレコードのLSNを0にするように修正.<commit_after>#include <iostream>
#include <cstdlib>
#include "../ARIES.h"

using namespace std;

#define LOG_OFFSET (1073741824)
#ifndef FIO
#define NUM_MAX_LOGFILE 1
static const char* log_path = "/work/kamiya/log.dat";
#else
#define NUM_MAX_LOGFILE 50
static const char* log_path = "/dev/fioa";
//static const char* log_path = "/dev/shm/kamiya/log.dat";
#endif

void init();

int main(){
  init();
}

void init(){

  int fd;
  MasterRecord master_record;
  char *ARIES_HOME =  getenv("ARIES_HOME");
  string system_filename = ARIES_HOME;
  system_filename += "/data/system.dat";
  
  if( (fd = open(system_filename.c_str(), O_RDWR | O_SYNC | O_CREAT, 0666 )) == -1 ){
    perror("open");
    exit(1);
  }
  int len1;

  
  if( (len1 = read(fd, &master_record, sizeof(MasterRecord))) == -1 ){
    perror("read");
    exit(1);
  }

  cout << "[before init]" << endl;
  cout << "chkp:" <<  master_record.mr_chkp << ", xid:" << master_record.system_xid << ", last_exit:" << std::boolalpha << master_record.last_exit << endl;

  master_record.mr_chkp=0;
  master_record.system_xid=0;
  master_record.system_last_lsn=0;
  master_record.last_exit=true;

  cout << "[after init]" << endl;
  cout << "chkp:" <<  master_record.mr_chkp << ", xid:" << master_record.system_xid << ", last_exit:" << master_record.last_exit << endl;

  lseek(fd, 0, SEEK_SET);
  if( -1 == write(fd, &master_record, sizeof(MasterRecord))) {
    perror("write");
    exit(1);
  }

  close(fd);

#ifndef FIO
  if( (fd = open(log_path, O_WRONLY | O_TRUNC | O_CREAT , 0666)) == -1 ){  
    perror("open");
    exit(1);
  }
#endif
#ifdef FIO
  if( (fd = open(log_path, O_WRONLY , 0666)) == -1 ){  
    perror("open");
    exit(1);
  }
#endif

  for(int i=0;i<NUM_MAX_LOGFILE;i++){

    off_t base = i * LOG_OFFSET;

#ifdef FIO
    printf("###   LogFile #%d is cleared   ###\n",i);
#endif

    lseek(fd, base, SEEK_SET);

    LogHeader lh = {0};
    if(-1 == write(fd, &lh, sizeof(lh))){
      perror("write");
      exit(1);
    }
  }
 
  close(fd);
}

{'fraction_non_alphanumeric': 0.18498394665349469, 'fraction_numerical': 0.02222771054581378, 'mean_word_length': 3.5866364665911665, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5165438', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1627, 'n_words': 336}