Merge pull request #22721 from kitaisreal/memory-storage-sync-comments-and-code

MemoryStorage sync comments and code
This commit is contained in:
Maksim Kita 2021-04-06 21:56:41 +03:00 committed by GitHub
commit e38206ee02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -26,10 +26,6 @@ class MemorySource : public SourceWithProgress
{
using InitializerFunc = std::function<void(std::shared_ptr<const Blocks> &)>;
public:
/// Blocks are stored in std::list which may be appended in another thread.
/// We use pointer to the beginning of the list and its current size.
/// We don't need synchronisation in this reader, because while we hold SharedLock on storage,
/// only new elements can be added to the back of the list, so our iterators remain valid
MemorySource(
Names column_names_,
@ -59,7 +55,7 @@ protected:
size_t current_index = getAndIncrementExecutionIndex();
if (current_index >= data->size())
if (!data || current_index >= data->size())
{
return {};
}

View File

@ -97,7 +97,7 @@ public:
void delayReadForGlobalSubqueries() { delay_read_for_global_subqueries = true; }
private:
/// MultiVersion data storage, so that we can copy the list of blocks to readers.
/// MultiVersion data storage, so that we can copy the vector of blocks to readers.
MultiVersion<Blocks> data;