am b7677156: Merge "Fix: incompatibility of sparse table."

* commit 'b767715651a914ba2d89142d13e23eaf081d5b13':
  Fix: incompatibility of sparse table.
main
Keisuke Kuroyanagi 2013-12-16 06:58:42 -08:00 committed by Android Git Automerger
commit 3a98fcb3ee
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);