Remove newBigramLinkedNodePos from ver4 format.
Bug: 11973488 Change-Id: I98045abaaf8566b1122fa5a531f8f48ad9562680
This commit is contained in:
parent
294fe541c8
commit
2cdb07c849
4 changed files with 7 additions and 21 deletions
|
@ -57,14 +57,13 @@ class PtNodeParams {
|
||||||
PtNodeParams(const int headPos, const PatriciaTrieReadingUtils::NodeFlags flags,
|
PtNodeParams(const int headPos, const PatriciaTrieReadingUtils::NodeFlags flags,
|
||||||
const int parentPos, const int codePointCount, const int *const codePoints,
|
const int parentPos, const int codePointCount, const int *const codePoints,
|
||||||
const int terminalIdFieldPos, const int terminalId, const int probability,
|
const int terminalIdFieldPos, const int terminalId, const int probability,
|
||||||
const int childrenPosFieldPos, const int childrenPos, const int bigramLinkedNodePos,
|
const int childrenPosFieldPos, const int childrenPos, const int siblingPos)
|
||||||
const int siblingPos)
|
|
||||||
: mHeadPos(headPos), mFlags(flags), mParentPos(parentPos),
|
: mHeadPos(headPos), mFlags(flags), mParentPos(parentPos),
|
||||||
mCodePointCount(codePointCount), mCodePoints(),
|
mCodePointCount(codePointCount), mCodePoints(),
|
||||||
mTerminalIdFieldPos(terminalIdFieldPos), mTerminalId(terminalId),
|
mTerminalIdFieldPos(terminalIdFieldPos), mTerminalId(terminalId),
|
||||||
mProbabilityFieldPos(NOT_A_DICT_POS), mProbability(probability),
|
mProbabilityFieldPos(NOT_A_DICT_POS), mProbability(probability),
|
||||||
mChildrenPosFieldPos(childrenPosFieldPos), mChildrenPos(childrenPos),
|
mChildrenPosFieldPos(childrenPosFieldPos), mChildrenPos(childrenPos),
|
||||||
mBigramLinkedNodePos(bigramLinkedNodePos), mShortcutPos(terminalId),
|
mBigramLinkedNodePos(NOT_A_DICT_POS), mShortcutPos(terminalId),
|
||||||
mBigramPos(terminalId), mSiblingPos(siblingPos) {
|
mBigramPos(terminalId), mSiblingPos(siblingPos) {
|
||||||
memcpy(mCodePoints, codePoints, sizeof(int) * mCodePointCount);
|
memcpy(mCodePoints, codePoints, sizeof(int) * mCodePointCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
const PtNodeParams Ver4PatriciaTrieNodeReader::fetchPtNodeInfoFromBufferAndProcessMovedPtNode(
|
const PtNodeParams Ver4PatriciaTrieNodeReader::fetchPtNodeInfoFromBufferAndProcessMovedPtNode(
|
||||||
const int ptNodePos, const int siblingNodePos, const int bigramLinkedNodePos) const {
|
const int ptNodePos, const int siblingNodePos) const {
|
||||||
if (ptNodePos < 0 || ptNodePos >= mBuffer->getTailPosition()) {
|
if (ptNodePos < 0 || ptNodePos >= mBuffer->getTailPosition()) {
|
||||||
// Reading invalid position because of bug or broken dictionary.
|
// Reading invalid position because of bug or broken dictionary.
|
||||||
AKLOGE("Fetching PtNode info from invalid dictionary position: %d, dictionary size: %d",
|
AKLOGE("Fetching PtNode info from invalid dictionary position: %d, dictionary size: %d",
|
||||||
|
@ -73,12 +73,6 @@ const PtNodeParams Ver4PatriciaTrieNodeReader::fetchPtNodeInfoFromBufferAndProce
|
||||||
if (usesAdditionalBuffer && childrenPos != NOT_A_DICT_POS) {
|
if (usesAdditionalBuffer && childrenPos != NOT_A_DICT_POS) {
|
||||||
childrenPos += mBuffer->getOriginalBufferSize();
|
childrenPos += mBuffer->getOriginalBufferSize();
|
||||||
}
|
}
|
||||||
int newBigramLinkedNodePos = bigramLinkedNodePos;
|
|
||||||
if (siblingNodePos == NOT_A_DICT_POS) {
|
|
||||||
if (DynamicPatriciaTrieReadingUtils::isMoved(flags)) {
|
|
||||||
newBigramLinkedNodePos = childrenPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (usesAdditionalBuffer) {
|
if (usesAdditionalBuffer) {
|
||||||
pos += mBuffer->getOriginalBufferSize();
|
pos += mBuffer->getOriginalBufferSize();
|
||||||
}
|
}
|
||||||
|
@ -87,12 +81,11 @@ const PtNodeParams Ver4PatriciaTrieNodeReader::fetchPtNodeInfoFromBufferAndProce
|
||||||
// Read destination node if the read node is a moved node.
|
// Read destination node if the read node is a moved node.
|
||||||
if (DynamicPatriciaTrieReadingUtils::isMoved(flags)) {
|
if (DynamicPatriciaTrieReadingUtils::isMoved(flags)) {
|
||||||
// The destination position is stored at the same place as the parent position.
|
// The destination position is stored at the same place as the parent position.
|
||||||
return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(parentPos, newSiblingNodePos,
|
return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(parentPos, newSiblingNodePos);
|
||||||
newBigramLinkedNodePos);
|
|
||||||
} else {
|
} else {
|
||||||
return PtNodeParams(headPos, flags, parentPos, codePonitCount, codePoints,
|
return PtNodeParams(headPos, flags, parentPos, codePonitCount, codePoints,
|
||||||
terminalIdFieldPos, terminalId, probability, childrenPosFieldPos, childrenPos,
|
terminalIdFieldPos, terminalId, probability, childrenPosFieldPos, childrenPos,
|
||||||
newBigramLinkedNodePos, newSiblingNodePos);
|
newSiblingNodePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Ver4PatriciaTrieNodeReader : public PtNodeReader {
|
||||||
|
|
||||||
virtual const PtNodeParams fetchNodeInfoInBufferFromPtNodePos(const int ptNodePos) const {
|
virtual const PtNodeParams fetchNodeInfoInBufferFromPtNodePos(const int ptNodePos) const {
|
||||||
return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(ptNodePos,
|
return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(ptNodePos,
|
||||||
NOT_A_DICT_POS /* siblingNodePos */, NOT_A_DICT_POS /* bigramLinkedNodePos */);
|
NOT_A_DICT_POS /* siblingNodePos */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -52,7 +52,7 @@ class Ver4PatriciaTrieNodeReader : public PtNodeReader {
|
||||||
const ProbabilityDictContent *const mProbabilityDictContent;
|
const ProbabilityDictContent *const mProbabilityDictContent;
|
||||||
|
|
||||||
const PtNodeParams fetchPtNodeInfoFromBufferAndProcessMovedPtNode(const int ptNodePos,
|
const PtNodeParams fetchPtNodeInfoFromBufferAndProcessMovedPtNode(const int ptNodePos,
|
||||||
const int siblingNodePos, const int bigramLinkedNodePos) const;
|
const int siblingNodePos) const;
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif /* LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H */
|
#endif /* LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H */
|
||||||
|
|
|
@ -86,12 +86,6 @@ bool Ver4PatriciaTrieNodeWriter::markPtNodeAsMoved(
|
||||||
mTrieBuffer, movedPos, toBeUpdatedPtNodeParams->getHeadPos(), &writingPos)) {
|
mTrieBuffer, movedPos, toBeUpdatedPtNodeParams->getHeadPos(), &writingPos)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Update bigram linked node position, which is stored in the children position field.
|
|
||||||
int childrenPosFieldPos = toBeUpdatedPtNodeParams->getChildrenPosFieldPos();
|
|
||||||
if (!DynamicPatriciaTrieWritingUtils::writeChildrenPositionAndAdvancePosition(
|
|
||||||
mTrieBuffer, bigramLinkedNodePos, &childrenPosFieldPos)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (toBeUpdatedPtNodeParams->hasChildren()) {
|
if (toBeUpdatedPtNodeParams->hasChildren()) {
|
||||||
// Update children's parent position.
|
// Update children's parent position.
|
||||||
mReadingHelper.initWithPtNodeArrayPos(toBeUpdatedPtNodeParams->getChildrenPos());
|
mReadingHelper.initWithPtNodeArrayPos(toBeUpdatedPtNodeParams->getChildrenPos());
|
||||||
|
|
Loading…
Reference in a new issue