예제 #1
0
      LdbLogsReader::~LdbLogsReader()
      {
        if (last_log_record_ != NULL)
        {
          delete last_log_record_;
        }

        clear_reader(0);
      }
예제 #2
0
      int LdbLogsReader::start_new_reader(uint64_t min_number)
      {
        int ret = TAIR_RETURN_SUCCESS;

        clear_reader(min_number);

        leveldb::DBImpl* db = dynamic_cast<leveldb::DBImpl*>(db_);
        leveldb::Env* db_env = db->GetEnv();
        const std::string& db_log_dir = db->DBLogDir();
        std::vector<std::string> filenames;
        leveldb::Status s = db_env->GetChildren(db_log_dir, &filenames);

        uint64_t number = 0;
        leveldb::FileType type;
        std::vector<uint64_t> logs;
        for (size_t i = 0; i < filenames.size(); i++)
        {
          if (leveldb::ParseFileName(filenames[i], &number, &type) && type == leveldb::kLogFile)
          {
            logs.push_back(number);
          }
        }

        uint64_t new_logfile_number = 0;
        uint64_t db_logfile_number = db->LogFileNumber();

        if (!logs.empty())
        {
          std::sort(logs.begin(), logs.end());
          // maybe binary-search..
          for (size_t i = 0; i < logs.size(); ++i)
          {
            if (logs[i] > min_number && logs[i] <= db_logfile_number)
            {
              new_logfile_number = logs[i];
              break;
            }
          }
        }

        if (0 == new_logfile_number)
        {
          log_info("no ldb log for reader");
        }
        else
        {
          ret = init_reader(new_logfile_number);
        }

        return ret;
      }
예제 #3
0
 IR Compile(Form* form)
 {
   string out;
   string tmp;
   if(form == NULL)
     error(form,"Can't emit code for the null form.");
   else if(isatom(form))
   {
     if(val(form) == "quit")
       exit(0);
     else if(val(form) == "IR")
     {
       master.Program->dump();
       nerror("Dumped IR.");
     }
     else if(val(form) == "debug")
     {
       master.debug = !master.debug;
       nerror("Debug mode is ",(master.debug?"on":"off"),".");
     }
     else
       out = emitCode(form);
   }
   else
     out = emitCode(form/*,Top*/);
   /*for(unsigned long i = 0; i < master.Persistent.size(); i++)
     tmp += master.Persistent[i] + "\n";*/
   for(unsigned long i = 0; i < master.CodeStack.size(); i++)
     tmp += master.CodeStack[i] + "\n";
   out = "define " + latest_type() + " @entry(){\n" + out + "\nret " + latest_type() + " " + get_current_res() + "\n}";
   out = tmp + out;
   string type = latest_type();
   master.CodeStack.clear();
   clear_reader();
   return {out,type};
 }