From 788ea2a5526c1cb56c70d6cc522b3a88b069363b Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 7 Aug 2012 20:37:45 +0000 Subject: [PATCH] dbms: development [#CONV-2944]. --- dbms/src/Storages/StorageMergeTree.cpp | 59 ++++++++++++++------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 32154f1caf6..e6b3d0c97d1 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -978,37 +978,40 @@ void StorageMergeTree::loadDataParts() * Удаление файлов будет произведено потом в методе clearOldParts. */ - DataParts::iterator prev_jt = new_data_parts->begin(); - DataParts::iterator curr_jt = prev_jt; - ++curr_jt; - while (curr_jt != new_data_parts->end()) + if (new_data_parts->size() >= 2) { - /// Куски данных за разные месяцы рассматривать не будем - if ((*curr_jt)->left_month != (*curr_jt)->right_month - || (*curr_jt)->right_month != (*prev_jt)->left_month - || (*prev_jt)->left_month != (*prev_jt)->right_month) + DataParts::iterator prev_jt = new_data_parts->begin(); + DataParts::iterator curr_jt = prev_jt; + ++curr_jt; + while (curr_jt != new_data_parts->end()) { - ++prev_jt; - ++curr_jt; - continue; - } + /// Куски данных за разные месяцы рассматривать не будем + if ((*curr_jt)->left_month != (*curr_jt)->right_month + || (*curr_jt)->right_month != (*prev_jt)->left_month + || (*prev_jt)->left_month != (*prev_jt)->right_month) + { + ++prev_jt; + ++curr_jt; + continue; + } - if ((*curr_jt)->contains(**prev_jt)) - { - LOG_WARNING(log, "Part " << (*curr_jt)->name << " contains " << (*prev_jt)->name); - new_data_parts->erase(prev_jt); - prev_jt = curr_jt; - ++curr_jt; - } - else if ((*prev_jt)->contains(**curr_jt)) - { - LOG_WARNING(log, "Part " << (*prev_jt)->name << " contains " << (*curr_jt)->name); - new_data_parts->erase(curr_jt++); - } - else - { - ++prev_jt; - ++curr_jt; + if ((*curr_jt)->contains(**prev_jt)) + { + LOG_WARNING(log, "Part " << (*curr_jt)->name << " contains " << (*prev_jt)->name); + new_data_parts->erase(prev_jt); + prev_jt = curr_jt; + ++curr_jt; + } + else if ((*prev_jt)->contains(**curr_jt)) + { + LOG_WARNING(log, "Part " << (*prev_jt)->name << " contains " << (*curr_jt)->name); + new_data_parts->erase(curr_jt++); + } + else + { + ++prev_jt; + ++curr_jt; + } } }