Remove isUpdatable from constructors of dict contents.

Change-Id: I2d54f477d9b341e944e265786a734f23d152bb81
This commit is contained in:
Keisuke Kuroyanagi 2014-07-10 20:14:36 +09:00
parent 2ac934296c
commit b22f95ec8a
8 changed files with 19 additions and 22 deletions

View file

@ -30,9 +30,8 @@ namespace latinime {
class BigramDictContent : public SparseTableDictContent { class BigramDictContent : public SparseTableDictContent {
public: public:
BigramDictContent(uint8_t *const *buffers, const int *bufferSizes, const bool hasHistoricalInfo, BigramDictContent(uint8_t *const *buffers, const int *bufferSizes, const bool hasHistoricalInfo)
const bool isUpdatable) : SparseTableDictContent(buffers, bufferSizes,
: SparseTableDictContent(buffers, bufferSizes, isUpdatable,
Ver4DictConstants::BIGRAM_ADDRESS_TABLE_BLOCK_SIZE, Ver4DictConstants::BIGRAM_ADDRESS_TABLE_BLOCK_SIZE,
Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_SIZE), Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_SIZE),
mHasHistoricalInfo(hasHistoricalInfo) {} mHasHistoricalInfo(hasHistoricalInfo) {}

View file

@ -33,8 +33,8 @@ class ProbabilityEntry;
class ProbabilityDictContent : public SingleDictContent { class ProbabilityDictContent : public SingleDictContent {
public: public:
ProbabilityDictContent(uint8_t *const buffer, const int bufferSize, ProbabilityDictContent(uint8_t *const buffer, const int bufferSize,
const bool hasHistoricalInfo, const bool isUpdatable) const bool hasHistoricalInfo)
: SingleDictContent(buffer, bufferSize, isUpdatable), : SingleDictContent(buffer, bufferSize),
mHasHistoricalInfo(hasHistoricalInfo), mHasHistoricalInfo(hasHistoricalInfo),
mSize(getBuffer()->getTailPosition() / getEntrySize()) {} mSize(getBuffer()->getTailPosition() / getEntrySize()) {}

View file

@ -29,8 +29,8 @@ namespace latinime {
class ShortcutDictContent : public SparseTableDictContent { class ShortcutDictContent : public SparseTableDictContent {
public: public:
ShortcutDictContent(uint8_t *const *buffers, const int *bufferSizes, const bool isUpdatable) ShortcutDictContent(uint8_t *const *buffers, const int *bufferSizes)
: SparseTableDictContent(buffers, bufferSizes, isUpdatable, : SparseTableDictContent(buffers, bufferSizes,
Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_BLOCK_SIZE, Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_BLOCK_SIZE,
Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE) {} Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE) {}

View file

@ -30,7 +30,7 @@ namespace latinime {
class SingleDictContent : public DictContent { class SingleDictContent : public DictContent {
public: public:
SingleDictContent(uint8_t *const buffer, const int bufferSize, const bool isUpdatable) SingleDictContent(uint8_t *const buffer, const int bufferSize)
: mExpandableContentBuffer(buffer, bufferSize, : mExpandableContentBuffer(buffer, bufferSize,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE) {} BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE) {}

View file

@ -32,7 +32,7 @@ namespace latinime {
class SparseTableDictContent : public DictContent { class SparseTableDictContent : public DictContent {
public: public:
AK_FORCE_INLINE SparseTableDictContent(uint8_t *const *buffers, const int *bufferSizes, AK_FORCE_INLINE SparseTableDictContent(uint8_t *const *buffers, const int *bufferSizes,
const bool isUpdatable, const int sparseTableBlockSize, const int sparseTableDataSize) const int sparseTableBlockSize, const int sparseTableDataSize)
: mExpandableLookupTableBuffer(buffers[LOOKUP_TABLE_BUFFER_INDEX], : mExpandableLookupTableBuffer(buffers[LOOKUP_TABLE_BUFFER_INDEX],
bufferSizes[LOOKUP_TABLE_BUFFER_INDEX], bufferSizes[LOOKUP_TABLE_BUFFER_INDEX],
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),

View file

@ -31,9 +31,8 @@ class TerminalPositionLookupTable : public SingleDictContent {
public: public:
typedef std::unordered_map<int, int> TerminalIdMap; typedef std::unordered_map<int, int> TerminalIdMap;
TerminalPositionLookupTable(uint8_t *const buffer, const int bufferSize, TerminalPositionLookupTable(uint8_t *const buffer, const int bufferSize)
const bool isUpdatable) : SingleDictContent(buffer, bufferSize),
: SingleDictContent(buffer, bufferSize, isUpdatable),
mSize(getBuffer()->getTailPosition() mSize(getBuffer()->getTailPosition()
/ Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE) {} / Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE) {}

View file

@ -39,7 +39,6 @@ namespace latinime {
} }
// TODO: take only dictDirPath, and open both header and trie files in the constructor below // TODO: take only dictDirPath, and open both header and trie files in the constructor below
const bool isUpdatable = headerBuffer->isUpdatable(); const bool isUpdatable = headerBuffer->isUpdatable();
MmappedBuffer::MmappedBufferPtr bodyBuffer = MmappedBuffer::openBuffer(dictPath, MmappedBuffer::MmappedBufferPtr bodyBuffer = MmappedBuffer::openBuffer(dictPath,
Ver4DictConstants::BODY_FILE_EXTENSION, isUpdatable); Ver4DictConstants::BODY_FILE_EXTENSION, isUpdatable);
if (!bodyBuffer) { if (!bodyBuffer) {
@ -64,7 +63,7 @@ namespace latinime {
return Ver4DictBuffersPtr(nullptr); return Ver4DictBuffersPtr(nullptr);
} }
return Ver4DictBuffersPtr(new Ver4DictBuffers(std::move(headerBuffer), std::move(bodyBuffer), return Ver4DictBuffersPtr(new Ver4DictBuffers(std::move(headerBuffer), std::move(bodyBuffer),
isUpdatable, formatVersion, buffers, bufferSizes)); formatVersion, buffers, bufferSizes));
} }
bool Ver4DictBuffers::flushHeaderAndDictBuffers(const char *const dictDirPath, bool Ver4DictBuffers::flushHeaderAndDictBuffers(const char *const dictDirPath,
@ -175,7 +174,7 @@ bool Ver4DictBuffers::flushDictBuffers(FILE *const file) const {
Ver4DictBuffers::Ver4DictBuffers(MmappedBuffer::MmappedBufferPtr &&headerBuffer, Ver4DictBuffers::Ver4DictBuffers(MmappedBuffer::MmappedBufferPtr &&headerBuffer,
MmappedBuffer::MmappedBufferPtr &&bodyBuffer, MmappedBuffer::MmappedBufferPtr &&bodyBuffer,
const bool isUpdatable, const FormatUtils::FORMAT_VERSION formatVersion, const FormatUtils::FORMAT_VERSION formatVersion,
const std::vector<uint8_t *> &contentBuffers, const std::vector<int> &contentBufferSizes) const std::vector<uint8_t *> &contentBuffers, const std::vector<int> &contentBufferSizes)
: mHeaderBuffer(std::move(headerBuffer)), mDictBuffer(std::move(bodyBuffer)), : mHeaderBuffer(std::move(headerBuffer)), mDictBuffer(std::move(bodyBuffer)),
mHeaderPolicy(mHeaderBuffer->getBuffer(), formatVersion), mHeaderPolicy(mHeaderBuffer->getBuffer(), formatVersion),
@ -187,18 +186,18 @@ Ver4DictBuffers::Ver4DictBuffers(MmappedBuffer::MmappedBufferPtr &&headerBuffer,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mTerminalPositionLookupTable( mTerminalPositionLookupTable(
contentBuffers[Ver4DictConstants::TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX], contentBuffers[Ver4DictConstants::TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX],
contentBufferSizes[Ver4DictConstants::TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX], contentBufferSizes[
isUpdatable), Ver4DictConstants::TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX]),
mProbabilityDictContent( mProbabilityDictContent(
contentBuffers[Ver4DictConstants::PROBABILITY_BUFFER_INDEX], contentBuffers[Ver4DictConstants::PROBABILITY_BUFFER_INDEX],
contentBufferSizes[Ver4DictConstants::PROBABILITY_BUFFER_INDEX], contentBufferSizes[Ver4DictConstants::PROBABILITY_BUFFER_INDEX],
mHeaderPolicy.hasHistoricalInfoOfWords(), isUpdatable), mHeaderPolicy.hasHistoricalInfoOfWords()),
mBigramDictContent(&contentBuffers[Ver4DictConstants::BIGRAM_BUFFERS_INDEX], mBigramDictContent(&contentBuffers[Ver4DictConstants::BIGRAM_BUFFERS_INDEX],
&contentBufferSizes[Ver4DictConstants::BIGRAM_BUFFERS_INDEX], &contentBufferSizes[Ver4DictConstants::BIGRAM_BUFFERS_INDEX],
mHeaderPolicy.hasHistoricalInfoOfWords(), isUpdatable), mHeaderPolicy.hasHistoricalInfoOfWords()),
mShortcutDictContent(&contentBuffers[Ver4DictConstants::SHORTCUT_BUFFERS_INDEX], mShortcutDictContent(&contentBuffers[Ver4DictConstants::SHORTCUT_BUFFERS_INDEX],
&contentBufferSizes[Ver4DictConstants::SHORTCUT_BUFFERS_INDEX], isUpdatable), &contentBufferSizes[Ver4DictConstants::SHORTCUT_BUFFERS_INDEX]),
mIsUpdatable(isUpdatable) {} mIsUpdatable(mDictBuffer->isUpdatable()) {}
Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy, const int maxTrieSize) Ver4DictBuffers::Ver4DictBuffers(const HeaderPolicy *const headerPolicy, const int maxTrieSize)
: mHeaderBuffer(nullptr), mDictBuffer(nullptr), mHeaderPolicy(headerPolicy), : mHeaderBuffer(nullptr), mDictBuffer(nullptr), mHeaderPolicy(headerPolicy),

View file

@ -121,7 +121,7 @@ class Ver4DictBuffers {
Ver4DictBuffers(MmappedBuffer::MmappedBufferPtr &&headerBuffer, Ver4DictBuffers(MmappedBuffer::MmappedBufferPtr &&headerBuffer,
MmappedBuffer::MmappedBufferPtr &&bodyBuffer, MmappedBuffer::MmappedBufferPtr &&bodyBuffer,
const bool isUpdatable, const FormatUtils::FORMAT_VERSION formatVersion, const FormatUtils::FORMAT_VERSION formatVersion,
const std::vector<uint8_t *> &contentBuffers, const std::vector<uint8_t *> &contentBuffers,
const std::vector<int> &contentBufferSizes); const std::vector<int> &contentBufferSizes);