This commit is contained in:
nikitamikhaylov 2020-11-17 00:37:38 +03:00
parent 20ae82b24b
commit 4345f2987d
3 changed files with 17 additions and 12 deletions

View File

@ -376,7 +376,6 @@ size_t CacheDictionary::findCellIdxForSet(const Key & id) const
void CacheDictionary::has(const PaddedPODArray<Key> & ids, PaddedPODArray<UInt8> & out) const
{
std::cout << "has" << std::endl;
/// There are three types of ids.
/// - Valid ids. These ids are presented in local cache and their lifetime is not expired.
/// - CacheExpired ids. Ids that are in local cache, but their values are rotted (lifetime is expired).
@ -509,18 +508,21 @@ void CacheDictionary::createAttributes()
}
}
CacheDictionary::Attribute CacheDictionary::createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value)
CacheDictionary::Attribute CacheDictionary::createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value) /* NOLINT(readability-convert-member-functions-to-static) */
{
Attribute attr{type, name, {}, {}};
switch (type)
{
/* Macro argument should be enclosed in parentheses, but if do so we cannot initialize \
* NearestFieldType which takes TYPE as a template parameter. */
#define DISPATCH(TYPE)\
case AttributeUnderlyingType::ut##TYPE:\
attr.null_value = TYPE(null_value.get<NearestFieldType<TYPE>>());\
attr.arrays = std::make_unique<ContainerType<TYPE>>(size);\
case AttributeUnderlyingType::ut##TYPE: {\
attr.null_value = TYPE(null_value.get<NearestFieldType<TYPE>>()); /* NOLINT(bugprone-macro-parentheses) */ \
attr.arrays = std::make_unique<ContainerType<TYPE>>(size); /* NOLINT(bugprone-macro-parentheses) */ \
bytes_allocated += size * sizeof(TYPE);\
break;
break;}
DISPATCH(UInt8)
DISPATCH(UInt16)
DISPATCH(UInt32)
@ -536,13 +538,14 @@ CacheDictionary::Attribute CacheDictionary::createAttributeWithTypeAndName(const
DISPATCH(Float32)
DISPATCH(Float64)
#undef DISPATCH
case AttributeUnderlyingType::utString:
case AttributeUnderlyingType::utString: {
attr.null_value = null_value.get<String>();
attr.arrays = std::make_unique<ContainerType<StringRef>>(size);
bytes_allocated += size * sizeof(StringRef);
if (!string_arena)
string_arena = std::make_unique<ArenaWithFreeLists>();
break;
}
}
return attr;
@ -552,9 +555,11 @@ void CacheDictionary::setDefaultAttributeValue(Attribute & attribute, const Key
{
switch (attribute.type)
{
/* Macro argument should be enclosed in parentheses, but if do so we cannot initialize \
* NearestFieldType which takes TYPE as a template parameter. */
#define DISPATCH(TYPE)\
case AttributeUnderlyingType::ut##TYPE:\
std::get<ContainerPtrType<TYPE>>(attribute.arrays)[idx] = std::get<TYPE>(attribute.null_value);\
std::get<ContainerPtrType<TYPE>>(attribute.arrays)[idx] = std::get<TYPE>(attribute.null_value); /* NOLINT(bugprone-macro-parentheses) */ \
break;
DISPATCH(UInt8)
DISPATCH(UInt16)

View File

@ -257,7 +257,7 @@ private:
void createAttributes();
Attribute createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value);
Attribute createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value); /* NOLINT(readability-convert-member-functions-to-static) */
template <typename AttributeType, typename OutputType, typename DefaultGetter>
void getItemsNumberImpl(

View File

@ -40,7 +40,7 @@ int main(int argc, char ** argv)
size_t num_reconnects = 0;
constexpr size_t max_reconnects = 100;
auto ensureSession = [&]
auto ensure_session = [&]
{
if (zookeeper->expired())
{
@ -70,7 +70,7 @@ int main(int argc, char ** argv)
else if (Coordination::isHardwareError(e.code))
{
/// Reinitialize the session and move the node to the end of the queue for later retry.
if (!ensureSession())
if (!ensure_session())
throw;
list_futures.emplace_back(it->first, zookeeper->asyncGetChildren(it->first));
continue;
@ -85,7 +85,7 @@ int main(int argc, char ** argv)
{
std::string child_path = it->first == "/" ? it->first + name : it->first + '/' + name;
ensureSession();
ensure_session();
list_futures.emplace_back(child_path, zookeeper->asyncGetChildren(child_path));
}
}