2014-08-01 13:19:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-09-29 00:53:10 +00:00
|
|
|
#include <string>
|
2014-08-01 13:19:27 +00:00
|
|
|
#include <Yandex/logger_useful.h>
|
2014-08-04 06:36:24 +00:00
|
|
|
#include <Poco/File.h>
|
2014-08-15 14:34:45 +00:00
|
|
|
|
2014-08-04 08:37:46 +00:00
|
|
|
|
2014-08-04 06:36:24 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2014-08-01 13:19:27 +00:00
|
|
|
|
|
|
|
/// хранит размеры всех столбцов, и может проверять не побились ли столбцы
|
|
|
|
class FileChecker
|
|
|
|
{
|
2015-09-29 00:53:10 +00:00
|
|
|
private:
|
|
|
|
/// Имя файла -> размер.
|
|
|
|
using Map = std::map<std::string, size_t>;
|
|
|
|
|
2014-08-01 13:19:27 +00:00
|
|
|
public:
|
2014-08-04 06:36:24 +00:00
|
|
|
using Files = std::vector<Poco::File>;
|
|
|
|
|
2015-09-29 14:09:01 +00:00
|
|
|
FileChecker(const std::string & file_info_path_);
|
|
|
|
void setPath(const std::string & file_info_path_);
|
|
|
|
void update(const Poco::File & file);
|
|
|
|
void update(const Files::const_iterator & begin, const Files::const_iterator & end);
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2014-08-06 13:22:52 +00:00
|
|
|
/// Проверяем файлы, параметры которых указаны в sizes.json
|
2015-09-29 14:09:01 +00:00
|
|
|
bool check() const;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
|
|
|
private:
|
2015-09-29 14:09:01 +00:00
|
|
|
void initialize();
|
|
|
|
void updateImpl(const Poco::File & file);
|
|
|
|
void save() const;
|
|
|
|
void load(Map & map) const;
|
2015-09-29 00:53:10 +00:00
|
|
|
|
2014-08-01 13:19:27 +00:00
|
|
|
std::string files_info_path;
|
2014-08-18 15:29:45 +00:00
|
|
|
std::string tmp_files_info_path;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2015-09-25 18:57:17 +00:00
|
|
|
/// Данные из файла читаются лениво.
|
2015-09-29 00:53:10 +00:00
|
|
|
Map map;
|
2015-09-25 18:57:17 +00:00
|
|
|
bool initialized = false;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2015-09-25 18:57:17 +00:00
|
|
|
Logger * log = &Logger::get("FileChecker");
|
2014-08-01 13:19:27 +00:00
|
|
|
};
|
2015-09-29 14:09:01 +00:00
|
|
|
|
2014-08-04 06:36:24 +00:00
|
|
|
}
|