mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Check that the set has been built before it is used
This commit is contained in:
parent
fbf09a1115
commit
ae2da38549
@ -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<void> local_is_created_future;
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<void> local_is_created_future;
|
||||
// {
|
||||
// std::lock_guard<std::mutex> 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();
|
||||
|
@ -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<bool> is_created = false;
|
||||
std::promise<void> is_created_promise;
|
||||
mutable std::mutex is_created_future_mutex;
|
||||
mutable std::shared_future<void> is_created_future TSA_GUARDED_BY(is_created_future_mutex);
|
||||
// std::promise<void> is_created_promise;
|
||||
// mutable std::mutex is_created_future_mutex;
|
||||
// mutable std::shared_future<void> 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(
|
||||
|
Loading…
Reference in New Issue
Block a user