From 2cdb07c8498dd0ca9d811e478104ab42f8c0a9ea Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Tue, 3 Dec 2013 21:39:16 +0900 Subject: [PATCH] Remove newBigramLinkedNodePos from ver4 format. Bug: 11973488 Change-Id: I98045abaaf8566b1122fa5a531f8f48ad9562680 --- .../dictionary/structure/pt_common/pt_node_params.h | 5 ++--- .../structure/v4/ver4_patricia_trie_node_reader.cpp | 13 +++---------- .../structure/v4/ver4_patricia_trie_node_reader.h | 4 ++-- .../structure/v4/ver4_patricia_trie_node_writer.cpp | 6 ------ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h index b5ef61b51..e99bb216a 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h @@ -57,14 +57,13 @@ class PtNodeParams { PtNodeParams(const int headPos, const PatriciaTrieReadingUtils::NodeFlags flags, const int parentPos, const int codePointCount, const int *const codePoints, const int terminalIdFieldPos, const int terminalId, const int probability, - const int childrenPosFieldPos, const int childrenPos, const int bigramLinkedNodePos, - const int siblingPos) + const int childrenPosFieldPos, const int childrenPos, const int siblingPos) : mHeadPos(headPos), mFlags(flags), mParentPos(parentPos), mCodePointCount(codePointCount), mCodePoints(), mTerminalIdFieldPos(terminalIdFieldPos), mTerminalId(terminalId), mProbabilityFieldPos(NOT_A_DICT_POS), mProbability(probability), mChildrenPosFieldPos(childrenPosFieldPos), mChildrenPos(childrenPos), - mBigramLinkedNodePos(bigramLinkedNodePos), mShortcutPos(terminalId), + mBigramLinkedNodePos(NOT_A_DICT_POS), mShortcutPos(terminalId), mBigramPos(terminalId), mSiblingPos(siblingPos) { memcpy(mCodePoints, codePoints, sizeof(int) * mCodePointCount); } diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp index 9f7b34d5b..3926a93a2 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp @@ -26,7 +26,7 @@ namespace latinime { 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()) { // Reading invalid position because of bug or broken dictionary. 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) { childrenPos += mBuffer->getOriginalBufferSize(); } - int newBigramLinkedNodePos = bigramLinkedNodePos; - if (siblingNodePos == NOT_A_DICT_POS) { - if (DynamicPatriciaTrieReadingUtils::isMoved(flags)) { - newBigramLinkedNodePos = childrenPos; - } - } if (usesAdditionalBuffer) { pos += mBuffer->getOriginalBufferSize(); } @@ -87,12 +81,11 @@ const PtNodeParams Ver4PatriciaTrieNodeReader::fetchPtNodeInfoFromBufferAndProce // Read destination node if the read node is a moved node. if (DynamicPatriciaTrieReadingUtils::isMoved(flags)) { // The destination position is stored at the same place as the parent position. - return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(parentPos, newSiblingNodePos, - newBigramLinkedNodePos); + return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(parentPos, newSiblingNodePos); } else { return PtNodeParams(headPos, flags, parentPos, codePonitCount, codePoints, terminalIdFieldPos, terminalId, probability, childrenPosFieldPos, childrenPos, - newBigramLinkedNodePos, newSiblingNodePos); + newSiblingNodePos); } } diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h index bdae0de7e..9d932457c 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h @@ -42,7 +42,7 @@ class Ver4PatriciaTrieNodeReader : public PtNodeReader { virtual const PtNodeParams fetchNodeInfoInBufferFromPtNodePos(const int ptNodePos) const { return fetchPtNodeInfoFromBufferAndProcessMovedPtNode(ptNodePos, - NOT_A_DICT_POS /* siblingNodePos */, NOT_A_DICT_POS /* bigramLinkedNodePos */); + NOT_A_DICT_POS /* siblingNodePos */); } private: @@ -52,7 +52,7 @@ class Ver4PatriciaTrieNodeReader : public PtNodeReader { const ProbabilityDictContent *const mProbabilityDictContent; const PtNodeParams fetchPtNodeInfoFromBufferAndProcessMovedPtNode(const int ptNodePos, - const int siblingNodePos, const int bigramLinkedNodePos) const; + const int siblingNodePos) const; }; } // namespace latinime #endif /* LATINIME_VER4_PATRICIA_TRIE_NODE_READER_H */ diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp index 15a3b2461..483c85440 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp @@ -86,12 +86,6 @@ bool Ver4PatriciaTrieNodeWriter::markPtNodeAsMoved( mTrieBuffer, movedPos, toBeUpdatedPtNodeParams->getHeadPos(), &writingPos)) { 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()) { // Update children's parent position. mReadingHelper.initWithPtNodeArrayPos(toBeUpdatedPtNodeParams->getChildrenPos());