From 79f35d5b0ae30f7cba077780b399ed7558c0ff4e Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Wed, 28 Oct 2020 09:44:10 -0700 Subject: [PATCH] add storage_config_uri (#493) * add storage_config_uri Signed-off-by: Karsten Knese * linters and tests Signed-off-by: Karsten Knese * move storage options to rosbag2_storage Signed-off-by: Karsten Knese * use storage options to open storage backends Signed-off-by: Karsten Knese * add rosbag2_py to metapackage Signed-off-by: Karsten Knese --- rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp | 7 ++----- .../sqlite/sqlite_storage.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp b/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp index a3fb3b81c..7cdce1e0d 100644 --- a/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp +++ b/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp @@ -141,6 +141,7 @@ void SequentialWriter::reset() metadata_io_->write_metadata(base_folder_, metadata_); } + reset_cache(); storage_.reset(); // Necessary to ensure that the storage is destroyed before the factory storage_factory_.reset(); } @@ -252,11 +253,7 @@ void SequentialWriter::write(std::shared_ptrserialized_data->buffer_length; if (current_cache_size_ >= storage_options_.max_cache_size) { - storage_->write(cache_); - // reset cache - cache_.clear(); - cache_.reserve(storage_options_.max_cache_size); - current_cache_size_ = 0u; + reset_cache(); } } } diff --git a/rosbag2_storage_default_plugins/src/rosbag2_storage_default_plugins/sqlite/sqlite_storage.cpp b/rosbag2_storage_default_plugins/src/rosbag2_storage_default_plugins/sqlite/sqlite_storage.cpp index 1dabb5f2f..e1289a486 100644 --- a/rosbag2_storage_default_plugins/src/rosbag2_storage_default_plugins/sqlite/sqlite_storage.cpp +++ b/rosbag2_storage_default_plugins/src/rosbag2_storage_default_plugins/sqlite/sqlite_storage.cpp @@ -123,10 +123,15 @@ void SqliteStorage::open( const rosbag2_storage::StorageOptions & storage_options, rosbag2_storage::storage_interfaces::IOFlag io_flag) { + if (!storage_options.storage_config_uri.empty()) { + fprintf(stderr, "going to open config file: %s\n", storage_options.storage_config_uri.c_str()); + throw std::runtime_error("storage specific config file is not yet implemented."); + } + auto pragmas = parse_pragmas(storage_options.storage_config_uri, io_flag); if (is_read_write(io_flag)) { - relative_path_ = storage_options.uri + FILE_EXTENSION; + relative_path_ = uri + FILE_EXTENSION; // READ_WRITE requires the DB to not exist. if (rcpputils::fs::path(relative_path_).exists()) {