mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fixed sanitizers errors
This commit is contained in:
parent
6ab451d41d
commit
7602c6c6cb
@ -366,6 +366,11 @@ struct AllocatorBufferDeleter<true, Allocator, Cell>
|
||||
size_t size;
|
||||
};
|
||||
|
||||
template <typename Key, typename Mapped>
|
||||
struct DefaultCellDisposer
|
||||
{
|
||||
void operator()(const Key &, const Mapped &) const {}
|
||||
};
|
||||
|
||||
// The HashTable
|
||||
template
|
||||
@ -1024,14 +1029,16 @@ public:
|
||||
return const_cast<std::decay_t<decltype(*this)> *>(this)->find(x, hash_value);
|
||||
}
|
||||
|
||||
template <typename Disposer = DefaultCellDisposer<typename Cell::key_type, typename Cell::mapped_type>>
|
||||
std::enable_if_t<Grower::performs_linear_probing_with_single_step, bool>
|
||||
ALWAYS_INLINE erase(const Key & x)
|
||||
ALWAYS_INLINE erase(const Key & x, Disposer && disposer = Disposer())
|
||||
{
|
||||
return erase(x, hash(x));
|
||||
return erase(x, hash(x), disposer);
|
||||
}
|
||||
|
||||
template <typename Disposer = DefaultCellDisposer<typename Cell::key_type, typename Cell::mapped_type>>
|
||||
std::enable_if_t<Grower::performs_linear_probing_with_single_step, bool>
|
||||
ALWAYS_INLINE erase(const Key & x, size_t hash_value)
|
||||
ALWAYS_INLINE erase(const Key & x, size_t hash_value, Disposer && disposer = Disposer())
|
||||
{
|
||||
/** Deletion from open addressing hash table without tombstones
|
||||
*
|
||||
@ -1134,7 +1141,9 @@ public:
|
||||
erased_key_position = next_position;
|
||||
}
|
||||
|
||||
buf[erased_key_position].setZero();
|
||||
auto & cell = buf[erased_key_position];
|
||||
disposer(cell.getKey(), cell.getMapped());
|
||||
cell.setZero();
|
||||
--m_size;
|
||||
|
||||
return true;
|
||||
|
@ -77,12 +77,6 @@ struct LRUHashMapCellNodeTraits
|
||||
static void set_previous(node * __restrict ptr, node * __restrict prev) { ptr->prev = prev; }
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct DefaultDisposer
|
||||
{
|
||||
void operator()(const Key &, const Value &) const {}
|
||||
};
|
||||
|
||||
template <typename TKey, typename TValue, typename Disposer, typename Hash, bool save_hash_in_cells>
|
||||
class LRUHashMapImpl :
|
||||
private HashMapTable<
|
||||
@ -164,14 +158,12 @@ public:
|
||||
/// Erase least recently used element from front of the list
|
||||
Cell & node = lru_list.front();
|
||||
|
||||
disposer(node.getKey(), node.getMapped());
|
||||
|
||||
const Key & element_to_remove_key = node.getKey();
|
||||
size_t key_hash = node.getHash(*this);
|
||||
|
||||
lru_list.pop_front();
|
||||
|
||||
[[maybe_unused]] bool erased = Base::erase(element_to_remove_key, key_hash);
|
||||
[[maybe_unused]] bool erased = Base::erase(element_to_remove_key, key_hash, disposer);
|
||||
assert(erased);
|
||||
}
|
||||
|
||||
@ -235,11 +227,8 @@ public:
|
||||
if (!it)
|
||||
return false;
|
||||
|
||||
disposer(it->getKey(), it->getMapped());
|
||||
|
||||
lru_list.erase(lru_list.iterator_to(*it));
|
||||
|
||||
return Base::erase(key, key_hash);
|
||||
return Base::erase(key, key_hash, disposer);
|
||||
}
|
||||
|
||||
void ALWAYS_INLINE clear()
|
||||
@ -275,8 +264,8 @@ private:
|
||||
Disposer disposer;
|
||||
};
|
||||
|
||||
template <typename Key, typename Value, typename Disposer = DefaultDisposer<Key, Value>, typename Hash = DefaultHash<Key>>
|
||||
template <typename Key, typename Value, typename Disposer = DefaultCellDisposer<Key, Value>, typename Hash = DefaultHash<Key>>
|
||||
using LRUHashMap = LRUHashMapImpl<Key, Value, Disposer, Hash, false>;
|
||||
|
||||
template <typename Key, typename Value, typename Disposer = DefaultDisposer<Key, Value>, typename Hash = DefaultHash<Key>>
|
||||
template <typename Key, typename Value, typename Disposer = DefaultCellDisposer<Key, Value>, typename Hash = DefaultHash<Key>>
|
||||
using LRUHashMapWithSavedHash = LRUHashMapImpl<Key, Value, Disposer, Hash, true>;
|
||||
|
@ -68,7 +68,7 @@ CacheDictionary<dictionary_key_type>::CacheDictionary(
|
||||
, update_queue(
|
||||
dict_id_.getNameForLogs(),
|
||||
update_queue_configuration_,
|
||||
[this](CacheDictionaryUpdateUnitPtr<dictionary_key_type> & unit_to_update)
|
||||
[this](CacheDictionaryUpdateUnitPtr<dictionary_key_type> unit_to_update)
|
||||
{
|
||||
update(unit_to_update);
|
||||
})
|
||||
@ -423,8 +423,11 @@ Columns CacheDictionary<dictionary_key_type>::getColumnsImpl(
|
||||
}
|
||||
|
||||
template <DictionaryKeyType dictionary_key_type>
|
||||
ColumnUInt8::Ptr CacheDictionary<dictionary_key_type>::hasKeys(const Columns & key_columns, const DataTypes &) const
|
||||
ColumnUInt8::Ptr CacheDictionary<dictionary_key_type>::hasKeys(const Columns & key_columns, const DataTypes & key_types) const
|
||||
{
|
||||
if (dictionary_key_type == DictionaryKeyType::complex)
|
||||
dict_struct.validateKeyTypes(key_types);
|
||||
|
||||
Arena complex_keys_arena;
|
||||
DictionaryKeysExtractor<dictionary_key_type> extractor(key_columns, complex_keys_arena);
|
||||
const auto & keys = extractor.getKeys();
|
||||
@ -642,10 +645,9 @@ BlockInputStreamPtr CacheDictionary<dictionary_key_type>::getBlockInputStream(co
|
||||
}
|
||||
|
||||
template <DictionaryKeyType dictionary_key_type>
|
||||
void CacheDictionary<dictionary_key_type>::update(CacheDictionaryUpdateUnitPtr<dictionary_key_type> & update_unit_ptr)
|
||||
void CacheDictionary<dictionary_key_type>::update(CacheDictionaryUpdateUnitPtr<dictionary_key_type> update_unit_ptr)
|
||||
{
|
||||
CurrentMetrics::Increment metric_increment{CurrentMetrics::DictCacheRequests};
|
||||
ProfileEvents::increment(ProfileEvents::DictCacheKeysRequested, update_unit_ptr->requested_simple_keys.size());
|
||||
|
||||
size_t found_num = 0;
|
||||
|
||||
@ -665,6 +667,8 @@ void CacheDictionary<dictionary_key_type>::update(CacheDictionaryUpdateUnitPtr<d
|
||||
else
|
||||
requested_keys_size = update_unit_ptr->requested_complex_key_rows.size();
|
||||
|
||||
ProfileEvents::increment(ProfileEvents::DictCacheKeysRequested, requested_keys_size);
|
||||
|
||||
const auto & fetch_request = update_unit_ptr->request;
|
||||
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
|
@ -181,7 +181,7 @@ private:
|
||||
|
||||
void setupHierarchicalAttribute();
|
||||
|
||||
void update(CacheDictionaryUpdateUnitPtr<dictionary_key_type> & update_unit_ptr);
|
||||
void update(CacheDictionaryUpdateUnitPtr<dictionary_key_type> update_unit_ptr);
|
||||
|
||||
/// Update dictionary source pointer if required and return it. Thread safe.
|
||||
/// MultiVersion is not used here because it works with constant pointers.
|
||||
|
@ -120,7 +120,7 @@ class CacheDictionaryUpdateQueue
|
||||
{
|
||||
public:
|
||||
/// Client of update queue must provide this function in constructor and perform update using update unit.
|
||||
using UpdateFunction = std::function<void (CacheDictionaryUpdateUnitPtr<dictionary_key_type> &)>;
|
||||
using UpdateFunction = std::function<void (CacheDictionaryUpdateUnitPtr<dictionary_key_type>)>;
|
||||
static_assert(dictionary_key_type != DictionaryKeyType::range, "Range key type is not supported by CacheDictionaryUpdateQueue");
|
||||
|
||||
CacheDictionaryUpdateQueue(
|
||||
|
@ -645,7 +645,8 @@ public:
|
||||
AIOContext aio_context(read_from_file_buffer_blocks_size);
|
||||
|
||||
PaddedPODArray<bool> processed(requests.size(), false);
|
||||
PaddedPODArray<io_event> events(requests.size());
|
||||
PaddedPODArray<io_event> events;
|
||||
events.resize_fill(requests.size());
|
||||
|
||||
size_t to_push = 0;
|
||||
size_t to_pop = 0;
|
||||
@ -1046,8 +1047,7 @@ private:
|
||||
throw Exception("Serialized columns size is greater than allowed block size and metadata", ErrorCodes::UNSUPPORTED_METHOD);
|
||||
|
||||
/// We cannot reuse place that is already allocated in file or memory cache so we erase key from index
|
||||
if (index.contains(key))
|
||||
index.erase(key);
|
||||
index.erase(key);
|
||||
|
||||
Cell cell;
|
||||
setCellDeadline(cell, now);
|
||||
|
Loading…
Reference in New Issue
Block a user