2014-08-01 13:19:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-09-29 19:19:54 +00:00
|
|
|
#include <common/logger_useful.h>
|
2019-07-03 13:17:19 +00:00
|
|
|
#include <Storages/CheckResults.h>
|
2019-12-12 08:57:25 +00:00
|
|
|
#include <Disks/IDisk.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
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/// stores the sizes of all columns, and can check whether the columns are corrupted
|
2014-08-01 13:19:27 +00:00
|
|
|
class FileChecker
|
|
|
|
{
|
|
|
|
public:
|
2019-12-12 08:57:25 +00:00
|
|
|
FileChecker(DiskPtr disk_, const String & file_info_path_);
|
|
|
|
void setPath(const String & file_info_path_);
|
|
|
|
void update(const String & file_path);
|
|
|
|
void update(const Strings::const_iterator & begin, const Strings::const_iterator & end);
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/// Check the files whose parameters are specified in sizes.json
|
2019-07-03 13:17:19 +00:00
|
|
|
CheckResults check() const;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
|
|
|
private:
|
2019-12-12 08:57:25 +00:00
|
|
|
/// File name -> size.
|
|
|
|
using Map = std::map<String, UInt64>;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void initialize();
|
2019-12-12 08:57:25 +00:00
|
|
|
void updateImpl(const String & file_path);
|
2017-04-01 07:20:54 +00:00
|
|
|
void save() const;
|
2019-12-12 08:57:25 +00:00
|
|
|
void load(Map & local_map, const String & path) const;
|
2015-09-29 00:53:10 +00:00
|
|
|
|
2019-12-12 08:57:25 +00:00
|
|
|
DiskPtr disk;
|
|
|
|
String files_info_path;
|
|
|
|
String tmp_files_info_path;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/// The data from the file is read lazily.
|
2017-04-01 07:20:54 +00:00
|
|
|
Map map;
|
|
|
|
bool initialized = false;
|
2014-08-01 13:19:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +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
|
|
|
}
|