Exemplo n.º 1
0
bool InliningDatabase::file_out_all() {
  ResourceMark rm;

  // The lookup table is used to create the index file.

  // Flush the lookup table
  reset_lookup_table();

  // File in the current index file.
  load_index_file();

  local_number_of_nmethods_written = 0;
  Universe::code->nmethods_do(local_file_out_all);

  fileStream index(index_file_name());

  // File out the index file.
  for (unsigned int i = 0 ; i < table_size; i++) {
    if (table[i].is_filled()) {
      if (table[i].is_inner()) {
        table[i].inner.print_inlining_database_on(&index);
        index.cr();
      }
      table[i].outer.print_inlining_database_on(&index);
      index.cr();
    }
  }

  // Flush the lookup table
  reset_lookup_table();

  return local_number_of_nmethods_written ? true : false;
}
Exemplo n.º 2
0
	int main(int argc, char **argv) {
		std::map<std::string, int> map_word;
		std::vector<std::string> lib_vec; 
		std::ofstream ofs_lib;
		std::ofstream ofs_index;
		char* source_name = strdup("./language_lib");
		std::string lib_file_name("/home/markwoo/Documents/my_project/0515_0516_mini_search/lib_page/ripepage.lib"); //build_lib file name
		std::string index_file_name("/home/markwoo/Documents/my_project/0515_0516_mini_search/index/ripepage.index"); //index file file name
		
		/* 扫描语料库 */
		ScanFile(source_name, lib_vec);
		
		/* 写入文件,同时制作索引 */
		OpenOutFile(ofs_lib, lib_file_name);
		OpenOutFile(ofs_index, index_file_name);
		size_t vec_index = 1; //存储页面的容器vector下标

		for (auto &i : lib_vec) {
			ofs_index << vec_index << " " << ofs_lib.tellp(); //取得当前文件指针的位置
			ofs_lib << i;
			ofs_index << " " << i.size() << std::endl; //Doc文件的大小
			++vec_index;
		}

		ofs_index.close();
		ofs_lib.close();
		log_file.close();
		std::cout << "language lib and index builded" << std::endl;

		SearchIndex(index_file_name, lib_file_name);

		return 0;
	}
Exemplo n.º 3
0
void init_string_hash (void) {
  string_storage = cmalloc(string_storage_length);
  string_storage_table =
    (size_t*)cmalloc(STRING_STORAGE_TABLE_LENGTH * sizeof(size_t));

#ifdef USAGE
  printf("Allocating %dM for string storage\n", meg(string_storage_length));
  printf("Allocating %dM for string hash table\n",
	 meg(STRING_STORAGE_TABLE_LENGTH * sizeof(size_t)));
#endif

  if ((string_storage_file = open64(index_file_name(STRING_STORAGE_FILE),
				    O_RDWR|O_CREAT, 0644)) == -1) {
    fprintf(stderr, "Couldn't open %s\n", 
	    index_file_name(STRING_STORAGE_FILE));
    merror("Opening the string storage file.");
  }

  if (file_size(string_storage_file) == 0) {
    write_from(string_storage_file, "@@@", 4);
    next_string = 4;
  } else 
    smart_populate_string_table_from_file(string_storage_file);
}
Exemplo n.º 4
0
void init_group_hash (void) {
  group_table = (int*)cmalloc(MAX_GROUPS * sizeof(int));
#ifdef USAGE
  printf("Allocating %dM for group hash table\n",
	 meg(MAX_GROUPS * sizeof(int)));
#endif

  if ((group_file = open64(index_file_name(GROUP_FILE),
			   O_RDWR|O_CREAT, 0644)) == -1)
    merror("Opening the group file.");

  next_group_id = 1;

  if (file_size(group_file) == 0) {
    write_from(group_file, (char*)(&groups[0]), sizeof(group));
  } else 
    populate_group_table_from_file(group_file);
}
Exemplo n.º 5
0
void InliningDatabase::load_index_file() {
  ResourceMark rm;
  TraceTime t("Loading index for inlining database");

  // Open the file
  FILE* stream = fopen(index_file_name(), "rt");
  if (!stream) return;

  char line[1000];

  LookupKey first;
  LookupKey second;

  while (fgets( line, 1000, stream)) {
    if (scan_key(line, &first)) {
      if (first.is_block_type()) {
        if (fgets( line, 1000, stream)) {
          if (scan_key(line, &second)) {
	    // std->print("Block ");
            // first.print_on(std);
	    // std->print(" outer ");
            // second.print_on(std);
            // std->cr();
            add_lookup_entry(&second, &first);
	  } else {
            std->print_cr("Index file parsing block failed for %s", line);
	  }
	}
      } else {
	// std->print("Method ");
        // first.print_on(std);
        // std->cr();
        add_lookup_entry(&first);
      }
    } else {
      std->print_cr("Index file parsing failed for %s", line);
    }
  }
  fclose(stream);
}