Skip to content

Commit

Permalink
fix(dict_compiler): shrink .reverse.bin file to fit after build
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Mar 28, 2021
1 parent 99e269c commit 2af37e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rime/dict/dict_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ bool DictCompiler::BuildReverseDb(DictSettings* settings,
collector.syllabary,
vocabulary,
collector.stems,
dict_file_checksum)) {
dict_file_checksum) ||
!reverse_db.Save()) {
LOG(ERROR) << "error building reversedb.";
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/rime/dict/reverse_lookup_dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ bool ReverseDb::Build(DictSettings* settings,
return true;
}

bool ReverseDb::Save() {
LOG(INFO) << "saving reverse file: " << file_name();
return ShrinkToFit();
}

uint32_t ReverseDb::dict_file_checksum() const {
return metadata_ ? metadata_->dict_file_checksum : 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/rime/dict/reverse_lookup_dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ReverseDb : public MappedFile {
const Vocabulary& vocabulary,
const ReverseLookupTable& stems,
uint32_t dict_file_checksum);
bool Save();

uint32_t dict_file_checksum() const;
reverse::Metadata* metadata() const { return metadata_; }
Expand Down

0 comments on commit 2af37e0

Please sign in to comment.