Loading native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/content/single_dict_content.h +4 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h" #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading @@ -40,8 +41,9 @@ class SingleDictContent : public DictContent { SingleDictContent(const char *const dictPath, const char *const contentFileName, const bool isUpdatable) : mMmappedBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), mExpandableContentBuffer(mMmappedBuffer ? mMmappedBuffer->getBuffer() : nullptr, mMmappedBuffer ? mMmappedBuffer->getBufferSize() : 0, mExpandableContentBuffer( mMmappedBuffer ? mMmappedBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mIsValid(mMmappedBuffer) {} Loading native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/content/sparse_table_dict_content.h +8 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "suggest/policyimpl/dictionary/utils/sparse_table.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading @@ -50,15 +51,16 @@ class SparseTableDictContent : public DictContent { mContentBuffer( MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), mExpandableLookupTableBuffer( mLookupTableBuffer ? mLookupTableBuffer->getBuffer() : nullptr, mLookupTableBuffer ? mLookupTableBuffer->getBufferSize() : 0, mLookupTableBuffer ? mLookupTableBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableAddressTableBuffer( mAddressTableBuffer ? mAddressTableBuffer->getBuffer() : nullptr, mAddressTableBuffer ? mAddressTableBuffer->getBufferSize() : 0, mAddressTableBuffer ? mAddressTableBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableContentBuffer(mContentBuffer ? mContentBuffer->getBuffer() : nullptr, mContentBuffer ? mContentBuffer->getBufferSize() : 0, mExpandableContentBuffer( mContentBuffer ? mContentBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mAddressLookupTable(&mExpandableLookupTableBuffer, &mExpandableAddressTableBuffer, sparseTableBlockSize, sparseTableDataSize), Loading native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_dict_buffers.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/file_utils.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading Loading @@ -130,12 +131,12 @@ Ver4DictBuffers::Ver4DictBuffers(const char *const dictPath, : mHeaderBuffer(std::move(headerBuffer)), mDictBuffer(MmappedBuffer::openBuffer(dictPath, Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)), mHeaderPolicy(mHeaderBuffer->getBuffer(), formatVersion), mExpandableHeaderBuffer(mHeaderBuffer ? mHeaderBuffer->getBuffer() : nullptr, mHeaderPolicy.getSize(), mHeaderPolicy(mHeaderBuffer->getReadOnlyByteArrayView().data(), formatVersion), mExpandableHeaderBuffer(mHeaderBuffer->getReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableTrieBuffer(mDictBuffer ? mDictBuffer->getBuffer() : nullptr, mDictBuffer ? mDictBuffer->getBufferSize() : 0, mExpandableTrieBuffer( mDictBuffer ? mDictBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mTerminalPositionLookupTable(dictPath, isUpdatable), mProbabilityDictContent(dictPath, mHeaderPolicy.hasHistoricalInfoOfWords(), isUpdatable), Loading native/jni/src/suggest/policyimpl/dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "suggest/policyimpl/dictionary/utils/file_utils.h" #include "suggest/policyimpl/dictionary/utils/format_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { Loading Loading @@ -110,7 +111,8 @@ template<class DictConstants, class DictBuffers, class DictBuffersPtr, class Str return nullptr; } const FormatUtils::FORMAT_VERSION formatVersion = FormatUtils::detectFormatVersion( mmappedBuffer->getBuffer(), mmappedBuffer->getBufferSize()); mmappedBuffer->getReadOnlyByteArrayView().data(), mmappedBuffer->getReadOnlyByteArrayView().size()); switch (formatVersion) { case FormatUtils::VERSION_2: AKLOGE("Given path is a directory but the format is version 2. path: %s", path); Loading Loading @@ -172,8 +174,8 @@ template<class DictConstants, class DictBuffers, class DictBuffersPtr, class Str if (!mmappedBuffer) { return nullptr; } switch (FormatUtils::detectFormatVersion(mmappedBuffer->getBuffer(), mmappedBuffer->getBufferSize())) { switch (FormatUtils::detectFormatVersion(mmappedBuffer->getReadOnlyByteArrayView().data(), mmappedBuffer->getReadOnlyByteArrayView().size())) { case FormatUtils::VERSION_2: return DictionaryStructureWithBufferPolicy::StructurePolicyPtr( new PatriciaTriePolicy(std::move(mmappedBuffer))); Loading native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h +7 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include "suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.h" #include "suggest/policyimpl/dictionary/utils/format_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { Loading @@ -39,9 +40,12 @@ class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { public: PatriciaTriePolicy(MmappedBuffer::MmappedBufferPtr mmappedBuffer) : mMmappedBuffer(std::move(mmappedBuffer)), mHeaderPolicy(mMmappedBuffer->getBuffer(), FormatUtils::VERSION_2), mDictRoot(mMmappedBuffer->getBuffer() + mHeaderPolicy.getSize()), mDictBufferSize(mMmappedBuffer->getBufferSize() - mHeaderPolicy.getSize()), mHeaderPolicy(mMmappedBuffer->getReadOnlyByteArrayView().data(), FormatUtils::VERSION_2), mDictRoot(mMmappedBuffer->getReadOnlyByteArrayView().data() + mHeaderPolicy.getSize()), mDictBufferSize(mMmappedBuffer->getReadOnlyByteArrayView().size() - mHeaderPolicy.getSize()), mBigramListPolicy(mDictRoot, mDictBufferSize), mShortcutListPolicy(mDictRoot), mPtNodeReader(mDictRoot, mDictBufferSize, &mBigramListPolicy, &mShortcutListPolicy), mPtNodeArrayReader(mDictRoot, mDictBufferSize), Loading Loading
native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/content/single_dict_content.h +4 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h" #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading @@ -40,8 +41,9 @@ class SingleDictContent : public DictContent { SingleDictContent(const char *const dictPath, const char *const contentFileName, const bool isUpdatable) : mMmappedBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), mExpandableContentBuffer(mMmappedBuffer ? mMmappedBuffer->getBuffer() : nullptr, mMmappedBuffer ? mMmappedBuffer->getBufferSize() : 0, mExpandableContentBuffer( mMmappedBuffer ? mMmappedBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mIsValid(mMmappedBuffer) {} Loading
native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/content/sparse_table_dict_content.h +8 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "suggest/policyimpl/dictionary/utils/sparse_table.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading @@ -50,15 +51,16 @@ class SparseTableDictContent : public DictContent { mContentBuffer( MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), mExpandableLookupTableBuffer( mLookupTableBuffer ? mLookupTableBuffer->getBuffer() : nullptr, mLookupTableBuffer ? mLookupTableBuffer->getBufferSize() : 0, mLookupTableBuffer ? mLookupTableBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableAddressTableBuffer( mAddressTableBuffer ? mAddressTableBuffer->getBuffer() : nullptr, mAddressTableBuffer ? mAddressTableBuffer->getBufferSize() : 0, mAddressTableBuffer ? mAddressTableBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableContentBuffer(mContentBuffer ? mContentBuffer->getBuffer() : nullptr, mContentBuffer ? mContentBuffer->getBufferSize() : 0, mExpandableContentBuffer( mContentBuffer ? mContentBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mAddressLookupTable(&mExpandableLookupTableBuffer, &mExpandableAddressTableBuffer, sparseTableBlockSize, sparseTableDataSize), Loading
native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_dict_buffers.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" #include "suggest/policyimpl/dictionary/utils/file_utils.h" #include "utils/byte_array_view.h" namespace latinime { namespace backward { Loading Loading @@ -130,12 +131,12 @@ Ver4DictBuffers::Ver4DictBuffers(const char *const dictPath, : mHeaderBuffer(std::move(headerBuffer)), mDictBuffer(MmappedBuffer::openBuffer(dictPath, Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)), mHeaderPolicy(mHeaderBuffer->getBuffer(), formatVersion), mExpandableHeaderBuffer(mHeaderBuffer ? mHeaderBuffer->getBuffer() : nullptr, mHeaderPolicy.getSize(), mHeaderPolicy(mHeaderBuffer->getReadOnlyByteArrayView().data(), formatVersion), mExpandableHeaderBuffer(mHeaderBuffer->getReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mExpandableTrieBuffer(mDictBuffer ? mDictBuffer->getBuffer() : nullptr, mDictBuffer ? mDictBuffer->getBufferSize() : 0, mExpandableTrieBuffer( mDictBuffer ? mDictBuffer->getReadWriteByteArrayView() : ReadWriteByteArrayView(), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), mTerminalPositionLookupTable(dictPath, isUpdatable), mProbabilityDictContent(dictPath, mHeaderPolicy.hasHistoricalInfoOfWords(), isUpdatable), Loading
native/jni/src/suggest/policyimpl/dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "suggest/policyimpl/dictionary/utils/file_utils.h" #include "suggest/policyimpl/dictionary/utils/format_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { Loading Loading @@ -110,7 +111,8 @@ template<class DictConstants, class DictBuffers, class DictBuffersPtr, class Str return nullptr; } const FormatUtils::FORMAT_VERSION formatVersion = FormatUtils::detectFormatVersion( mmappedBuffer->getBuffer(), mmappedBuffer->getBufferSize()); mmappedBuffer->getReadOnlyByteArrayView().data(), mmappedBuffer->getReadOnlyByteArrayView().size()); switch (formatVersion) { case FormatUtils::VERSION_2: AKLOGE("Given path is a directory but the format is version 2. path: %s", path); Loading Loading @@ -172,8 +174,8 @@ template<class DictConstants, class DictBuffers, class DictBuffersPtr, class Str if (!mmappedBuffer) { return nullptr; } switch (FormatUtils::detectFormatVersion(mmappedBuffer->getBuffer(), mmappedBuffer->getBufferSize())) { switch (FormatUtils::detectFormatVersion(mmappedBuffer->getReadOnlyByteArrayView().data(), mmappedBuffer->getReadOnlyByteArrayView().size())) { case FormatUtils::VERSION_2: return DictionaryStructureWithBufferPolicy::StructurePolicyPtr( new PatriciaTriePolicy(std::move(mmappedBuffer))); Loading
native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h +7 −3 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include "suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.h" #include "suggest/policyimpl/dictionary/utils/format_utils.h" #include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" #include "utils/byte_array_view.h" namespace latinime { Loading @@ -39,9 +40,12 @@ class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { public: PatriciaTriePolicy(MmappedBuffer::MmappedBufferPtr mmappedBuffer) : mMmappedBuffer(std::move(mmappedBuffer)), mHeaderPolicy(mMmappedBuffer->getBuffer(), FormatUtils::VERSION_2), mDictRoot(mMmappedBuffer->getBuffer() + mHeaderPolicy.getSize()), mDictBufferSize(mMmappedBuffer->getBufferSize() - mHeaderPolicy.getSize()), mHeaderPolicy(mMmappedBuffer->getReadOnlyByteArrayView().data(), FormatUtils::VERSION_2), mDictRoot(mMmappedBuffer->getReadOnlyByteArrayView().data() + mHeaderPolicy.getSize()), mDictBufferSize(mMmappedBuffer->getReadOnlyByteArrayView().size() - mHeaderPolicy.getSize()), mBigramListPolicy(mDictRoot, mDictBufferSize), mShortcutListPolicy(mDictRoot), mPtNodeReader(mDictRoot, mDictBufferSize, &mBigramListPolicy, &mShortcutListPolicy), mPtNodeArrayReader(mDictRoot, mDictBufferSize), Loading