FileChecker migrated to boost::propertytree

This commit is contained in:
Pavel Kartavyy 2014-08-15 20:46:13 +04:00
parent f53a889cc6
commit 9508cb93cf
3 changed files with 8 additions and 9 deletions

View File

@ -9,7 +9,7 @@
#include <DB/Common/escapeForFileName.h>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
namespace DB
{
@ -23,7 +23,7 @@ public:
files_info_path(file_info_path_), files_info(), storage(storage_), log(&Logger::get("FileChecker"))
{
if (Poco::File(files_info_path).exists())
boost::property_tree::read_xml(files_info_path, files_info);
boost::property_tree::read_json(files_info_path, files_info);
}
void setPath(const std::string & file_info_path_)
@ -46,7 +46,7 @@ public:
saveTree();
}
/// Проверяем файлы, параметры которых указаны в sizes.txt
/// Проверяем файлы, параметры которых указаны в sizes.json
bool check() const
{
bool correct = true;
@ -82,8 +82,7 @@ private:
void saveTree()
{
boost::property_tree::write_xml(files_info_path, files_info, std::locale(),
boost::property_tree::xml_parser::xml_writer_settings<char>('\t', 1));
boost::property_tree::write_json(files_info_path, files_info, std::locale());
}
std::string files_info_path;

View File

@ -411,7 +411,7 @@ void LogBlockOutputStream::writeMarks(MarksForColumns marks)
StorageLog::StorageLog(const std::string & path_, const std::string & name_, NamesAndTypesListPtr columns_, size_t max_compress_block_size_)
: path(path_), name(name_), columns(columns_), loaded_marks(false), max_compress_block_size(max_compress_block_size_),
file_checker(path + escapeForFileName(name) + '/' + "sizes.txt", *this)
file_checker(path + escapeForFileName(name) + '/' + "sizes.json", *this)
{
if (columns->empty())
throw Exception("Empty list of columns passed to StorageLog constructor", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED);
@ -540,7 +540,7 @@ void StorageLog::rename(const String & new_path_to_db, const String & new_databa
path = new_path_to_db;
name = new_table_name;
file_checker.setPath(path + escapeForFileName(name) + '/' + "sizes.txt");
file_checker.setPath(path + escapeForFileName(name) + '/' + "sizes.json");
for (Files_t::iterator it = files.begin(); it != files.end(); ++it)
{

View File

@ -294,7 +294,7 @@ void TinyLogBlockOutputStream::write(const Block & block)
StorageTinyLog::StorageTinyLog(const std::string & path_, const std::string & name_, NamesAndTypesListPtr columns_, bool attach, size_t max_compress_block_size_)
: path(path_), name(name_), columns(columns_),
max_compress_block_size(max_compress_block_size_),
file_checker(path + escapeForFileName(name) + '/' + "sizes.txt", *this),
file_checker(path + escapeForFileName(name) + '/' + "sizes.json", *this),
log(&Logger::get("StorageTinyLog"))
{
if (columns->empty())
@ -369,7 +369,7 @@ void StorageTinyLog::rename(const String & new_path_to_db, const String & new_da
path = new_path_to_db;
name = new_table_name;
file_checker.setPath(path + escapeForFileName(name) + "/" + "sizes.txt");
file_checker.setPath(path + escapeForFileName(name) + "/" + "sizes.json");
for (Files_t::iterator it = files.begin(); it != files.end(); ++it)
it->second.data_file = Poco::File(path + escapeForFileName(name) + '/' + Poco::Path(it->second.data_file.path()).getFileName());