00001 #pragma once
00002
00003 #include "probing_hash_utils.hh"
00004 #include "huffmanish.hh"
00005 #include "hash.hh"
00006 #include <sys/stat.h>
00007 #include "vocabid.hh"
00008 #include <algorithm>
00009 #define API_VERSION 3
00010
00011
00012 char * read_binary_file(char * filename);
00013
00014 class QueryEngine
00015 {
00016 unsigned char * binary_mmaped;
00017 std::map<unsigned int, std::string> vocabids;
00018 std::map<uint64_t, std::string> source_vocabids;
00019
00020 Table table;
00021 char *mem;
00022
00023 HuffmanDecoder decoder;
00024
00025 size_t binary_filesize;
00026 size_t table_filesize;
00027 int num_scores;
00028 bool is_reordering;
00029 public:
00030 QueryEngine (const char *);
00031 ~QueryEngine();
00032 std::pair<bool, std::vector<target_text> > query(StringPiece source_phrase);
00033 std::pair<bool, std::vector<target_text> > query(std::vector<uint64_t> source_phrase);
00034 void printTargetInfo(std::vector<target_text> target_phrases);
00035 const std::map<unsigned int, std::string> getVocab() const {
00036 return decoder.get_target_lookup_map();
00037 }
00038
00039 const std::map<uint64_t, std::string> getSourceVocab() const {
00040 return source_vocabids;
00041 }
00042
00043 };
00044
00045