00001
00002
00003 #include <iostream>
00004
00005 #include "core/big_hash_map.hpp"
00006 #include "usage/terminal.hpp"
00007 #include "util/memory.hpp"
00008
00009 using namespace aitools::bighashmap;
00010 using namespace aitools;
00011
00012 void build_hashmap()
00013 {
00014 typedef uint64_t value_type;
00015
00016 const bfs::path input_dir("/home/trenkman/nreth/posHashMap/input");
00017 const bfs::path output_dir("/home/trenkman/nreth/posHashMap/output");
00018
00019 try
00020 {
00021 core::builder<value_type>::build(input_dir, output_dir);
00022 }
00023 catch (std::string& msg)
00024 {
00025 std::cerr << "Exception: " << msg << std::endl;
00026 }
00027 catch (...)
00028 {
00029 std::cerr << "Unknown exception " << std::endl;
00030 }
00031 }
00032
00033 void open_hashmap()
00034 {
00035 typedef uint64_t value_type;
00036
00037 const bfs::path idx_file("/media/1TB/test/output/big_hash_map.idx");
00038
00039 try
00040 {
00041 std::unique_ptr<core::big_hash_map<value_type>> bhm(
00042 core::big_hash_map<value_type>::open(idx_file, util::memory_type::mb512));
00043
00044 value_type count(0);
00045 if (bhm->find("separateness of", count))
00046 {
00047 std::cout << count << std::endl;
00048 }
00049 if (bhm->find("machine kitchenaid", count))
00050 {
00051 std::cout << count << std::endl;
00052 }
00053 if (bhm->find("poker strengths", count))
00054 {
00055 std::cout << count << std::endl;
00056 }
00057 if (bhm->find("dfjwejfnfjaug", count))
00058 {
00059 std::cout << count << std::endl;
00060 }
00061 }
00062 catch (std::string& msg)
00063 {
00064 std::cerr << "Exception: " << msg << std::endl;
00065 }
00066 }
00067
00068 int main(int argc, char* argv[])
00069 {
00070
00071
00072
00073 if (argc != 3)
00074 {
00075 std::cout << "\nUsage: aitools3-aq-bighashmap <idx-file> "
00076 << "(internal | external)" << std::endl;
00077 }
00078 else
00079 {
00080 if (std::string(argv[2]) == "internal")
00081 {
00082 terminal<uint64_t>(bfs::path(argv[1]), util::memory_type::mb65536);
00083 }
00084 else
00085 {
00086 terminal<uint64_t>(bfs::path(argv[1]), util::memory_type::min_required);
00087 }
00088 }
00089
00090 return EXIT_SUCCESS;
00091 }