diff options
| author | Peng Wu <alexepico@gmail.com> | 2026-04-24 14:26:24 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2026-04-24 14:26:51 +0800 |
| commit | 7165d2a8bc2d07fcaf422457dbab99656aa32296 (patch) | |
| tree | 09eaa4272b1b5f9cc43913fc3f30f64e587e341e | |
| parent | 0c5e80e1200f84fab185d1c5bde458b770a0636c (diff) | |
| -rw-r--r-- | src/storage/flexible_ngram_tkrzwdb.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/storage/flexible_ngram_tkrzwdb.h b/src/storage/flexible_ngram_tkrzwdb.h index c71500f..258bd8a 100644 --- a/src/storage/flexible_ngram_tkrzwdb.h +++ b/src/storage/flexible_ngram_tkrzwdb.h @@ -409,14 +409,16 @@ public: const size_t ksiz = sizeof(phrase_token_t); std::string value_str; + size_t vsiz = 0; char * vbuf = NULL; Status status = m_db->Get(std::string_view(kbuf, ksiz), &value_str); - if (!status.IsOK()) - return false; - - size_t vsiz = value_str.size(); - m_chunk.set_size(vsiz); - char * vbuf = (char *) m_chunk.begin(); - memcpy(vbuf, value_str.data(), vsiz); + if (!status.IsOK()) { + vsiz = sizeof(ArrayHeader); + } else { + vsiz = value_str.size(); + m_chunk.set_size(vsiz); + vbuf = (char *) m_chunk.begin(); + memcpy(vbuf, value_str.data(), vsiz); + } m_chunk.set_content(0, &header, sizeof(ArrayHeader)); |
