Small renaming for more clarity

This commit is contained in:
Robert Schulze 2023-01-02 11:02:27 +00:00
parent 4f3051de19
commit 4cb7ac57e4
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
2 changed files with 11 additions and 11 deletions

View File

@ -180,8 +180,8 @@ try
return res; return res;
}; };
auto entry = std::make_shared<Chunk>(to_single_chunk(chunks)); auto result = std::make_shared<Chunk>(to_single_chunk(partial_results));
new_entry_size_in_bytes = entry->allocatedBytes(); // updated because compression potentially affects the size of the single chunk vs the aggregate size of individual chunks new_entry_size_in_bytes = result->allocatedBytes(); // updated because compression potentially affects the size of the single chunk vs the aggregate size of individual chunks
std::lock_guard lock(mutex); std::lock_guard lock(mutex);
@ -212,13 +212,13 @@ try
/// Insert or replace if enough space /// Insert or replace if enough space
if (sufficient_space_in_cache()) if (sufficient_space_in_cache())
{ {
cache_size_in_bytes += entry->allocatedBytes(); cache_size_in_bytes += result->allocatedBytes();
if (auto it = cache.find(key); it != cache.end()) if (auto it = cache.find(key); it != cache.end())
cache_size_in_bytes -= it->second->allocatedBytes(); /// key replacement cache_size_in_bytes -= it->second->allocatedBytes(); /// key replacement
/// cache[key] = entry; /// does no replacement for unclear reasons /// cache[key] = result; /// does no replacement for unclear reasons
cache.erase(key); cache.erase(key);
cache[key] = entry; cache[key] = result;
LOG_DEBUG(&Poco::Logger::get("QueryResultCache"), "Stored result of query {}", key.queryStringFromAst()); LOG_DEBUG(&Poco::Logger::get("QueryResultCache"), "Stored result of query {}", key.queryStringFromAst());
} }
@ -227,15 +227,15 @@ catch (const std::exception &)
{ {
} }
void QueryResultCache::Writer::buffer(Chunk && chunk) void QueryResultCache::Writer::buffer(Chunk && partial_result)
{ {
if (skip_insert) if (skip_insert)
return; return;
chunks.emplace_back(std::move(chunk)); partial_results.emplace_back(std::move(partial_result));
new_entry_size_in_bytes += chunks.back().allocatedBytes(); new_entry_size_in_bytes += partial_results.back().allocatedBytes();
new_entry_size_in_rows += chunks.back().getNumRows(); new_entry_size_in_rows += partial_results.back().getNumRows();
if ((new_entry_size_in_bytes > max_entry_size_in_bytes) || (new_entry_size_in_rows > max_entry_size_in_rows)) if ((new_entry_size_in_bytes > max_entry_size_in_bytes) || (new_entry_size_in_rows > max_entry_size_in_rows))
skip_insert = true; skip_insert = true;

View File

@ -80,7 +80,7 @@ public:
{ {
public: public:
~Writer(); ~Writer();
void buffer(Chunk && chunk); void buffer(Chunk && partial_result);
private: private:
std::mutex & mutex; std::mutex & mutex;
Cache & cache TSA_GUARDED_BY(mutex); Cache & cache TSA_GUARDED_BY(mutex);
@ -94,7 +94,7 @@ public:
const size_t max_entry_size_in_rows; const size_t max_entry_size_in_rows;
const std::chrono::time_point<std::chrono::system_clock> query_start_time = std::chrono::system_clock::now(); /// Writer construction/destruction coincides with query start/end const std::chrono::time_point<std::chrono::system_clock> query_start_time = std::chrono::system_clock::now(); /// Writer construction/destruction coincides with query start/end
const std::chrono::milliseconds min_query_duration; const std::chrono::milliseconds min_query_duration;
Chunks chunks; Chunks partial_results;
std::atomic<bool> skip_insert = false; std::atomic<bool> skip_insert = false;
Writer(std::mutex & mutex_, Cache & cache_, const Key & key_, Writer(std::mutex & mutex_, Cache & cache_, const Key & key_,