dbms: parts_checker; not working yet. [#METR-11980]

This commit is contained in:
Michael Kolupaev 2014-07-22 12:20:45 +04:00
parent 4830e7f634
commit c777975b0b
4 changed files with 41 additions and 0 deletions

View File

@ -254,6 +254,7 @@ namespace ErrorCodes
UNEXPECTED_ZOOKEEPER_ERROR,
INVALID_NESTED_NAME,
CORRUPTED_DATA,
INCORRECT_MARK,
POCO_EXCEPTION = 1000,
STD_EXCEPTION,

View File

@ -51,6 +51,13 @@ public:
return res;
}
inline void nextIfAtEnd()
{
if (pos == working_buffer.end())
next();
}
virtual ~ReadBuffer() {}
@ -87,6 +94,21 @@ public:
throw Exception("Attempt to read after eof", ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF);
}
/// Можно было бы назвать этот метод ignore, а ignore назвать ignoreStrict.
size_t tryIgnore(size_t n)
{
size_t bytes_ignored = 0;
while (bytes_ignored < n && !eof())
{
size_t bytes_to_ignore = std::min(static_cast<size_t>(working_buffer.end() - pos), n - bytes_ignored);
pos += bytes_to_ignore;
bytes_ignored += bytes_to_ignore;
}
return bytes_ignored;
}
/** Читает столько, сколько есть, не больше n байт. */
size_t read(char * to, size_t n)
{

View File

@ -13,6 +13,21 @@ struct MarkInCompressedFile
{
size_t offset_in_compressed_file;
size_t offset_in_decompressed_block;
bool operator==(const MarkInCompressedFile & rhs) const
{
return std::forward_as_tuple(offset_in_compressed_file, offset_in_decompressed_block) ==
std::forward_as_tuple(rhs.offset_in_compressed_file, rhs.offset_in_decompressed_block);
}
bool operator!=(const MarkInCompressedFile & rhs) const
{
return !(*this == rhs);
}
String toString() const
{
return "(" + DB::toString(offset_in_compressed_file) + "," + DB::toString(offset_in_decompressed_block) + ")";
}
};
typedef std::vector<MarkInCompressedFile> MarksInCompressedFile;

View File

@ -137,6 +137,9 @@ public:
Checksum() {}
Checksum(size_t file_size_, uint128 file_hash_) : file_size(file_size_), file_hash(file_hash_) {}
Checksum(size_t file_size_, uint128 file_hash_, size_t uncompressed_size_, uint128 uncompressed_hash_)
: file_size(file_size_), file_hash(file_hash_), is_compressed(true),
uncompressed_size(uncompressed_size_), uncompressed_hash(uncompressed_hash_) {}
void checkEqual(const Checksum & rhs, bool have_uncompressed, const String & name) const;
void checkSize(const String & path) const;