Fix bug related to dynamic patricia trie bigram adding.

Bug: 6669677

Change-Id: Ia1216a1860a7c5c12a0d8a0816dda8d6a3bea123
main
Keisuke Kuroyanagi 2013-09-13 11:38:53 +09:00
parent be470f06e4
commit 1c0fc852f6
4 changed files with 10 additions and 14 deletions

View File

@ -57,7 +57,7 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
mChildrenPosFieldPos += mBuffer->getOriginalBufferSize(); mChildrenPosFieldPos += mBuffer->getOriginalBufferSize();
} }
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition( mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
dictBuf, mFlags, &pos); dictBuf, &pos);
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) { if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
mChildrenPos += mBuffer->getOriginalBufferSize(); mChildrenPos += mBuffer->getOriginalBufferSize();
} }

View File

@ -29,18 +29,14 @@ const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_MOVED = 0x40;
const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_DELETED = 0x80; const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_DELETED = 0x80;
/* static */ int DptReadingUtils::readChildrenPositionAndAdvancePosition( /* static */ int DptReadingUtils::readChildrenPositionAndAdvancePosition(
const uint8_t *const buffer, const NodeFlags flags, int *const pos) { const uint8_t *const buffer, int *const pos) {
if ((flags & MASK_MOVED) == FLAG_IS_NOT_MOVED) { const int base = *pos;
const int base = *pos; const int offset = ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
const int offset = ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos); if (offset == 0) {
if (offset == 0) { // 0 offset means that the node does not have children.
// 0 offset means that the node does not have children.
return NOT_A_DICT_POS;
} else {
return base + offset;
}
} else {
return NOT_A_DICT_POS; return NOT_A_DICT_POS;
} else {
return base + offset;
} }
} }

View File

@ -42,8 +42,7 @@ class DynamicPatriciaTrieReadingUtils {
return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos); return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
} }
static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer, static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer, int *const pos);
const NodeFlags flags, int *const pos);
/** /**
* Node Flags * Node Flags

View File

@ -172,6 +172,7 @@ class ByteArrayUtils {
int codePoint = readCodePointAndAdvancePosition(buffer, pos); int codePoint = readCodePointAndAdvancePosition(buffer, pos);
while (NOT_A_CODE_POINT != codePoint && length < maxLength) { while (NOT_A_CODE_POINT != codePoint && length < maxLength) {
codePoint = readCodePointAndAdvancePosition(buffer, pos); codePoint = readCodePointAndAdvancePosition(buffer, pos);
length++;
} }
return length; return length;
} }