Merge "Fix: incompatibility of sparse table."

This commit is contained in:
Keisuke Kuroyanagi 2013-12-16 13:58:17 +00:00 committed by Android (Google) Code Review
commit b767715651
2 changed files with 5 additions and 4 deletions

View file

@ -48,8 +48,8 @@ const int Ver4DictConstants::TIME_STAMP_FIELD_SIZE = 4;
const int Ver4DictConstants::WORD_LEVEL_FIELD_SIZE = 1;
const int Ver4DictConstants::WORD_COUNT_FIELD_SIZE = 1;
const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_BLOCK_SIZE = 4;
const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_SIZE = 16;
const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_BLOCK_SIZE = 16;
const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_SIZE = 4;
const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_BLOCK_SIZE = 64;
const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE = 4;

View file

@ -34,7 +34,8 @@ uint32_t SparseTable::get(const int id) const {
const int indexTableReadingPos = getPosInIndexTable(id);
const int index = mIndexTableBuffer->readUint(INDEX_SIZE, indexTableReadingPos);
const int contentTableReadingPos = getPosInContentTable(id, index);
return mContentTableBuffer->readUint(mDataSize, contentTableReadingPos);
const int contentValue = mContentTableBuffer->readUint(mDataSize, contentTableReadingPos);
return contentValue == NOT_EXIST ? NOT_A_DICT_POS : contentValue;
}
bool SparseTable::set(const int id, const uint32_t value) {
@ -70,7 +71,7 @@ bool SparseTable::set(const int id, const uint32_t value) {
// Write a new block that containing the entry to be set.
int writingPos = getPosInContentTable(0 /* id */, index);
for (int i = 0; i < mBlockSize; ++i) {
if (!mContentTableBuffer->writeUintAndAdvancePosition(NOT_A_DICT_POS, mDataSize,
if (!mContentTableBuffer->writeUintAndAdvancePosition(NOT_EXIST, mDataSize,
&writingPos)) {
AKLOGE("cannot write content table to extend. writingPos: %d, tailPos: %d, "
"mDataSize: %d", writingPos, mContentTableBuffer->getTailPosition(), mDataSize);