Merge "Pass max trie structure size to on memory Ver4DictBuffers."

main
Keisuke Kuroyanagi 2014-04-19 01:04:20 +00:00 committed by Android (Google) Code Review
commit 4f3c3aaf11
4 changed files with 9 additions and 8 deletions

View File

@ -130,11 +130,10 @@ Ver4DictBuffers::Ver4DictBuffers(const char *const dictPath,
mShortcutDictContent(dictPath, isUpdatable), mShortcutDictContent(dictPath, isUpdatable),
mIsUpdatable(isUpdatable) {} mIsUpdatable(isUpdatable) {}
Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy) Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy, const int maxTrieSize)
: mHeaderBuffer(nullptr), mDictBuffer(nullptr), mHeaderPolicy(), : mHeaderBuffer(nullptr), mDictBuffer(nullptr), mHeaderPolicy(),
mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE), mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
mExpandableTrieBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE), mExpandableTrieBuffer(maxTrieSize), mTerminalPositionLookupTable(),
mTerminalPositionLookupTable(),
mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()), mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()),
mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(), mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(),
mIsUpdatable(true) {} mIsUpdatable(true) {}

View File

@ -39,8 +39,8 @@ class Ver4DictBuffers {
MmappedBuffer::MmappedBufferPtr headerBuffer); MmappedBuffer::MmappedBufferPtr headerBuffer);
static AK_FORCE_INLINE Ver4DictBuffersPtr createVer4DictBuffers( static AK_FORCE_INLINE Ver4DictBuffersPtr createVer4DictBuffers(
const HeaderPolicy *const headerPolicy) { const HeaderPolicy *const headerPolicy, const int maxTrieSize) {
return Ver4DictBuffersPtr(new Ver4DictBuffers(headerPolicy)); return Ver4DictBuffersPtr(new Ver4DictBuffers(headerPolicy, maxTrieSize));
} }
AK_FORCE_INLINE bool isValid() const { AK_FORCE_INLINE bool isValid() const {
@ -122,7 +122,7 @@ class Ver4DictBuffers {
Ver4DictBuffers(const char *const dictDirPath, Ver4DictBuffers(const char *const dictDirPath,
const MmappedBuffer::MmappedBufferPtr headerBuffer, const bool isUpdatable); const MmappedBuffer::MmappedBufferPtr headerBuffer, const bool isUpdatable);
Ver4DictBuffers(const HeaderPolicy *const headerPolicy); Ver4DictBuffers(const HeaderPolicy *const headerPolicy, const int maxTrieSize);
const MmappedBuffer::MmappedBufferPtr mHeaderBuffer; const MmappedBuffer::MmappedBufferPtr mHeaderBuffer;
const MmappedBuffer::MmappedBufferPtr mDictBuffer; const MmappedBuffer::MmappedBufferPtr mDictBuffer;

View File

@ -55,7 +55,8 @@ bool Ver4PatriciaTrieWritingHelper::writeToDictFileWithGC(const int rootPtNodeAr
const char *const dictDirPath) { const char *const dictDirPath) {
const HeaderPolicy *const headerPolicy = mBuffers->getHeaderPolicy(); const HeaderPolicy *const headerPolicy = mBuffers->getHeaderPolicy();
Ver4DictBuffers::Ver4DictBuffersPtr dictBuffers( Ver4DictBuffers::Ver4DictBuffersPtr dictBuffers(
Ver4DictBuffers::createVer4DictBuffers(headerPolicy)); Ver4DictBuffers::createVer4DictBuffers(headerPolicy,
Ver4DictConstants::MAX_DICTIONARY_SIZE));
int unigramCount = 0; int unigramCount = 0;
int bigramCount = 0; int bigramCount = 0;
if (!runGC(rootPtNodeArrayPos, headerPolicy, dictBuffers.get(), &unigramCount, &bigramCount)) { if (!runGC(rootPtNodeArrayPos, headerPolicy, dictBuffers.get(), &unigramCount, &bigramCount)) {

View File

@ -49,7 +49,8 @@ const char *const DictFileWritingUtils::TEMP_FILE_SUFFIX_FOR_WRITING_DICT_FILE =
const DictionaryHeaderStructurePolicy::AttributeMap *const attributeMap) { const DictionaryHeaderStructurePolicy::AttributeMap *const attributeMap) {
HeaderPolicy headerPolicy(FormatUtils::VERSION_4, localeAsCodePointVector, attributeMap); HeaderPolicy headerPolicy(FormatUtils::VERSION_4, localeAsCodePointVector, attributeMap);
Ver4DictBuffers::Ver4DictBuffersPtr dictBuffers( Ver4DictBuffers::Ver4DictBuffersPtr dictBuffers(
Ver4DictBuffers::createVer4DictBuffers(&headerPolicy)); Ver4DictBuffers::createVer4DictBuffers(&headerPolicy,
Ver4DictConstants::MAX_DICT_EXTENDED_REGION_SIZE));
headerPolicy.fillInAndWriteHeaderToBuffer(true /* updatesLastDecayedTime */, headerPolicy.fillInAndWriteHeaderToBuffer(true /* updatesLastDecayedTime */,
0 /* unigramCount */, 0 /* bigramCount */, 0 /* unigramCount */, 0 /* bigramCount */,
0 /* extendedRegionSize */, dictBuffers->getWritableHeaderBuffer()); 0 /* extendedRegionSize */, dictBuffers->getWritableHeaderBuffer());