am 54653533: Merge "Fix offdevice build."
* commit '54653533d2072b7d0983a6fb1635b06c140d98b1': Fix offdevice build.main
commit
777ea9a2dd
|
@ -25,6 +25,13 @@
|
|||
|
||||
namespace latinime {
|
||||
|
||||
/* static */ Ver4DictBuffers::Ver4DictBuffersPtr Ver4DictBuffers::openVer4DictBuffers(
|
||||
const char *const dictDirPath, const MmappedBuffer::MmappedBufferPtr &headerBuffer) {
|
||||
const bool isUpdatable = headerBuffer.get() ? headerBuffer.get()->isUpdatable() : false;
|
||||
// TODO: take only dictDirPath, and open both header and trie files in the constructor below
|
||||
return Ver4DictBuffersPtr(new Ver4DictBuffers(dictDirPath, headerBuffer, isUpdatable));
|
||||
}
|
||||
|
||||
bool Ver4DictBuffers::flushHeaderAndDictBuffers(const char *const dictDirPath,
|
||||
const BufferWithExtendableBuffer *const headerBuffer) const {
|
||||
// Create temporary directory.
|
||||
|
@ -91,4 +98,32 @@ bool Ver4DictBuffers::flushHeaderAndDictBuffers(const char *const dictDirPath,
|
|||
return true;
|
||||
}
|
||||
|
||||
Ver4DictBuffers::Ver4DictBuffers(const char *const dictDirPath,
|
||||
const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable)
|
||||
: mHeaderBuffer(headerBuffer),
|
||||
mDictBuffer(MmappedBuffer::openBuffer(dictDirPath,
|
||||
Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
|
||||
mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
|
||||
mExpandableHeaderBuffer(headerBuffer.get()->getBuffer(), mHeaderPolicy.getSize(),
|
||||
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
|
||||
mExpandableTrieBuffer(mDictBuffer.get()->getBuffer(),
|
||||
mDictBuffer.get()->getBufferSize(),
|
||||
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
|
||||
mTerminalPositionLookupTable(dictDirPath, isUpdatable),
|
||||
mProbabilityDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
|
||||
isUpdatable),
|
||||
mBigramDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
|
||||
isUpdatable),
|
||||
mShortcutDictContent(dictDirPath, isUpdatable),
|
||||
mIsUpdatable(isUpdatable) {}
|
||||
|
||||
Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy)
|
||||
: mHeaderBuffer(0), mDictBuffer(0), mHeaderPolicy(),
|
||||
mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
|
||||
mExpandableTrieBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
|
||||
mTerminalPositionLookupTable(),
|
||||
mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()),
|
||||
mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(),
|
||||
mIsUpdatable(true) {}
|
||||
|
||||
} // namespace latinime
|
||||
|
|
|
@ -33,12 +33,8 @@ class Ver4DictBuffers {
|
|||
public:
|
||||
typedef ExclusiveOwnershipPointer<Ver4DictBuffers> Ver4DictBuffersPtr;
|
||||
|
||||
static AK_FORCE_INLINE Ver4DictBuffersPtr openVer4DictBuffers(const char *const dictDirPath,
|
||||
const MmappedBuffer::MmappedBufferPtr &headerBuffer) {
|
||||
const bool isUpdatable = headerBuffer.get() ? headerBuffer.get()->isUpdatable() : false;
|
||||
// TODO: take only dictDirPath, and open both header and trie files in the constructor below
|
||||
return Ver4DictBuffersPtr(new Ver4DictBuffers(dictDirPath, headerBuffer, isUpdatable));
|
||||
}
|
||||
static Ver4DictBuffersPtr openVer4DictBuffers(const char *const dictDirPath,
|
||||
const MmappedBuffer::MmappedBufferPtr &headerBuffer);
|
||||
|
||||
static AK_FORCE_INLINE Ver4DictBuffersPtr createVer4DictBuffers(
|
||||
const HeaderPolicy *const headerPolicy) {
|
||||
|
@ -121,33 +117,10 @@ class Ver4DictBuffers {
|
|||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Ver4DictBuffers);
|
||||
|
||||
AK_FORCE_INLINE Ver4DictBuffers(const char *const dictDirPath,
|
||||
const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable)
|
||||
: mHeaderBuffer(headerBuffer),
|
||||
mDictBuffer(MmappedBuffer::openBuffer(dictDirPath,
|
||||
Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
|
||||
mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
|
||||
mExpandableHeaderBuffer(headerBuffer.get()->getBuffer(), mHeaderPolicy.getSize(),
|
||||
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
|
||||
mExpandableTrieBuffer(mDictBuffer.get()->getBuffer(),
|
||||
mDictBuffer.get()->getBufferSize(),
|
||||
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
|
||||
mTerminalPositionLookupTable(dictDirPath, isUpdatable),
|
||||
mProbabilityDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
|
||||
isUpdatable),
|
||||
mBigramDictContent(dictDirPath, mHeaderPolicy.hasHistoricalInfoOfWords(),
|
||||
isUpdatable),
|
||||
mShortcutDictContent(dictDirPath, isUpdatable),
|
||||
mIsUpdatable(isUpdatable) {}
|
||||
Ver4DictBuffers(const char *const dictDirPath,
|
||||
const MmappedBuffer::MmappedBufferPtr &headerBuffer, const bool isUpdatable);
|
||||
|
||||
AK_FORCE_INLINE Ver4DictBuffers(const HeaderPolicy *const headerPolicy)
|
||||
: mHeaderBuffer(0), mDictBuffer(0), mHeaderPolicy(),
|
||||
mExpandableHeaderBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
|
||||
mExpandableTrieBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
|
||||
mTerminalPositionLookupTable(),
|
||||
mProbabilityDictContent(headerPolicy->hasHistoricalInfoOfWords()),
|
||||
mBigramDictContent(headerPolicy->hasHistoricalInfoOfWords()), mShortcutDictContent(),
|
||||
mIsUpdatable(true) {}
|
||||
Ver4DictBuffers(const HeaderPolicy *const headerPolicy);
|
||||
|
||||
const MmappedBuffer::MmappedBufferPtr mHeaderBuffer;
|
||||
const MmappedBuffer::MmappedBufferPtr mDictBuffer;
|
||||
|
|
|
@ -25,22 +25,23 @@ template<class T>
|
|||
class ExclusiveOwnershipPointer {
|
||||
public:
|
||||
// This instance become an owner of the raw pointer.
|
||||
ExclusiveOwnershipPointer(T *const rawPointer)
|
||||
AK_FORCE_INLINE ExclusiveOwnershipPointer(T *const rawPointer)
|
||||
: mPointer(rawPointer),
|
||||
mSharedOwnerPtr(new (ExclusiveOwnershipPointer<T> *)(this)) {}
|
||||
|
||||
// Move the ownership.
|
||||
ExclusiveOwnershipPointer(const ExclusiveOwnershipPointer<T> &pointer)
|
||||
AK_FORCE_INLINE ExclusiveOwnershipPointer(const ExclusiveOwnershipPointer<T> &pointer)
|
||||
: mPointer(pointer.mPointer), mSharedOwnerPtr(pointer.mSharedOwnerPtr) {
|
||||
transferOwnership(&pointer);
|
||||
}
|
||||
|
||||
~ExclusiveOwnershipPointer() {
|
||||
AK_FORCE_INLINE ~ExclusiveOwnershipPointer() {
|
||||
deletePointersIfHavingOwnership();
|
||||
}
|
||||
|
||||
// Move the ownership.
|
||||
ExclusiveOwnershipPointer<T> &operator=(const ExclusiveOwnershipPointer<T> &pointer) {
|
||||
AK_FORCE_INLINE ExclusiveOwnershipPointer<T> &operator=(
|
||||
const ExclusiveOwnershipPointer<T> &pointer) {
|
||||
// Delete pointers when this is an owner of another pointer.
|
||||
deletePointersIfHavingOwnership();
|
||||
mPointer = pointer.mPointer;
|
||||
|
@ -49,7 +50,7 @@ class ExclusiveOwnershipPointer {
|
|||
return *this;
|
||||
}
|
||||
|
||||
T *get() const {
|
||||
AK_FORCE_INLINE T *get() const {
|
||||
return mPointer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue