-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQLite storage optimized by default (#568)
* Use optimized pragmas by default in sqlite storage. Added option to use former behavior Signed-off-by: Adam Dabrowski <[email protected]>
- Loading branch information
Showing
11 changed files
with
163 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...storage_default_plugins/include/rosbag2_storage_default_plugins/sqlite/sqlite_pragmas.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2020, Robotec.ai sp. z o.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2_STORAGE_DEFAULT_PLUGINS__SQLITE__SQLITE_PRAGMAS_HPP_ | ||
#define ROSBAG2_STORAGE_DEFAULT_PLUGINS__SQLITE__SQLITE_PRAGMAS_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
|
||
namespace rosbag2_storage_plugins | ||
{ | ||
|
||
class ROSBAG2_STORAGE_DEFAULT_PLUGINS_PUBLIC SqlitePragmas | ||
{ | ||
public: | ||
using pragmas_map_t = std::unordered_map<std::string, std::string>; | ||
|
||
static pragmas_map_t default_pragmas() | ||
{ | ||
static pragmas_map_t p = {{"schema_version", "PRAGMA schema_version;"}}; | ||
return p; | ||
} | ||
|
||
// more robust storage settings will cause performace hit on writing, | ||
// but increase resistance to bagfile data corruption in case of crashes | ||
static pragmas_map_t robust_writing_pragmas() | ||
{ | ||
static pragmas_map_t p = { | ||
{"journal_mode", "PRAGMA journal_mode=WAL;"}, | ||
{"synchronous", "PRAGMA synchronous=NORMAL;"} | ||
}; | ||
return p; | ||
} | ||
|
||
static pragmas_map_t optimized_writing_pragmas() | ||
{ | ||
static pragmas_map_t p = { | ||
{"journal_mode", "PRAGMA journal_mode=MEMORY;"}, | ||
{"synchronous", "PRAGMA synchronous=OFF;"} | ||
}; | ||
return p; | ||
} | ||
}; | ||
|
||
} // namespace rosbag2_storage_plugins | ||
|
||
#endif // ROSBAG2_STORAGE_DEFAULT_PLUGINS__SQLITE__SQLITE_PRAGMAS_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters