diff --git a/src/Interpreters/Set.cpp b/src/Interpreters/Set.cpp index a22e430ea67..c5e3cb8ad63 100644 --- a/src/Interpreters/Set.cpp +++ b/src/Interpreters/Set.cpp @@ -241,22 +241,22 @@ bool Set::insertFromBlock(const Columns & columns) void Set::finishInsert() { is_created = true; - is_created_promise.set_value(); +// is_created_promise.set_value(); } -void Set::waitForIsCreated() const +void Set::checkIsCreated() const { - if (is_created.load()) - return; - -// FIXME: each thread must wait on its own copy of the future - std::shared_future local_is_created_future; - { - std::lock_guard lock(is_created_future_mutex); - local_is_created_future = is_created_future; - } - - local_is_created_future.wait(); + if (!is_created.load()) + throw Exception(ErrorCodes::LOGICAL_ERROR, "Logical error: Trying to use set before it has been built."); +// +//// FIXME: each thread must wait on its own copy of the future +// std::shared_future local_is_created_future; +// { +// std::lock_guard lock(is_created_future_mutex); +// local_is_created_future = is_created_future; +// } +// +// local_is_created_future.wait(); } ColumnPtr Set::execute(const ColumnsWithTypeAndName & columns, bool negative) const @@ -266,7 +266,7 @@ ColumnPtr Set::execute(const ColumnsWithTypeAndName & columns, bool negative) co if (0 == num_key_columns) throw Exception(ErrorCodes::LOGICAL_ERROR, "Logical error: no columns passed to Set::execute method."); - waitForIsCreated(); + checkIsCreated(); auto res = ColumnUInt8::create(); ColumnUInt8::Container & vec_res = res->getData(); diff --git a/src/Interpreters/Set.h b/src/Interpreters/Set.h index be15c449e09..cbfbe874b35 100644 --- a/src/Interpreters/Set.h +++ b/src/Interpreters/Set.h @@ -34,7 +34,7 @@ public: : log(&Poco::Logger::get("Set")), limits(limits_), fill_set_elements(fill_set_elements_), transform_null_in(transform_null_in_) { - is_created_future = is_created_promise.get_future(); +// is_created_future = is_created_promise.get_future(); } /** Set can be created either from AST or from a stream of data (subquery result). @@ -55,7 +55,7 @@ public: /// finishInsert and isCreated are thread-safe bool isCreated() const { return is_created.load(); } - void waitForIsCreated() const; + void checkIsCreated() const; /** For columns of 'block', check belonging of corresponding rows to the set. * Return UInt8 column with the result. @@ -70,7 +70,7 @@ public: const DataTypes & getElementsTypes() const { return set_elements_types; } bool hasExplicitSetElements() const { return fill_set_elements; } - Columns getSetElements() const { waitForIsCreated(); return { set_elements.begin(), set_elements.end() }; } + Columns getSetElements() const { checkIsCreated(); return { set_elements.begin(), set_elements.end() }; } void checkColumnsNumber(size_t num_key_columns) const; bool areTypesEqual(size_t set_type_idx, const DataTypePtr & other_type) const; @@ -118,9 +118,9 @@ private: /// Check if set contains all the data. std::atomic is_created = false; - std::promise is_created_promise; - mutable std::mutex is_created_future_mutex; - mutable std::shared_future is_created_future TSA_GUARDED_BY(is_created_future_mutex); +// std::promise is_created_promise; +// mutable std::mutex is_created_future_mutex; +// mutable std::shared_future is_created_future TSA_GUARDED_BY(is_created_future_mutex); /// If in the left part columns contains the same types as the elements of the set. void executeOrdinary(