am b7677156: Merge "Fix: incompatibility of sparse table."
* commit 'b767715651a914ba2d89142d13e23eaf081d5b13': Fix: incompatibility of sparse table.main
commit
3a98fcb3ee
|
@ -48,8 +48,8 @@ const int Ver4DictConstants::TIME_STAMP_FIELD_SIZE = 4;
|
||||||
const int Ver4DictConstants::WORD_LEVEL_FIELD_SIZE = 1;
|
const int Ver4DictConstants::WORD_LEVEL_FIELD_SIZE = 1;
|
||||||
const int Ver4DictConstants::WORD_COUNT_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_BLOCK_SIZE = 16;
|
||||||
const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_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_BLOCK_SIZE = 64;
|
||||||
const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE = 4;
|
const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE = 4;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ uint32_t SparseTable::get(const int id) const {
|
||||||
const int indexTableReadingPos = getPosInIndexTable(id);
|
const int indexTableReadingPos = getPosInIndexTable(id);
|
||||||
const int index = mIndexTableBuffer->readUint(INDEX_SIZE, indexTableReadingPos);
|
const int index = mIndexTableBuffer->readUint(INDEX_SIZE, indexTableReadingPos);
|
||||||
const int contentTableReadingPos = getPosInContentTable(id, index);
|
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) {
|
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.
|
// Write a new block that containing the entry to be set.
|
||||||
int writingPos = getPosInContentTable(0 /* id */, index);
|
int writingPos = getPosInContentTable(0 /* id */, index);
|
||||||
for (int i = 0; i < mBlockSize; ++i) {
|
for (int i = 0; i < mBlockSize; ++i) {
|
||||||
if (!mContentTableBuffer->writeUintAndAdvancePosition(NOT_A_DICT_POS, mDataSize,
|
if (!mContentTableBuffer->writeUintAndAdvancePosition(NOT_EXIST, mDataSize,
|
||||||
&writingPos)) {
|
&writingPos)) {
|
||||||
AKLOGE("cannot write content table to extend. writingPos: %d, tailPos: %d, "
|
AKLOGE("cannot write content table to extend. writingPos: %d, tailPos: %d, "
|
||||||
"mDataSize: %d", writingPos, mContentTableBuffer->getTailPosition(), mDataSize);
|
"mDataSize: %d", writingPos, mContentTableBuffer->getTailPosition(), mDataSize);
|
||||||
|
|
Loading…
Reference in New Issue