diff options
author | Peng Wu <alexepico@gmail.com> | 2015-04-21 11:19:00 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-04-21 11:19:00 +0800 |
commit | 107f642630eed151e859583d493ee677b5b063b9 (patch) | |
tree | 872ace6691a67facb5e326eeb118878b5f4d7dac /src | |
parent | fb3a0fa827098b9c2f8885e1e55e761deccdac1d (diff) | |
download | libpinyin-107f642630eed151e859583d493ee677b5b063b9.tar.gz libpinyin-107f642630eed151e859583d493ee677b5b063b9.tar.xz libpinyin-107f642630eed151e859583d493ee677b5b063b9.zip |
add copy parameter to Bigram::load
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/flexible_ngram_bdb.h | 6 | ||||
-rw-r--r-- | src/storage/flexible_ngram_kyotodb.h | 6 | ||||
-rw-r--r-- | src/storage/ngram_bdb.cpp | 5 | ||||
-rw-r--r-- | src/storage/ngram_bdb.h | 3 | ||||
-rw-r--r-- | src/storage/ngram_kyotodb.cpp | 5 | ||||
-rw-r--r-- | src/storage/ngram_kyotodb.h | 4 |
6 files changed, 19 insertions, 10 deletions
diff --git a/src/storage/flexible_ngram_bdb.h b/src/storage/flexible_ngram_bdb.h index fd1e2ed..27bb7f8 100644 --- a/src/storage/flexible_ngram_bdb.h +++ b/src/storage/flexible_ngram_bdb.h @@ -157,13 +157,15 @@ public: * FlexibleBigram::load: * @index: the previous token in the flexible bi-gram. * @single_gram: the single gram of the previous token. + * @copy: whether copy content to the single gram. * @returns: whether the load operation is successful. * * Load the single gram of the previous token. * */ bool load(phrase_token_t index, - FlexibleSingleGram<ArrayHeader, ArrayItem> * & single_gram){ + FlexibleSingleGram<ArrayHeader, ArrayItem> * & single_gram, + bool copy=false){ single_gram = NULL; if ( !m_db ) return false; @@ -180,7 +182,7 @@ public: return false; single_gram = new FlexibleSingleGram<ArrayHeader, ArrayItem> - (db_data.data, db_data.size); + (db_data.data, db_data.size, copy); return true; } diff --git a/src/storage/flexible_ngram_kyotodb.h b/src/storage/flexible_ngram_kyotodb.h index a1396d2..660681e 100644 --- a/src/storage/flexible_ngram_kyotodb.h +++ b/src/storage/flexible_ngram_kyotodb.h @@ -184,13 +184,15 @@ public: * FlexibleBigram::load: * @index: the previous token in the flexible bi-gram. * @single_gram: the single gram of the previous token. + * @copy: whether copy content to the single gram. * @returns: whether the load operation is successful. * * Load the single gram of the previous token. * */ bool load(phrase_token_t index, - FlexibleSingleGram<ArrayHeader, ArrayItem> * & single_gram){ + FlexibleSingleGram<ArrayHeader, ArrayItem> * & single_gram, + bool copy=false){ single_gram = NULL; if ( !m_db ) return false; @@ -209,7 +211,7 @@ public: vbuf, vsiz)); single_gram = new FlexibleSingleGram<ArrayHeader, ArrayItem> - (m_chunk.begin(), vsiz); + (m_chunk.begin(), vsiz, copy); return true; } diff --git a/src/storage/ngram_bdb.cpp b/src/storage/ngram_bdb.cpp index 9d696ff..bba7c1d 100644 --- a/src/storage/ngram_bdb.cpp +++ b/src/storage/ngram_bdb.cpp @@ -173,7 +173,8 @@ bool Bigram::attach(const char * dbfile, guint32 flags){ return true; } -bool Bigram::load(phrase_token_t index, SingleGram * & single_gram){ +bool Bigram::load(phrase_token_t index, SingleGram * & single_gram, + bool copy){ single_gram = NULL; if ( !m_db ) return false; @@ -189,7 +190,7 @@ bool Bigram::load(phrase_token_t index, SingleGram * & single_gram){ if ( ret != 0 ) return false; - single_gram = new SingleGram(db_data.data, db_data.size); + single_gram = new SingleGram(db_data.data, db_data.size, copy); return true; } diff --git a/src/storage/ngram_bdb.h b/src/storage/ngram_bdb.h index a1e70d3..d7c8584 100644 --- a/src/storage/ngram_bdb.h +++ b/src/storage/ngram_bdb.h @@ -92,13 +92,14 @@ public: * Bigram::load: * @index: the previous token in the bi-gram. * @single_gram: the single gram of the previous token. + * @copy: whether copy content to the single gram. * @returns: whether the load operation is successful. * * Load the single gram of the previous token. * */ bool load(/* in */ phrase_token_t index, - /* out */ SingleGram * & single_gram); + /* out */ SingleGram * & single_gram, bool copy=false); /** * Bigram::store: diff --git a/src/storage/ngram_kyotodb.cpp b/src/storage/ngram_kyotodb.cpp index f2771ca..98d44dc 100644 --- a/src/storage/ngram_kyotodb.cpp +++ b/src/storage/ngram_kyotodb.cpp @@ -134,7 +134,8 @@ bool Bigram::attach(const char * dbfile, guint32 flags){ /* Use DB interface, first check, second reserve the memory chunk, third get value into the chunk. */ -bool Bigram::load(phrase_token_t index, SingleGram * & single_gram){ +bool Bigram::load(phrase_token_t index, SingleGram * & single_gram, + bool copy){ single_gram = NULL; if ( !m_db ) return false; @@ -150,7 +151,7 @@ bool Bigram::load(phrase_token_t index, SingleGram * & single_gram){ assert (vsiz == m_db->get(kbuf, sizeof(phrase_token_t), vbuf, vsiz)); - single_gram = new SingleGram(m_chunk.begin(), vsiz); + single_gram = new SingleGram(m_chunk.begin(), vsiz, copy); return true; } diff --git a/src/storage/ngram_kyotodb.h b/src/storage/ngram_kyotodb.h index 2c156de..39ca82a 100644 --- a/src/storage/ngram_kyotodb.h +++ b/src/storage/ngram_kyotodb.h @@ -96,13 +96,15 @@ public: * Bigram::load: * @index: the previous token in the bi-gram. * @single_gram: the single gram of the previous token. + * @copy: whether copy content to the single gram. * @returns: whether the load operation is successful. * * Load the single gram of the previous token. * */ bool load(/* in */ phrase_token_t index, - /* out */ SingleGram * & single_gram); + /* out */ SingleGram * & single_gram, + bool copy=false); /** * Bigram::store: |