am 64faafbb: Merge "Stop passing buffer directly to DynamicPtReadingHelper."

* commit '64faafbb0e0a048997cc52e7198e789baa14e85c':
  Stop passing buffer directly to DynamicPtReadingHelper.
main
Keisuke Kuroyanagi 2014-02-10 04:27:18 -08:00 committed by Android Git Automerger
commit b4747d8300
4 changed files with 12 additions and 18 deletions

View File

@ -26,7 +26,6 @@
namespace latinime {
class BufferWithExtendableBuffer;
class DictionaryBigramsStructurePolicy;
class DictionaryShortcutsStructurePolicy;
class PtNodeArrayReader;
@ -75,12 +74,10 @@ class DynamicPtReadingHelper {
std::vector<int> *const mTerminalPositions;
};
DynamicPtReadingHelper(const BufferWithExtendableBuffer *const buffer,
const PtNodeReader *const ptNodeReader,
DynamicPtReadingHelper(const PtNodeReader *const ptNodeReader,
const PtNodeArrayReader *const ptNodeArrayReader)
: mIsError(false), mReadingState(), mBuffer(buffer),
mPtNodeReader(ptNodeReader), mPtNodeArrayReader(ptNodeArrayReader),
mReadingStateStack() {}
: mIsError(false), mReadingState(), mPtNodeReader(ptNodeReader),
mPtNodeArrayReader(ptNodeArrayReader), mReadingStateStack() {}
~DynamicPtReadingHelper() {}
@ -255,7 +252,6 @@ class DynamicPtReadingHelper {
// TODO: Introduce error code to track what caused the error.
bool mIsError;
PtNodeReadingState mReadingState;
const BufferWithExtendableBuffer *const mBuffer;
const PtNodeReader *const mPtNodeReader;
const PtNodeArrayReader *const mPtNodeArrayReader;
std::vector<PtNodeReadingState> mReadingStateStack;

View File

@ -44,8 +44,8 @@ class Ver4PatriciaTrieNodeWriter : public PtNodeWriter {
const PtNodeArrayReader *const ptNodeArrayReader,
Ver4BigramListPolicy *const bigramPolicy, Ver4ShortcutListPolicy *const shortcutPolicy)
: mTrieBuffer(trieBuffer), mBuffers(buffers),
mReadingHelper(mTrieBuffer, ptNodeReader, ptNodeArrayReader),
mBigramPolicy(bigramPolicy), mShortcutPolicy(shortcutPolicy) {}
mReadingHelper(ptNodeReader, ptNodeArrayReader), mBigramPolicy(bigramPolicy),
mShortcutPolicy(shortcutPolicy) {}
virtual ~Ver4PatriciaTrieNodeWriter() {}

View File

@ -43,7 +43,7 @@ void Ver4PatriciaTriePolicy::createAndGetAllChildDicNodes(const DicNode *const d
if (!dicNode->hasChildren()) {
return;
}
DynamicPtReadingHelper readingHelper(mDictBuffer, &mNodeReader, &mPtNodeArrayReader);
DynamicPtReadingHelper readingHelper(&mNodeReader, &mPtNodeArrayReader);
readingHelper.initWithPtNodeArrayPos(dicNode->getChildrenPtNodeArrayPos());
while (!readingHelper.isEnd()) {
const PtNodeParams ptNodeParams = readingHelper.getPtNodeParams();
@ -70,7 +70,7 @@ void Ver4PatriciaTriePolicy::createAndGetAllChildDicNodes(const DicNode *const d
int Ver4PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount(
const int ptNodePos, const int maxCodePointCount, int *const outCodePoints,
int *const outUnigramProbability) const {
DynamicPtReadingHelper readingHelper(mDictBuffer, &mNodeReader, &mPtNodeArrayReader);
DynamicPtReadingHelper readingHelper(&mNodeReader, &mPtNodeArrayReader);
readingHelper.initWithPtNodePos(ptNodePos);
return readingHelper.getCodePointsAndProbabilityAndReturnCodePointCount(
maxCodePointCount, outCodePoints, outUnigramProbability);
@ -78,7 +78,7 @@ int Ver4PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount(
int Ver4PatriciaTriePolicy::getTerminalPtNodePositionOfWord(const int *const inWord,
const int length, const bool forceLowerCaseSearch) const {
DynamicPtReadingHelper readingHelper(mDictBuffer, &mNodeReader, &mPtNodeArrayReader);
DynamicPtReadingHelper readingHelper(&mNodeReader, &mPtNodeArrayReader);
readingHelper.initWithPtNodeArrayPos(getRootPosition());
return readingHelper.getTerminalPtNodePositionOfWord(inWord, length, forceLowerCaseSearch);
}
@ -158,7 +158,7 @@ bool Ver4PatriciaTriePolicy::addUnigramWord(const int *const word, const int len
shortcutLength);
return false;
}
DynamicPtReadingHelper readingHelper(mDictBuffer, &mNodeReader, &mPtNodeArrayReader);
DynamicPtReadingHelper readingHelper(&mNodeReader, &mPtNodeArrayReader);
readingHelper.initWithPtNodeArrayPos(getRootPosition());
bool addedNewUnigram = false;
if (mUpdatingHelper.addUnigramWord(&readingHelper, word, length, probability, isNotAWord,
@ -397,7 +397,7 @@ int Ver4PatriciaTriePolicy::getNextWordAndNextToken(const int token, int *const
mTerminalPtNodePositionsForIteratingWords.clear();
DynamicPtReadingHelper::TraversePolicyToGetAllTerminalPtNodePositions traversePolicy(
&mTerminalPtNodePositionsForIteratingWords);
DynamicPtReadingHelper readingHelper(mDictBuffer, &mNodeReader, &mPtNodeArrayReader);
DynamicPtReadingHelper readingHelper(&mNodeReader, &mPtNodeArrayReader);
readingHelper.initWithPtNodeArrayPos(getRootPosition());
readingHelper.traverseAllPtNodesInPostorderDepthFirstManner(&traversePolicy);
}

View File

@ -83,8 +83,7 @@ bool Ver4PatriciaTrieWritingHelper::runGC(const int rootPtNodeArrayPos,
Ver4PatriciaTrieNodeWriter ptNodeWriter(mBuffers->getWritableTrieBuffer(),
mBuffers, &ptNodeReader, &ptNodeArrayReader, &bigramPolicy, &shortcutPolicy);
DynamicPtReadingHelper readingHelper(mBuffers->getTrieBuffer(), &ptNodeReader,
&ptNodeArrayReader);
DynamicPtReadingHelper readingHelper(&ptNodeReader, &ptNodeArrayReader);
readingHelper.initWithPtNodeArrayPos(rootPtNodeArrayPos);
DynamicPtGcEventListeners
::TraversePolicyToUpdateUnigramProbabilityAndMarkUselessPtNodesAsDeleted
@ -168,8 +167,7 @@ bool Ver4PatriciaTrieWritingHelper::runGC(const int rootPtNodeArrayPos,
mBuffers->getShortcutDictContent())) {
return false;
}
DynamicPtReadingHelper newDictReadingHelper(buffersToWrite->getTrieBuffer(),
&newPtNodeReader, &newPtNodeArrayreader);
DynamicPtReadingHelper newDictReadingHelper(&newPtNodeReader, &newPtNodeArrayreader);
newDictReadingHelper.initWithPtNodeArrayPos(rootPtNodeArrayPos);
DynamicPtGcEventListeners::TraversePolicyToUpdateAllPositionFields
traversePolicyToUpdateAllPositionFields(&newPtNodeWriter, &dictPositionRelocationMap);