提交 d35e4d0e 编写于 作者: A Alexey Arno

dbms: Server: Code cleanups. [#METR-15090]

上级 341fed3e
......@@ -15,21 +15,21 @@ class InterpreterOptimizeQuery
{
public:
InterpreterOptimizeQuery(ASTPtr query_ptr_, Context & context_)
: query_ptr(query_ptr_), context(context_),
aio_threshold(context_.getSettings().min_bytes_to_use_direct_io) {}
: query_ptr(query_ptr_), context(context_)
{
}
void execute()
{
const ASTOptimizeQuery & ast = typeid_cast<const ASTOptimizeQuery &>(*query_ptr);
StoragePtr table = context.getTable(ast.database, ast.table);
auto table_lock = table->lockStructure(true);
table->optimize(aio_threshold);
table->optimize(&context.getSettingsRef());
}
private:
ASTPtr query_ptr;
Context context;
size_t aio_threshold;
};
......
......@@ -236,9 +236,9 @@ public:
/** Выполнить какую-либо фоновую работу. Например, объединение кусков в таблице типа MergeTree.
* Возвращает - была ли выполнена какая-либо работа.
*/
bool optimize(size_t aio_threshold = 0)
bool optimize(const Settings * settings = nullptr)
{
return performOptimize(aio_threshold);
return performOptimize(settings);
}
/** Получить запрос CREATE TABLE, который описывает данную таблицу.
......@@ -280,7 +280,7 @@ public:
virtual bool checkData() const { throw DB::Exception("Check query is not supported for " + getName() + " storage"); }
protected:
virtual bool performOptimize(size_t aio_threshold)
virtual bool performOptimize(const Settings * settings)
{
throw Exception("Method optimize is not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
......
......@@ -124,7 +124,7 @@ private:
void flushThread();
bool performOptimize(size_t aio_threshold) override;
bool performOptimize(const Settings * settings) override;
};
}
......@@ -56,7 +56,7 @@ private:
const ColumnDefaults & column_defaults_,
bool attach_);
bool performOptimize(size_t aio_threshold) override;
bool performOptimize(const Settings * settings) override;
};
}
......@@ -96,9 +96,10 @@ public:
private:
/** Выполнить очередной шаг объединения кусков.
*/
bool performOptimize(size_t aio_threshold) override
bool performOptimize(const Settings * settings) override
{
return merge(aio_threshold, true);
const auto & applied_settings = (settings != nullptr) ? *settings : context.getSettings();
return merge(applied_settings.min_bytes_to_use_direct_io, true);
}
private:
......
......@@ -386,7 +386,7 @@ private:
*/
void waitForReplicaToProcessLogEntry(const String & replica_name, const LogEntry & entry);
bool performOptimize(size_t aio_threshold) override;
bool performOptimize(const Settings * settings) override;
/// Преобразовать число в строку формате суффиксов автоинкрементных нод в ZooKeeper.
static String padIndex(UInt64 index)
......
......@@ -25,7 +25,7 @@ int main(int argc, char ** argv)
{
Stopwatch watch;
CachedCompressedReadBuffer in(path, &cache, 0, 0, std::numeric_limits<size_t>::max());
CachedCompressedReadBuffer in(path, &cache, 0, 0);
WriteBufferFromFile out("/dev/null");
copyData(in, out);
......@@ -37,7 +37,7 @@ int main(int argc, char ** argv)
{
Stopwatch watch;
CachedCompressedReadBuffer in(path, &cache, 0, 0, std::numeric_limits<size_t>::max());
CachedCompressedReadBuffer in(path, &cache, 0, 0);
WriteBufferFromFile out("/dev/null");
copyData(in, out);
......
......@@ -269,7 +269,7 @@ void StorageBuffer::shutdown()
}
bool StorageBuffer::performOptimize(size_t aio_threshold)
bool StorageBuffer::performOptimize(const Settings * settings)
{
flushAllBuffers(false);
......
......@@ -129,9 +129,9 @@ void StorageMaterializedView::drop()
}
}
bool StorageMaterializedView::performOptimize(size_t aio_threshold)
bool StorageMaterializedView::performOptimize(const Settings * settings)
{
return data->optimize(aio_threshold);
return data->optimize(settings);
}
......
......@@ -2060,7 +2060,7 @@ BlockOutputStreamPtr StorageReplicatedMergeTree::write(ASTPtr query)
}
bool StorageReplicatedMergeTree::performOptimize(size_t aio_threshold)
bool StorageReplicatedMergeTree::performOptimize(const Settings * settings)
{
/// Померджим какие-нибудь куски из директории unreplicated.
/// TODO: Мерджить реплицируемые куски тоже.
......@@ -2074,12 +2074,15 @@ bool StorageReplicatedMergeTree::performOptimize(size_t aio_threshold)
MergeTreeData::DataPartsVector parts;
String merged_name;
auto always_can_merge = [](const MergeTreeData::DataPartPtr &a, const MergeTreeData::DataPartPtr &b) { return true; };
auto always_can_merge = [](const MergeTreeData::DataPartPtr & a, const MergeTreeData::DataPartPtr & b) { return true; };
if (!unreplicated_merger->selectPartsToMerge(parts, merged_name, 0, true, true, false, always_can_merge))
return false;
const auto & merge_entry = context.getMergeList().insert(database_name, table_name, merged_name);
unreplicated_merger->mergeParts(parts, merged_name, *merge_entry, aio_threshold);
const auto & applied_settings = (settings != nullptr) ? *settings : context.getSettings();
unreplicated_merger->mergeParts(parts, merged_name, *merge_entry, applied_settings.min_bytes_to_use_direct_io);
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册