diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2024-04-15 14:00:27 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2024-04-15 14:00:27 -0400 |
| commit | b25beb13773072c3b143842b45a7c32a1108f347 (patch) | |
| tree | 97f490a4b8e527e6281df2cb1ee8f1fab84f1f8d /include/shard | |
| parent | 2c69253f382cd0c6d41db57c45119c33c315bb9c (diff) | |
| download | dynamic-extension-b25beb13773072c3b143842b45a7c32a1108f347.tar.gz | |
Updated FSTrie to use const char * instead of std::string
Note: this requires the caller to manage the memory of the strings
Diffstat (limited to 'include/shard')
| -rw-r--r-- | include/shard/FSTrie.h | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/include/shard/FSTrie.h b/include/shard/FSTrie.h index 95f396f..be678ff 100644 --- a/include/shard/FSTrie.h +++ b/include/shard/FSTrie.h @@ -30,7 +30,7 @@ private: typedef decltype(R::key) K; typedef decltype(R::value) V; - static_assert(std::is_same_v<K, std::string>, "FST requires std::string keys."); + static_assert(std::is_same_v<K, const char*>, "FST requires const char* keys."); public: FSTrie(BufferView<R> buffer) @@ -42,7 +42,7 @@ public: m_alloc_size = sizeof(Wrapped<R>) * buffer.get_record_count(); size_t cnt = 0; - std::vector<K> keys; + std::vector<std::string> keys; keys.reserve(buffer.get_record_count()); /* @@ -68,14 +68,10 @@ public: m_data[cnt] = temp_buffer[i]; m_data[cnt].clear_timestamp(); - keys.push_back(m_data[cnt].rec.key); + keys.push_back(std::string(m_data[cnt].rec.key)); cnt++; } - for (size_t i=0; i<keys.size() - 1; i++) { - assert(keys[i] <= keys[i+1]); - } - m_reccnt = cnt; if (m_reccnt > 0) { m_fst = new fst::Trie(keys); @@ -96,7 +92,7 @@ public: m_data = new Wrapped<R>[attemp_reccnt](); m_alloc_size = attemp_reccnt * sizeof(Wrapped<R>); - std::vector<K> keys; + std::vector<std::string> keys; keys.reserve(attemp_reccnt); // FIXME: For smaller cursor arrays, it may be more efficient to skip @@ -128,7 +124,7 @@ public: /* skip over records that have been deleted via tagging */ if (!cursor.ptr->is_deleted() && cursor.ptr->rec.key != "") { m_data[m_reccnt] = *cursor.ptr; - keys.push_back(m_data[m_reccnt].rec.key); + keys.push_back(std::string(m_data[m_reccnt].rec.key)); m_reccnt++; } @@ -138,10 +134,6 @@ public: } } - for (size_t i=0; i<keys.size() - 1; i++) { - assert(keys[i] <= keys[i+1]); - } - if (m_reccnt > 0) { m_fst = new fst::Trie(keys); } |