Fix: terminal lookup table flushing.

Bug: 11073222
Change-Id: I17865dc400ad21cbfb3e3ed93cfe620dde1c7b6d
main
Keisuke Kuroyanagi 2013-12-03 15:20:02 +09:00
parent 6d9e273fb5
commit b4aea1acaa
3 changed files with 9 additions and 7 deletions

View File

@ -25,7 +25,7 @@ const BigramEntry BigramDictContent::getBigramEntryAndAdvancePosition(
const BufferWithExtendableBuffer *const bigramListBuffer = getContentBuffer();
const int bigramFlags = bigramListBuffer->readUintAndAdvancePosition(
Ver4DictConstants::BIGRAM_FLAGS_FIELD_SIZE, bigramEntryPos);
const int hasNext = (bigramFlags & Ver4DictConstants::BIGRAM_HAS_NEXT_MASK) != 0;
const bool hasNext = (bigramFlags & Ver4DictConstants::BIGRAM_HAS_NEXT_MASK) != 0;
int probability = NOT_A_PROBABILITY;
int timestamp = Ver4DictConstants::NOT_A_TIME_STAMP;
int level = 0;

View File

@ -53,13 +53,12 @@ bool TerminalPositionLookupTable::setTerminalPtNodePosition(
bool TerminalPositionLookupTable::flushToFile(const char *const dictDirPath,
const int newHeaderRegionSize) const {
const int headerRegionSizeDiff = newHeaderRegionSize - mHeaderRegionSize;
// If header region size has been changed, terminal PtNode positions have to be adjusted
// depending on the new header region size.
if (headerRegionSizeDiff != 0) {
TerminalPositionLookupTable lookupTableToWrite;
// If header region size has been changed or used buffer size is smaller than actual buffer
// size, regenerate lookup table and write the new table to file.
if (headerRegionSizeDiff != 0 || getEntryPos(mSize) < getBuffer()->getTailPosition()) {
TerminalPositionLookupTable lookupTableToWrite(newHeaderRegionSize);
for (int i = 0; i < mSize; ++i) {
const int terminalPtNodePosition = getTerminalPtNodePosition(i)
+ headerRegionSizeDiff;
const int terminalPtNodePosition = getTerminalPtNodePosition(i);
if (!lookupTableToWrite.setTerminalPtNodePosition(i, terminalPtNodePosition)) {
AKLOGE("Cannot set terminal position to lookupTableToWrite."
" terminalId: %d, position: %d", i, terminalPtNodePosition);

View File

@ -37,6 +37,9 @@ class TerminalPositionLookupTable : public SingleDictContent {
/ Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE),
mHeaderRegionSize(headerRegionSize) {}
explicit TerminalPositionLookupTable(const int headerRegionSize)
: mSize(0), mHeaderRegionSize(headerRegionSize) {}
TerminalPositionLookupTable() : mSize(0), mHeaderRegionSize(0) {}
int getTerminalPtNodePosition(const int terminalId) const;