00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Common/IndexTable.h"
00027 #include "Common/LexEntry.h"
00028
00029 using namespace IXE::io;
00030
00031 namespace IXE {
00032
00033 #ifdef LEXLEN
00034 FileFormat fileFormatVersion = { 1, 4 };
00035 #else
00036 FileFormat fileFormatVersion = { 1, 3 };
00037 #endif
00038
00039 static void
00040 skipLexicon(char const* begin, off32_t& offset)
00041 {
00042 off32_t* p = (off32_t*)(begin + offset);
00043 Count entries = p[0];
00044 LexEntry const* table = reinterpret_cast<LexEntry const *>(&p[1]);
00045
00046 offset = table[entries].word;
00047 }
00048
00049
00055
00056
00057 template <class Entry>
00058 IndexTable<Entry>::IndexTable(mappedFile const &file, index_id id)
00059 {
00060 begin_ = file.begin();
00061 FileHeader* fh = (FileHeader*)begin_;
00062 Count num_columns = fh->get_num_columns();
00063 off32_t offset = sizeof(FileHeader);
00064
00065 Count i;
00066 for (i = 0; i < num_columns; i++) {
00067
00068
00069 ((BigramTable*)this)->access(file, offset);
00070 skipLexicon(begin_, offset);
00071 }
00072 for (i = 0; i <= (Count)id; i++)
00073 access(file, offset);
00074 }
00075
00076
00083
00084 void
00085 BigramTable::access(mappedFile const &file, off32_t &offset)
00086 {
00087 begin_ = file.begin();
00088 off32_t const *p = reinterpret_cast<off32_t const *>(begin_ + offset);
00089 entries = p[0];
00090 table = reinterpret_cast<TermID const *>(&p[1]);
00091
00092 offset += sizeof(entries) + entries * sizeof(size_type);
00093 }
00094
00095
00096
00097
00098 StringTable::StringTable(mappedFile const &file, index_id id) :
00099 IndexTable<Size>(file, id) { }
00100
00101 }