Revert accident changes

This commit is contained in:
alesapin 2020-03-19 18:12:22 +03:00
parent 204d0ac955
commit c6d10e32fc
6 changed files with 3 additions and 52 deletions

View File

@ -50,13 +50,10 @@ Block PartLogElement::createBlock()
{ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "bytes_uncompressed"}, // Result bytes {ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "bytes_uncompressed"}, // Result bytes
{ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "read_rows"}, {ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "read_rows"},
{ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "read_bytes"}, {ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "read_bytes"},
{ColumnUInt64::create(), std::make_shared<DataTypeUInt64>(), "peak_memory_usage"},
/// Is there an error during the execution or commit /// Is there an error during the execution or commit
{ColumnUInt16::create(), std::make_shared<DataTypeUInt16>(), "error"}, {ColumnUInt16::create(), std::make_shared<DataTypeUInt16>(), "error"},
{ColumnString::create(), std::make_shared<DataTypeString>(), "exception"}, {ColumnString::create(), std::make_shared<DataTypeString>(), "exception"},
}; };
} }
@ -90,12 +87,10 @@ void PartLogElement::appendToBlock(Block & block) const
columns[i++]->insert(bytes_uncompressed); columns[i++]->insert(bytes_uncompressed);
columns[i++]->insert(rows_read); columns[i++]->insert(rows_read);
columns[i++]->insert(bytes_read_uncompressed); columns[i++]->insert(bytes_read_uncompressed);
columns[i++]->insert(peak_memory_usage);
columns[i++]->insert(error); columns[i++]->insert(error);
columns[i++]->insert(exception); columns[i++]->insert(exception);
block.setColumns(std::move(columns)); block.setColumns(std::move(columns));
} }

View File

@ -40,13 +40,11 @@ struct PartLogElement
UInt64 bytes_uncompressed = 0; UInt64 bytes_uncompressed = 0;
UInt64 rows_read = 0; UInt64 rows_read = 0;
UInt64 bytes_read_uncompressed = 0; UInt64 bytes_read_uncompressed = 0;
UInt64 peak_memory_usage = 0;
/// Was the operation successful? /// Was the operation successful?
UInt16 error = 0; UInt16 error = 0;
String exception; String exception;
static std::string name() { return "PartLog"; } static std::string name() { return "PartLog"; }
static Block createBlock(); static Block createBlock();

View File

@ -3373,7 +3373,6 @@ try
part_log_elem.rows = (*merge_entry)->rows_written; part_log_elem.rows = (*merge_entry)->rows_written;
part_log_elem.bytes_uncompressed = (*merge_entry)->bytes_written_uncompressed; part_log_elem.bytes_uncompressed = (*merge_entry)->bytes_written_uncompressed;
part_log_elem.peak_memory_usage = (*merge_entry)->memory_tracker.getPeak();
} }
part_log->add(part_log_elem); part_log->add(part_log_elem);

View File

@ -2,7 +2,6 @@
#include <Storages/MergeTree/MergeTreeData.h> #include <Storages/MergeTree/MergeTreeData.h>
#include <Interpreters/AnalyzedJoin.h> #include <Interpreters/AnalyzedJoin.h>
#include <Functions/IFunction.h> #include <Functions/IFunction.h>
#include <Storages/MergeTree/StorageFromMergeTreeDataPart.h>
namespace DB namespace DB
{ {
@ -32,28 +31,14 @@ ReadInOrderOptimizer::ReadInOrderOptimizer(
InputSortingInfoPtr ReadInOrderOptimizer::getInputOrder(const StoragePtr & storage) const InputSortingInfoPtr ReadInOrderOptimizer::getInputOrder(const StoragePtr & storage) const
{ {
Names sorting_key_columns; const MergeTreeData * merge_tree = dynamic_cast<const MergeTreeData *>(storage.get());
if (const auto * merge_tree = dynamic_cast<const MergeTreeData *>(storage.get())) if (!merge_tree || !merge_tree->hasSortingKey())
{
if (!merge_tree->hasSortingKey())
return {};
sorting_key_columns = merge_tree->getSortingKeyColumns();
}
else if (const auto * part = dynamic_cast<const StorageFromMergeTreeDataPart *>(storage.get()))
{
if (!part->hasSortingKey())
return {};
sorting_key_columns = part->getSortingKeyColumns();
}
else /// Inapplicable storage type
{
return {}; return {};
}
SortDescription order_key_prefix_descr; SortDescription order_key_prefix_descr;
int read_direction = required_sort_description.at(0).direction; int read_direction = required_sort_description.at(0).direction;
const auto & sorting_key_columns = merge_tree->getSortingKeyColumns();
size_t prefix_size = std::min(required_sort_description.size(), sorting_key_columns.size()); size_t prefix_size = std::min(required_sort_description.size(), sorting_key_columns.size());
for (size_t i = 0; i < prefix_size; ++i) for (size_t i = 0; i < prefix_size; ++i)

View File

@ -1,25 +0,0 @@
DROP TABLE IF EXISTS table_with_pk;
CREATE TABLE table_with_pk
(
key UInt8,
value String
)
ENGINE = MergeTree
ORDER BY key;
INSERT INTO table_with_pk SELECT number, toString(number % 10) FROM numbers(10000000);
ALTER TABLE table_with_pk DELETE WHERE key % 77 = 0 SETTINGS mutations_sync = 1;
SYSTEM FLUSH LOGS;
-- Memory usage for all mutations must be almost constant and less than
-- read_bytes.
SELECT
DISTINCT read_bytes >= peak_memory_usage
FROM
system.part_log2
WHERE event_type = 'MutatePart' AND table = 'table_with_pk' AND database = currentDatabase();
DROP TABLE IF EXISTS table_with_pk;