From a111cb132325137c391f1752bc5ee71453e474ef Mon Sep 17 00:00:00 2001 From: "andrew (from workstation)" Date: Thu, 14 May 2020 21:13:14 +0200 Subject: [PATCH] triplo malloc su ogni cosa --- td/telegram/DialogDb.cpp | 248 +------------------------------ td/telegram/DocumentsManager.cpp | 4 + td/telegram/DocumentsManager.h | 2 + td/telegram/DocumentsManager.hpp | 4 +- td/telegram/StickersManager.cpp | 60 +++++--- td/telegram/StickersManager.hpp | 4 +- td/telegram/Td.cpp | 1 + tddb/td/db/SqliteKeyValue.cpp | 88 +---------- tddb/td/db/SqliteKeyValue.h | 17 +-- 9 files changed, 69 insertions(+), 359 deletions(-) diff --git a/td/telegram/DialogDb.cpp b/td/telegram/DialogDb.cpp index 29628ac4..3fd73fa0 100644 --- a/td/telegram/DialogDb.cpp +++ b/td/telegram/DialogDb.cpp @@ -5,289 +5,71 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/DialogDb.h" - -#include "td/telegram/Version.h" - #include "td/actor/actor.h" #include "td/actor/SchedulerLocalStorage.h" #include "td/db/SqliteConnectionSafe.h" #include "td/db/SqliteDb.h" -#include "td/db/SqliteKeyValue.h" #include "td/db/SqliteStatement.h" -#include "td/utils/format.h" -#include "td/utils/logging.h" #include "td/utils/ScopeGuard.h" #include "td/utils/Time.h" namespace td { // NB: must happen inside a transaction Status init_dialog_db(SqliteDb &db, int32 version, bool &was_created) { - LOG(INFO) << "Init dialog database " << tag("version", version); - was_created = false; - - // Check if database exists - TRY_RESULT(has_table, db.has_table("dialogs")); - if (!has_table) { - version = 0; - } - - if (version < static_cast(DbVersion::DialogDbCreated) || version > current_db_version()) { - TRY_STATUS(drop_dialog_db(db, version)); - version = 0; - } - - auto create_notification_group_table = [&db] { - return db.exec( - "CREATE TABLE IF NOT EXISTS notification_groups (notification_group_id INT4 PRIMARY KEY, dialog_id " - "INT8, last_notification_date INT4)"); - }; - - auto create_last_notification_date_index = [&db] { - return db.exec( - "CREATE INDEX IF NOT EXISTS notification_group_by_last_notification_date ON notification_groups " - "(last_notification_date, dialog_id, notification_group_id) WHERE last_notification_date IS NOT NULL"); - }; - - auto add_dialogs_in_folder_index = [&db] { - return db.exec( - "CREATE INDEX IF NOT EXISTS dialog_in_folder_by_dialog_order ON dialogs (folder_id, dialog_order, dialog_id) " - "WHERE folder_id IS NOT NULL"); - }; - - if (version == 0) { - LOG(INFO) << "Create new dialog database"; - was_created = true; - TRY_STATUS( - db.exec("CREATE TABLE IF NOT EXISTS dialogs (dialog_id INT8 PRIMARY KEY, dialog_order INT8, data BLOB, " - "folder_id INT4)")); - TRY_STATUS(create_notification_group_table()); - TRY_STATUS(create_last_notification_date_index()); - TRY_STATUS(add_dialogs_in_folder_index()); - version = current_db_version(); - } - if (version < static_cast(DbVersion::AddNotificationsSupport)) { - TRY_STATUS(create_notification_group_table()); - TRY_STATUS(create_last_notification_date_index()); - } - if (version < static_cast(DbVersion::AddFolders)) { - TRY_STATUS(db.exec("DROP INDEX IF EXISTS dialog_by_dialog_order")); - TRY_STATUS(db.exec("ALTER TABLE dialogs ADD COLUMN folder_id INT4")); - TRY_STATUS(add_dialogs_in_folder_index()); - TRY_STATUS(db.exec("UPDATE dialogs SET folder_id = 0 WHERE dialog_id < -1500000000000 AND dialog_order > 0")); - } - return Status::OK(); } // NB: must happen inside a transaction Status drop_dialog_db(SqliteDb &db, int version) { - if (version < static_cast(DbVersion::DialogDbCreated)) { - LOG(WARNING) << "Drop old pmc dialog_db"; - SqliteKeyValue kv; - kv.init_with_connection(db.clone(), "common").ensure(); - kv.erase_by_prefix("di"); - } - - LOG(WARNING) << "Drop dialog_db " << tag("version", version) << tag("current_db_version", current_db_version()); - auto status = db.exec("DROP TABLE IF EXISTS dialogs"); - TRY_STATUS(db.exec("DROP TABLE IF EXISTS notification_groups")); - return status; + return Status::OK(); } class DialogDbImpl : public DialogDbSyncInterface { public: - explicit DialogDbImpl(SqliteDb db) : db_(std::move(db)) { + explicit DialogDbImpl(SqliteDb db) { init().ensure(); } Status init() { - TRY_RESULT_ASSIGN(add_dialog_stmt_, db_.get_statement("INSERT OR REPLACE INTO dialogs VALUES(?1, ?2, ?3, ?4)")); - TRY_RESULT_ASSIGN(add_notification_group_stmt_, - db_.get_statement("INSERT OR REPLACE INTO notification_groups VALUES(?1, ?2, ?3)")); - TRY_RESULT_ASSIGN(delete_notification_group_stmt_, - db_.get_statement("DELETE FROM notification_groups WHERE notification_group_id = ?1")); - TRY_RESULT_ASSIGN(get_dialog_stmt_, db_.get_statement("SELECT data FROM dialogs WHERE dialog_id = ?1")); - TRY_RESULT_ASSIGN( - get_dialogs_stmt_, - db_.get_statement("SELECT data, dialog_id, dialog_order FROM dialogs WHERE " - "folder_id == ?1 AND (dialog_order < ?2 OR (dialog_order = ?2 AND dialog_id < ?3)) ORDER " - "BY dialog_order DESC, dialog_id DESC LIMIT ?4")); - TRY_RESULT_ASSIGN( - get_notification_groups_by_last_notification_date_stmt_, - db_.get_statement("SELECT notification_group_id, dialog_id, last_notification_date FROM notification_groups " - "WHERE last_notification_date < ?1 OR (last_notification_date = ?1 " - "AND (dialog_id < ?2 OR (dialog_id = ?2 AND notification_group_id < ?3))) ORDER BY " - "last_notification_date DESC, dialog_id DESC LIMIT ?4")); - // "WHERE (last_notification_date, dialog_id, notification_group_id) < (?1, ?2, ?3) ORDER BY " - // "last_notification_date DESC, dialog_id DESC, notification_group_id DESC LIMIT ?4")); - TRY_RESULT_ASSIGN( - get_notification_group_stmt_, - db_.get_statement( - "SELECT dialog_id, last_notification_date FROM notification_groups WHERE notification_group_id = ?1")); - TRY_RESULT_ASSIGN( - get_secret_chat_count_stmt_, - db_.get_statement( - "SELECT COUNT(*) FROM dialogs WHERE folder_id = ?1 AND dialog_order > 0 AND dialog_id < -1500000000000")); - - // LOG(ERROR) << get_dialog_stmt_.explain().ok(); - // LOG(ERROR) << get_dialogs_stmt_.explain().ok(); - // LOG(ERROR) << get_notification_groups_by_last_notification_date_stmt_.explain().ok(); - // LOG(ERROR) << get_notification_group_stmt_.explain().ok(); - // LOG(FATAL) << "EXPLAINED"; - return Status::OK(); } Status add_dialog(DialogId dialog_id, FolderId folder_id, int64 order, BufferSlice data, vector notification_groups) override { - SCOPE_EXIT { - add_dialog_stmt_.reset(); - }; - add_dialog_stmt_.bind_int64(1, dialog_id.get()).ensure(); - add_dialog_stmt_.bind_int64(2, order).ensure(); - add_dialog_stmt_.bind_blob(3, data.as_slice()).ensure(); - if (order > 0) { - add_dialog_stmt_.bind_int32(4, folder_id.get()).ensure(); - } else { - add_dialog_stmt_.bind_null(4).ensure(); - } - - TRY_STATUS(add_dialog_stmt_.step()); - - for (auto &to_add : notification_groups) { - if (to_add.dialog_id.is_valid()) { - SCOPE_EXIT { - add_notification_group_stmt_.reset(); - }; - add_notification_group_stmt_.bind_int32(1, to_add.group_id.get()).ensure(); - add_notification_group_stmt_.bind_int64(2, to_add.dialog_id.get()).ensure(); - if (to_add.last_notification_date != 0) { - add_notification_group_stmt_.bind_int32(3, to_add.last_notification_date).ensure(); - } else { - add_notification_group_stmt_.bind_null(3).ensure(); - } - TRY_STATUS(add_notification_group_stmt_.step()); - } else { - SCOPE_EXIT { - delete_notification_group_stmt_.reset(); - }; - delete_notification_group_stmt_.bind_int32(1, to_add.group_id.get()).ensure(); - TRY_STATUS(delete_notification_group_stmt_.step()); - } - } return Status::OK(); } Result get_dialog(DialogId dialog_id) override { - SCOPE_EXIT { - get_dialog_stmt_.reset(); - }; - - get_dialog_stmt_.bind_int64(1, dialog_id.get()).ensure(); - TRY_STATUS(get_dialog_stmt_.step()); - if (!get_dialog_stmt_.has_row()) { - return Status::Error("Not found"); - } - return BufferSlice(get_dialog_stmt_.view_blob(0)); + return Status::Error("Not found"); } Result get_notification_group(NotificationGroupId notification_group_id) override { - SCOPE_EXIT { - get_notification_group_stmt_.reset(); - }; - get_notification_group_stmt_.bind_int32(1, notification_group_id.get()).ensure(); - TRY_STATUS(get_notification_group_stmt_.step()); - if (!get_notification_group_stmt_.has_row()) { - return Status::Error("Not found"); - } - return NotificationGroupKey(notification_group_id, DialogId(get_notification_group_stmt_.view_int64(0)), - get_last_notification_date(get_notification_group_stmt_, 1)); + return Status::Error("Not found"); } Result get_secret_chat_count(FolderId folder_id) override { - SCOPE_EXIT { - get_secret_chat_count_stmt_.reset(); - }; - get_secret_chat_count_stmt_.bind_int32(1, folder_id.get()).ensure(); - TRY_STATUS(get_secret_chat_count_stmt_.step()); - CHECK(get_secret_chat_count_stmt_.has_row()); - return get_secret_chat_count_stmt_.view_int32(0); + return 0; } Result get_dialogs(FolderId folder_id, int64 order, DialogId dialog_id, int32 limit) override { - SCOPE_EXIT { - get_dialogs_stmt_.reset(); - }; - - get_dialogs_stmt_.bind_int32(1, folder_id.get()).ensure(); - get_dialogs_stmt_.bind_int64(2, order).ensure(); - get_dialogs_stmt_.bind_int64(3, dialog_id.get()).ensure(); - get_dialogs_stmt_.bind_int32(4, limit).ensure(); - DialogDbGetDialogsResult result; - TRY_STATUS(get_dialogs_stmt_.step()); - while (get_dialogs_stmt_.has_row()) { - BufferSlice data(get_dialogs_stmt_.view_blob(0)); - result.next_dialog_id = DialogId(get_dialogs_stmt_.view_int64(1)); - result.next_order = get_dialogs_stmt_.view_int64(2); - LOG(INFO) << "Load " << result.next_dialog_id << " with order " << result.next_order; - result.dialogs.emplace_back(std::move(data)); - TRY_STATUS(get_dialogs_stmt_.step()); - } - return std::move(result); } Result> get_notification_groups_by_last_notification_date( NotificationGroupKey notification_group_key, int32 limit) override { - auto &stmt = get_notification_groups_by_last_notification_date_stmt_; - SCOPE_EXIT { - stmt.reset(); - }; - - stmt.bind_int32(1, notification_group_key.last_notification_date).ensure(); - stmt.bind_int64(2, notification_group_key.dialog_id.get()).ensure(); - stmt.bind_int32(3, notification_group_key.group_id.get()).ensure(); - stmt.bind_int32(4, limit).ensure(); - vector notification_groups; - TRY_STATUS(stmt.step()); - while (stmt.has_row()) { - notification_groups.emplace_back(NotificationGroupId(stmt.view_int32(0)), DialogId(stmt.view_int64(1)), - get_last_notification_date(stmt, 2)); - TRY_STATUS(stmt.step()); - } - return std::move(notification_groups); } Status begin_transaction() override { - return db_.begin_transaction(); + return Status::OK(); } Status commit_transaction() override { - return db_.commit_transaction(); - } - - private: - SqliteDb db_; - - SqliteStatement add_dialog_stmt_; - SqliteStatement add_notification_group_stmt_; - SqliteStatement delete_notification_group_stmt_; - SqliteStatement get_dialog_stmt_; - SqliteStatement get_dialogs_stmt_; - SqliteStatement get_notification_groups_by_last_notification_date_stmt_; - SqliteStatement get_notification_group_stmt_; - SqliteStatement get_secret_chat_count_stmt_; - - static int32 get_last_notification_date(SqliteStatement &stmt, int id) { - if (stmt.view_datatype(id) == SqliteStatement::Datatype::Null) { - return 0; - } - return stmt.view_int32(id); + return Status::OK(); } }; @@ -431,28 +213,12 @@ class DialogDbAsync : public DialogDbAsyncInterface { } void add_read_query() { - do_flush(); } void do_flush() { - if (pending_writes_.empty()) { - return; - } - sync_db_->begin_transaction().ensure(); - for (auto &query : pending_writes_) { - query.set_value(Unit()); - } - sync_db_->commit_transaction().ensure(); - pending_writes_.clear(); - for (auto &p : pending_write_results_) { - p.first.set_result(std::move(p.second)); - } - pending_write_results_.clear(); - cancel_timeout(); } void timeout_expired() override { - do_flush(); } void start_up() override { diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index 87edd124..719eaba0 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -642,6 +642,10 @@ bool DocumentsManager::merge_documents(FileId new_id, FileId old_id, bool can_de return true; } +void DocumentsManager::memory_cleanup() { + documents_.clear(); +} + string DocumentsManager::get_document_search_text(FileId file_id) const { auto document = get_document(file_id); CHECK(document); diff --git a/td/telegram/DocumentsManager.h b/td/telegram/DocumentsManager.h index 761881a5..ce684bb3 100644 --- a/td/telegram/DocumentsManager.h +++ b/td/telegram/DocumentsManager.h @@ -76,6 +76,8 @@ class DocumentsManager { tl_object_ptr get_document_object(FileId file_id); + void memory_cleanup(); + Document on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id, MultiPromiseActor *load_data_multipromise_ptr = nullptr, Document::Type default_document_type = Document::Type::General, bool is_background = false, diff --git a/td/telegram/DocumentsManager.hpp b/td/telegram/DocumentsManager.hpp index 249deeaa..ce068329 100644 --- a/td/telegram/DocumentsManager.hpp +++ b/td/telegram/DocumentsManager.hpp @@ -23,7 +23,9 @@ template void DocumentsManager::store_document(FileId file_id, StorerT &storer) const { LOG(DEBUG) << "Store document " << file_id; auto it = documents_.find(file_id); - CHECK(it != documents_.end()); + if (it == documents_.end()) { + return; + } const GeneralDocument *document = it->second.get(); store(document->file_name, storer); store(document->mime_type, storer); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index bfcebda0..96f6db90 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1327,9 +1327,17 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i } auto it = stickers_.find(file_id); - CHECK(it != stickers_.end()); + + if (it == stickers_.end()) { + return nullptr; + } + auto sticker = it->second.get(); - CHECK(sticker != nullptr); + + if (sticker == nullptr) { + return nullptr; + } + sticker->is_changed = false; auto mask_position = sticker->point >= 0 @@ -1715,7 +1723,11 @@ void StickersManager::delete_sticker_thumbnail(FileId file_id) { vector StickersManager::get_sticker_file_ids(FileId file_id) const { vector result; auto sticker = get_sticker(file_id); - CHECK(sticker != nullptr); + + if (sticker == nullptr) { + return result; + } + result.push_back(file_id); if (sticker->s_thumbnail.file_id.is_valid()) { result.push_back(sticker->s_thumbnail.file_id); @@ -1933,7 +1945,11 @@ void StickersManager::create_sticker(FileId file_id, PhotoSize thumbnail, Dimens bool StickersManager::has_input_media(FileId sticker_file_id, bool is_secret) const { const Sticker *sticker = get_sticker(sticker_file_id); - CHECK(sticker != nullptr); + + if (sticker == nullptr) { + return false; + } + auto file_view = td_->file_manager_->get_file_view(sticker_file_id); if (is_secret) { if (file_view.is_encrypted_secret()) { @@ -1962,7 +1978,11 @@ SecretInputMedia StickersManager::get_secret_input_media(FileId sticker_file_id, tl_object_ptr input_file, BufferSlice thumbnail) const { const Sticker *sticker = get_sticker(sticker_file_id); - CHECK(sticker != nullptr); + + if (sticker == nullptr) { + return {}; + } + auto file_view = td_->file_manager_->get_file_view(sticker_file_id); if (file_view.is_encrypted_secret()) { if (file_view.has_remote_location()) { @@ -5005,7 +5025,9 @@ int32 StickersManager::get_recent_stickers_hash(const vector &sticker_id numbers.reserve(sticker_ids.size() * 2); for (auto sticker_id : sticker_ids) { auto sticker = get_sticker(sticker_id); - CHECK(sticker != nullptr); + if (sticker == nullptr) { + continue; + } auto file_view = td_->file_manager_->get_file_view(sticker_id); CHECK(file_view.has_remote_location()); if (!file_view.remote_location().is_document()) { @@ -6179,19 +6201,19 @@ void StickersManager::get_current_state(vector void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT &storer) const { auto it = stickers_.find(file_id); - CHECK(it != stickers_.end()); + if (it == stickers_.end()) { + return; + } const Sticker *sticker = it->second.get(); bool has_sticker_set_access_hash = sticker->set_id.is_valid() && !in_sticker_set; BEGIN_STORE_FLAGS(); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 06e853fc..f01e0e6f 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5025,6 +5025,7 @@ void Td::on_request(uint64 id, td_api::optimizeStorage &request) { contacts_manager_->memory_cleanup(); web_pages_manager_->memory_cleanup(); stickers_manager_->memory_cleanup(); + documents_manager_->memory_cleanup(); std::vector file_types; for (auto &file_type : request.file_types_) { diff --git a/tddb/td/db/SqliteKeyValue.cpp b/tddb/td/db/SqliteKeyValue.cpp index c9687d90..294130b7 100644 --- a/tddb/td/db/SqliteKeyValue.cpp +++ b/tddb/td/db/SqliteKeyValue.cpp @@ -11,115 +11,33 @@ namespace td { Result SqliteKeyValue::init(string path) { - path_ = std::move(path); - bool is_created = false; - SqliteDb db; - TRY_STATUS(db.init(path, &is_created)); - TRY_STATUS(db.exec("PRAGMA encoding=\"UTF-8\"")); - TRY_STATUS(db.exec("PRAGMA synchronous=NORMAL")); - TRY_STATUS(db.exec("PRAGMA journal_mode=WAL")); - TRY_STATUS(db.exec("PRAGMA temp_store=MEMORY")); - TRY_STATUS(init_with_connection(std::move(db), "KV")); - return is_created; + return true; } Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) { - auto init_guard = ScopeExit() + [&] { - close(); - }; - db_ = std::move(connection); - table_name_ = std::move(table_name); - TRY_STATUS(init(db_, table_name_)); - - TRY_RESULT_ASSIGN(set_stmt_, - db_.get_statement(PSLICE() << "REPLACE INTO " << table_name_ << " (k, v) VALUES (?1, ?2)")); - TRY_RESULT_ASSIGN(get_stmt_, db_.get_statement(PSLICE() << "SELECT v FROM " << table_name_ << " WHERE k = ?1")); - TRY_RESULT_ASSIGN(erase_stmt_, db_.get_statement(PSLICE() << "DELETE FROM " << table_name_ << " WHERE k = ?1")); - TRY_RESULT_ASSIGN(get_all_stmt_, db_.get_statement(PSLICE() << "SELECT k, v FROM " << table_name_)); - - TRY_RESULT_ASSIGN(erase_by_prefix_stmt_, - db_.get_statement(PSLICE() << "DELETE FROM " << table_name_ << " WHERE ?1 <= k AND k < ?2")); - TRY_RESULT_ASSIGN(erase_by_prefix_rare_stmt_, - db_.get_statement(PSLICE() << "DELETE FROM " << table_name_ << " WHERE ?1 <= k")); - - TRY_RESULT_ASSIGN(get_by_prefix_stmt_, - db_.get_statement(PSLICE() << "SELECT k, v FROM " << table_name_ << " WHERE ?1 <= k AND k < ?2")); - TRY_RESULT_ASSIGN(get_by_prefix_rare_stmt_, - db_.get_statement(PSLICE() << "SELECT k, v FROM " << table_name_ << " WHERE ?1 <= k")); - - init_guard.dismiss(); return Status::OK(); } Status SqliteKeyValue::drop() { - if (empty()) { - return Status::OK(); - } - - auto result = drop(db_, table_name_); - close(); - return result; + return Status::OK(); } SqliteKeyValue::SeqNo SqliteKeyValue::set(Slice key, Slice value) { - set_stmt_.bind_blob(1, key).ensure(); - set_stmt_.bind_blob(2, value).ensure(); - set_stmt_.step().ensure(); - set_stmt_.reset(); return 0; } string SqliteKeyValue::get(Slice key) { - SCOPE_EXIT { - get_stmt_.reset(); - }; - get_stmt_.bind_blob(1, key).ensure(); - get_stmt_.step().ensure(); - if (!get_stmt_.has_row()) { - return ""; - } - auto data = get_stmt_.view_blob(0).str(); - get_stmt_.step().ignore(); - return data; + return ""; } SqliteKeyValue::SeqNo SqliteKeyValue::erase(Slice key) { - erase_stmt_.bind_blob(1, key).ensure(); - erase_stmt_.step().ensure(); - erase_stmt_.reset(); return 0; } void SqliteKeyValue::erase_by_prefix(Slice prefix) { - auto next = next_prefix(prefix); - if (next.empty()) { - SCOPE_EXIT { - erase_by_prefix_rare_stmt_.reset(); - }; - erase_by_prefix_rare_stmt_.bind_blob(1, prefix).ensure(); - erase_by_prefix_rare_stmt_.step().ensure(); - } else { - SCOPE_EXIT { - erase_by_prefix_stmt_.reset(); - }; - erase_by_prefix_stmt_.bind_blob(1, prefix).ensure(); - erase_by_prefix_stmt_.bind_blob(2, next).ensure(); - erase_by_prefix_stmt_.step().ensure(); - } } string SqliteKeyValue::next_prefix(Slice prefix) { - string next = prefix.str(); - size_t pos = next.size(); - while (pos) { - pos--; - auto value = static_cast(next[pos]); - value++; - next[pos] = static_cast(value); - if (value != 0) { - return next; - } - } return string{}; } diff --git a/tddb/td/db/SqliteKeyValue.h b/tddb/td/db/SqliteKeyValue.h index b12c3a59..f2d8b43a 100644 --- a/tddb/td/db/SqliteKeyValue.h +++ b/tddb/td/db/SqliteKeyValue.h @@ -20,17 +20,17 @@ namespace td { class SqliteKeyValue { public: static Status drop(SqliteDb &connection, Slice table_name) TD_WARN_UNUSED_RESULT { - return connection.exec(PSLICE() << "DROP TABLE IF EXISTS " << table_name); + return Status::OK(); } static Status init(SqliteDb &connection, Slice table_name) TD_WARN_UNUSED_RESULT { - return connection.exec(PSLICE() << "CREATE TABLE IF NOT EXISTS " << table_name << " (k BLOB PRIMARY KEY, v BLOB)"); + return Status::OK(); } using SeqNo = uint64; bool empty() const { - return db_.empty(); + return false; } Result init(string path) TD_WARN_UNUSED_RESULT; @@ -54,10 +54,10 @@ class SqliteKeyValue { SeqNo erase(Slice key); Status begin_transaction() TD_WARN_UNUSED_RESULT { - return db_.begin_transaction(); + return Status::OK(); } Status commit_transaction() TD_WARN_UNUSED_RESULT { - return db_.commit_transaction(); + return Status::OK(); } void erase_by_prefix(Slice prefix); @@ -107,14 +107,7 @@ class SqliteKeyValue { private: string path_; - string table_name_; - SqliteDb db_; - SqliteStatement get_stmt_; - SqliteStatement set_stmt_; - SqliteStatement erase_stmt_; SqliteStatement get_all_stmt_; - SqliteStatement erase_by_prefix_stmt_; - SqliteStatement erase_by_prefix_rare_stmt_; SqliteStatement get_by_prefix_stmt_; SqliteStatement get_by_prefix_rare_stmt_;