2014-07-22 08:21:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
2014-07-22 08:21:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class MergeTreePartChecker
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
struct Settings
|
|
|
|
{
|
2017-04-16 15:00:33 +00:00
|
|
|
bool verbose = false; /// Writes progress and errors to stderr, and does not stop at the first error.
|
|
|
|
bool require_checksums = false; /// Requires column.txt to be.
|
|
|
|
bool require_column_files = false; /// Requires that all columns from columns.txt have files.
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t index_granularity = 8192;
|
2014-08-08 08:28:13 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Settings & setVerbose(bool verbose_) { verbose = verbose_; return *this; }
|
|
|
|
Settings & setRequireChecksums(bool require_checksums_) { require_checksums = require_checksums_; return *this; }
|
|
|
|
Settings & setRequireColumnFiles(bool require_column_files_) { require_column_files = require_column_files_; return *this; }
|
|
|
|
Settings & setIndexGranularity(size_t index_granularity_) { index_granularity = index_granularity_; return *this; }
|
|
|
|
};
|
2014-08-08 08:28:13 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Completely checks the part data
|
|
|
|
* - Calculates checksums and compares them with checksums.txt.
|
|
|
|
* - For arrays and strings, checks the correspondence of the size and amount of data.
|
|
|
|
* - Checks the correctness of marks.
|
2017-06-25 00:17:08 +00:00
|
|
|
* Throws an exception if the part is corrupted or if the check fails (TODO: you can try to separate these cases).
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
static void checkDataPart(
|
|
|
|
String path,
|
|
|
|
const Settings & settings,
|
2017-04-16 15:00:33 +00:00
|
|
|
const DataTypes & primary_key_data_types, /// Check the primary key. If it is not necessary, pass an empty array.
|
2017-04-01 07:20:54 +00:00
|
|
|
MergeTreeData::DataPart::Checksums * out_checksums = nullptr,
|
|
|
|
std::atomic<bool> * is_cancelled = nullptr);
|
2014-07-22 08:21:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|