diff --git a/.clang-format b/.clang-format index 3501c92a3..2cdfadd74 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,10 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true +AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left -AlignOperands: true +AlignOperands: AlignAfterOperator AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: true @@ -70,6 +70,7 @@ IncludeIsMainRegex: '([-_](test|unittest))?$' IndentCaseLabels: true IndentWidth: 4 IndentWrappedFunctionNames: false +InsertBraces: true KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' @@ -100,3 +101,4 @@ SpacesInSquareBrackets: false Standard: Auto TabWidth: 4 UseTab: Never + diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 6657e778d..d7a9ff537 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,3 +9,4 @@ # Reformatted codebase with clang-format efb1ad8497bc43a84d7a90fe58b25a242aa13183 +28ea72feb02e36e819b864e960f73e8cc08e80ec diff --git a/src/chunked_data_view/Axis.cc b/src/chunked_data_view/Axis.cc index e727261b8..4b2fb27f7 100644 --- a/src/chunked_data_view/Axis.cc +++ b/src/chunked_data_view/Axis.cc @@ -53,7 +53,7 @@ size_t Axis::index(const fdb5::Key& key) const { // Sanity check whether the key is containing information about the axis const std::vector& keys = key.names(); - size_t prod = 1; + size_t prod = 1; size_t index = 0; for (int i = parameters().size() - 1; i >= 0; --i) { diff --git a/src/chunked_data_view/Buffer.h b/src/chunked_data_view/Buffer.h index 500cff90b..e6a60f68c 100644 --- a/src/chunked_data_view/Buffer.h +++ b/src/chunked_data_view/Buffer.h @@ -31,7 +31,7 @@ class Buffer { } bitset_ = std::vector(prod); - data_ = std::vector(prod * chunkShape[chunkShape.size() - 1]); + data_ = std::vector(prod * chunkShape[chunkShape.size() - 1]); }; void resize(size_t size) { diff --git a/src/chunked_data_view/ChunkedDataViewBuilder.cc b/src/chunked_data_view/ChunkedDataViewBuilder.cc index 525d704ef..4b8a5f744 100644 --- a/src/chunked_data_view/ChunkedDataViewBuilder.cc +++ b/src/chunked_data_view/ChunkedDataViewBuilder.cc @@ -44,7 +44,7 @@ ChunkedDataViewBuilder& ChunkedDataViewBuilder::extendOnAxis(size_t index) { bool ChunkedDataViewBuilder::doPartsAlign(const std::vector& viewParts) { const ViewPart& first = viewParts[0]; - bool extensible = true; + bool extensible = true; for (const ViewPart& viewPart : viewParts) { extensible &= first.extensibleWith(viewPart, extensionAxisIndex_.value_or(0)); } diff --git a/src/chunked_data_view/GribExtractor.cc b/src/chunked_data_view/GribExtractor.cc index 9631086de..e3f8b548e 100644 --- a/src/chunked_data_view/GribExtractor.cc +++ b/src/chunked_data_view/GribExtractor.cc @@ -72,15 +72,15 @@ void GribExtractor::writeInto(const metkit::mars::MarsRequest& request, } iterator_empty = false; - const auto& key = std::get<0>(*res); - auto& data_handle = std::get<1>(*res); + const auto& key = std::get<0>(*res); + auto& data_handle = std::get<1>(*res); const size_t msgIndex = computeBufferIndex(axes, key); try { eckit::message::Reader reader(*data_handle); eckit::message::Message msg{}; - auto copyInto = ptr + msgIndex * layout.countValues; + auto copyInto = ptr + msgIndex * layout.countValues; const auto end = copyInto + layout.countValues; ASSERT(end - ptr <= len); diff --git a/src/chunked_data_view/IndexMapper.cc b/src/chunked_data_view/IndexMapper.cc index 85ffee855..0dee2c301 100644 --- a/src/chunked_data_view/IndexMapper.cc +++ b/src/chunked_data_view/IndexMapper.cc @@ -32,7 +32,7 @@ size_t index_mapping::axis_index_to_buffer_index(const std::vector& indi ASSERT(indices.size() == axes.size()); - size_t prod = 1; + size_t prod = 1; size_t index = 0; for (int i = axes.size() - 1; i >= 0; --i) { @@ -72,7 +72,7 @@ std::vector index_mapping::to_axis_parameter_index(const size_t& index, } size_t index_in_dim = chunk_index / dim_prod; // (1) - result[i] = index_in_dim; + result[i] = index_in_dim; chunk_index -= index_in_dim * dim_prod; // (2) } diff --git a/src/chunked_data_view/RequestManipulation.cc b/src/chunked_data_view/RequestManipulation.cc index e9bba3f4b..e8e5a02e5 100644 --- a/src/chunked_data_view/RequestManipulation.cc +++ b/src/chunked_data_view/RequestManipulation.cc @@ -45,7 +45,7 @@ void RequestManipulation::updateRequest(metkit::mars::MarsRequest& request, cons } size_t index_in_dim = chunk_index / dim_prod; // (1) - index[i] = index_in_dim; + index[i] = index_in_dim; chunk_index -= index_in_dim * dim_prod; // (2) } diff --git a/src/chunked_data_view/include/chunked_data_view/Fdb.h b/src/chunked_data_view/include/chunked_data_view/Fdb.h index b60798ea7..8f2e21827 100644 --- a/src/chunked_data_view/include/chunked_data_view/Fdb.h +++ b/src/chunked_data_view/include/chunked_data_view/Fdb.h @@ -24,8 +24,8 @@ namespace chunked_data_view { class FdbInterface { public: - virtual ~FdbInterface() = default; - virtual std::unique_ptr retrieve(const metkit::mars::MarsRequest& request) = 0; + virtual ~FdbInterface() = default; + virtual std::unique_ptr retrieve(const metkit::mars::MarsRequest& request) = 0; virtual std::unique_ptr inspect(const metkit::mars::MarsRequest& request) = 0; }; diff --git a/src/chunked_data_view/include/chunked_data_view/ListIterator.h b/src/chunked_data_view/include/chunked_data_view/ListIterator.h index 853d1289f..33e43f21a 100644 --- a/src/chunked_data_view/include/chunked_data_view/ListIterator.h +++ b/src/chunked_data_view/include/chunked_data_view/ListIterator.h @@ -25,7 +25,7 @@ class ListIteratorInterface { public: - virtual ~ListIteratorInterface() = default; + virtual ~ListIteratorInterface() = default; virtual std::optional>> next() = 0; }; diff --git a/src/chunked_data_view_bindings/bindings.cc b/src/chunked_data_view_bindings/bindings.cc index 8584830fa..2f0208b75 100644 --- a/src/chunked_data_view_bindings/bindings.cc +++ b/src/chunked_data_view_bindings/bindings.cc @@ -22,7 +22,7 @@ #include #include -namespace py = pybind11; +namespace py = pybind11; namespace cdv = chunked_data_view; PYBIND11_MODULE(chunked_data_view_bindings, m) { diff --git a/src/dummy_daos/daos.cc b/src/dummy_daos/daos.cc index 0e1fd90c3..42d9f7d25 100644 --- a/src/dummy_daos/daos.cc +++ b/src/dummy_daos/daos.cc @@ -83,14 +83,18 @@ int daos_pool_connect(const char* pool, const char* sys, unsigned int flags, dao poh->impl = nullptr; - if (sys != NULL) + if (sys != NULL) { NOTIMP; - if (flags != DAOS_PC_RW) + } + if (flags != DAOS_PC_RW) { NOTIMP; - if (info != NULL) + } + if (info != NULL) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } eckit::PathName path = dummy_daos_root() / pool; eckit::PathName realpath{dummy_daos_root()}; @@ -109,18 +113,20 @@ int daos_pool_connect(const char* pool, const char* sys, unsigned int flags, dao } catch (eckit::FailedSystemCall& e) { - if (path.exists()) + if (path.exists()) { throw; + } return -1; } } - if (!realpath.exists()) + if (!realpath.exists()) { return -1; + } - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = realpath; - poh->impl = impl.release(); + poh->impl = impl.release(); return 0; } @@ -130,8 +136,9 @@ int daos_pool_disconnect(daos_handle_t poh, daos_event_t* ev) { ASSERT(poh.impl); delete poh.impl; - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } return 0; } @@ -139,8 +146,9 @@ int daos_pool_disconnect(daos_handle_t poh, daos_event_t* ev) { int daos_pool_list_cont(daos_handle_t poh, daos_size_t* ncont, struct daos_pool_cont_info* cbuf, daos_event_t* ev) { ASSERT(poh.impl); - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } daos_size_t n(*ncont); @@ -151,11 +159,13 @@ int daos_pool_list_cont(daos_handle_t poh, daos_size_t* ncont, struct daos_pool_ *ncont = files.size(); - if (cbuf == NULL) + if (cbuf == NULL) { return 0; + } - if (files.size() > n) + if (files.size() > n) { return -1; + } daos_size_t nfound = 0; @@ -178,14 +188,15 @@ int daos_pool_list_cont(daos_handle_t poh, daos_size_t* ncont, struct daos_pool_ } const char* uuid_cstr = uuid_str.c_str(); - uuid_t uuid = {0}; + uuid_t uuid = {0}; ASSERT(uuid_parse(uuid_cstr, uuid) == 0); uuid_copy(cbuf[nfound - 1].pci_uuid, uuid); } catch (eckit::FailedSystemCall& e) { - if (f.exists()) + if (f.exists()) { throw; + } --nfound; } } @@ -231,13 +242,15 @@ int daos_cont_create_internal(daos_handle_t poh, uuid_t* uuid) { eckit::PathName cont_path = poh.impl->path / cont_uuid_cstr; - if (cont_path.exists()) + if (cont_path.exists()) { throw eckit::SeriousBug("UUID clash in cont create"); + } cont_path.mkdir(); - if (uuid != NULL) + if (uuid != NULL) { uuid_copy(*uuid, new_uuid); + } return 0; } @@ -256,23 +269,27 @@ int daos_cont_create(daos_handle_t poh, uuid_t* uuid, daos_prop_t* cont_prop, da if (cont_prop != NULL && cont_prop->dpp_entries) { - if (cont_prop->dpp_nr != 1) + if (cont_prop->dpp_nr != 1) { NOTIMP; - if (cont_prop->dpp_entries[0].dpe_type != DAOS_PROP_CO_LABEL) + } + if (cont_prop->dpp_entries[0].dpe_type != DAOS_PROP_CO_LABEL) { NOTIMP; + } struct daos_prop_entry* entry = &cont_prop->dpp_entries[0]; - if (entry == NULL) + if (entry == NULL) { NOTIMP; + } std::string cont_name{entry->dpe_str}; return daos_cont_create_with_label(poh, cont_name.c_str(), NULL, uuid, ev); } - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } uuid_t new_uuid = {0}; @@ -297,8 +314,9 @@ int daos_cont_create(daos_handle_t poh, uuid_t* uuid, daos_prop_t* cont_prop, da } } - if (uuid != NULL) + if (uuid != NULL) { uuid_copy(*uuid, new_uuid); + } return 0; } @@ -307,18 +325,21 @@ int daos_cont_create_with_label(daos_handle_t poh, const char* label, daos_prop_ daos_event_t* ev) { ASSERT(poh.impl); - if (cont_prop != NULL) + if (cont_prop != NULL) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } ASSERT(std::string{label}.rfind("__dummy_daos_uuid_", 0) != 0); ASSERT(strlen(label) <= DAOS_PROP_LABEL_MAX_LEN); eckit::PathName label_symlink_path = poh.impl->path / label; - if (label_symlink_path.exists()) + if (label_symlink_path.exists()) { return 0; + } uuid_t new_uuid = {0}; @@ -349,8 +370,9 @@ int daos_cont_create_with_label(daos_handle_t poh, const char* label, daos_prop_ } } - if (uuid != NULL) + if (uuid != NULL) { uuid_copy(*uuid, new_uuid); + } return 0; } @@ -371,15 +393,17 @@ int daos_cont_create_with_label(daos_handle_t poh, const char* label, daos_prop_ int daos_cont_destroy(daos_handle_t poh, const char* cont, int force, daos_event_t* ev) { ASSERT(poh.impl); - if (force != 1) + if (force != 1) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } ASSERT(std::string{cont}.rfind("__dummy_daos_uuid_", 0) != 0); eckit::PathName path = poh.impl->path; - uuid_t uuid = {0}; + uuid_t uuid = {0}; if (uuid_parse(cont, uuid) == 0) { path /= std::string("__dummy_daos_uuid_") + cont; } @@ -396,8 +420,9 @@ int daos_cont_destroy(daos_handle_t poh, const char* cont, int force, daos_event } catch (eckit::FailedSystemCall& e) { - if (path.exists()) + if (path.exists()) { throw; + } return -DER_NONEXIST; } @@ -407,8 +432,9 @@ int daos_cont_destroy(daos_handle_t poh, const char* cont, int force, daos_event } catch (eckit::FailedSystemCall& e) { - if (realpath.exists()) + if (realpath.exists()) { throw; + } return -DER_NONEXIST; } @@ -419,17 +445,20 @@ int daos_cont_open(daos_handle_t poh, const char* cont, unsigned int flags, daos daos_event_t* ev) { ASSERT(poh.impl); - if (flags != DAOS_COO_RW) + if (flags != DAOS_COO_RW) { NOTIMP; - if (info != NULL) + } + if (info != NULL) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } ASSERT(std::string{cont}.rfind("__dummy_daos_uuid_", 0) != 0); eckit::PathName path = poh.impl->path; - uuid_t uuid = {0}; + uuid_t uuid = {0}; if (uuid_parse(cont, uuid) == 0) { path /= std::string("__dummy_daos_uuid_") + cont; } @@ -437,8 +466,9 @@ int daos_cont_open(daos_handle_t poh, const char* cont, unsigned int flags, daos path /= cont; } - if (!path.exists()) + if (!path.exists()) { return -DER_NONEXIST; + } eckit::PathName realpath{poh.impl->path}; try { @@ -448,15 +478,17 @@ int daos_cont_open(daos_handle_t poh, const char* cont, unsigned int flags, daos } catch (eckit::FailedSystemCall& e) { - if (path.exists()) + if (path.exists()) { throw; + } return -DER_NONEXIST; } - if (!realpath.exists()) + if (!realpath.exists()) { return -DER_NONEXIST; + } - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = realpath; coh->impl = impl.release(); @@ -468,8 +500,9 @@ int daos_cont_close(daos_handle_t coh, daos_event_t* ev) { ASSERT(coh.impl); delete coh.impl; - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } return 0; } @@ -479,8 +512,9 @@ int daos_cont_alloc_oids(daos_handle_t coh, daos_size_t num_oids, uint64_t* oid, static uint64_t next_oid = 0; ASSERT(coh.impl); - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } ASSERT(num_oids > (uint64_t)0); // support for multi-node clients running dummy DAOS backed by a @@ -520,14 +554,18 @@ int daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t* oid, enum daos_otype daos_oclass_hints_t hints, uint32_t args) { ASSERT(coh.impl); - if (type != DAOS_OT_KV_HASHED && type != DAOS_OT_ARRAY && type != DAOS_OT_ARRAY_BYTE) + if (type != DAOS_OT_KV_HASHED && type != DAOS_OT_ARRAY && type != DAOS_OT_ARRAY_BYTE) { NOTIMP; - if (cid != OC_S1) + } + if (cid != OC_S1) { NOTIMP; - if (hints != 0) + } + if (hints != 0) { NOTIMP; - if (args != 0) + } + if (args != 0) { NOTIMP; + } oid->hi &= (uint64_t)0x00000000FFFFFFFF; oid->hi |= ((((uint64_t)type) & OID_FMT_TYPE_MAX) << OID_FMT_TYPE_SHIFT); @@ -541,17 +579,19 @@ int daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t* oid, enum daos_otype int daos_kv_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_handle_t* oh, daos_event_t* ev) { ASSERT(coh.impl); - if (mode != DAOS_OO_RW) + if (mode != DAOS_OO_RW) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } std::stringstream os; os << std::setw(16) << std::setfill('0') << std::hex << oid.hi; os << "."; os << std::setw(16) << std::setfill('0') << std::hex << oid.lo; - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = coh.impl->path / os.str(); impl->path.mkdir(); @@ -566,10 +606,12 @@ int daos_kv_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_h int daos_kv_destroy(daos_handle_t oh, daos_handle_t th, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } try { @@ -577,8 +619,9 @@ int daos_kv_destroy(daos_handle_t oh, daos_handle_t th, daos_event_t* ev) { } catch (eckit::FailedSystemCall& e) { - if (oh.impl->path.exists()) + if (oh.impl->path.exists()) { throw; + } return -DER_NONEXIST; } @@ -590,8 +633,9 @@ int daos_obj_close(daos_handle_t oh, daos_event_t* ev) { ASSERT(oh.impl); delete oh.impl; - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } return 0; } @@ -609,12 +653,15 @@ int daos_kv_put(daos_handle_t oh, daos_handle_t th, uint64_t flags, const char* daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (flags != 0) + } + if (flags != 0) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } eckit::FileHandle fh(oh.impl->path / key, true); fh.openForWrite(eckit::Length(size)); @@ -629,32 +676,39 @@ int daos_kv_get(daos_handle_t oh, daos_handle_t th, uint64_t flags, const char* daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (flags != 0) + } + if (flags != 0) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } bool exists = (oh.impl->path / key).exists(); - if (!exists && buf != NULL) + if (!exists && buf != NULL) { return -DER_NONEXIST; + } daos_size_t dest_size = *size; - *size = 0; - if (!exists) + *size = 0; + if (!exists) { return 0; + } eckit::FileHandle fh(oh.impl->path / key); eckit::Length len = fh.size(); - *size = len; + *size = len; - if (buf == NULL) + if (buf == NULL) { return 0; + } - if (len > dest_size) + if (len > dest_size) { return -1; + } fh.openForRead(); eckit::AutoClose closer(fh); @@ -667,20 +721,25 @@ int daos_kv_get(daos_handle_t oh, daos_handle_t th, uint64_t flags, const char* int daos_kv_remove(daos_handle_t oh, daos_handle_t th, uint64_t flags, const char* key, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (flags != 0) + } + if (flags != 0) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - if (!oh.impl->path.exists()) + if (!oh.impl->path.exists()) { return -1; + } /// @todo: should removal of a non-existing key fail? /// @todo: if not, can the exist check be avoided and unlink be called directly? - if ((oh.impl->path / key).exists()) + if ((oh.impl->path / key).exists()) { (oh.impl->path / key).unlink(); + } return 0; } @@ -693,48 +752,61 @@ int daos_kv_list(daos_handle_t oh, daos_handle_t th, uint32_t* nr, daos_key_desc static std::string req_hash; static unsigned long long n = (((unsigned long long)::getpid()) << 32); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - if (nr == NULL) + if (nr == NULL) { return -1; - if (kds == NULL) + } + if (kds == NULL) { return -1; - if (sgl == NULL) + } + if (sgl == NULL) { return -1; - if (sgl->sg_nr != 1) + } + if (sgl->sg_nr != 1) { NOTIMP; - if (sgl->sg_iovs == NULL) + } + if (sgl->sg_iovs == NULL) { return -1; - if (anchor == NULL) + } + if (anchor == NULL) { return -1; + } - if (!oh.impl->path.exists()) + if (!oh.impl->path.exists()) { return -1; + } - if (anchor->da_type == DAOS_ANCHOR_TYPE_EOF) + if (anchor->da_type == DAOS_ANCHOR_TYPE_EOF) { return -1; - if (anchor->da_type == DAOS_ANCHOR_TYPE_HKEY) + } + if (anchor->da_type == DAOS_ANCHOR_TYPE_HKEY) { NOTIMP; + } if (anchor->da_type == DAOS_ANCHOR_TYPE_ZERO) { /// client process must consume all key names before starting a new request - if (ongoing_req.size() != 0) + if (ongoing_req.size() != 0) { NOTIMP; + } std::vector files; std::vector dirs; oh.impl->path.children(files, dirs); - for (auto& f : files) + for (auto& f : files) { ongoing_req.push_back(f.baseName()); + } anchor->da_type = DAOS_ANCHOR_TYPE_KEY; - std::string hostname = eckit::Main::hostname(); + std::string hostname = eckit::Main::hostname(); static std::string format = "%Y%m%d.%H%M%S"; std::ostringstream os; os << eckit::TimeStamp(format) << '.' << hostname << '.' << n++; @@ -753,24 +825,27 @@ int daos_kv_list(daos_handle_t oh, daos_handle_t th, uint32_t* nr, daos_key_desc } else { - if (anchor->da_type != DAOS_ANCHOR_TYPE_KEY) + if (anchor->da_type != DAOS_ANCHOR_TYPE_KEY) { throw eckit::SeriousBug("Unexpected anchor type"); + } /// different processes cannot collaborate on consuming a same kv_list /// request (i.e. cannot share a hash) - if (std::string((char*)&(anchor->da_buf[0]), anchor->da_shard) != req_hash) + if (std::string((char*)&(anchor->da_buf[0]), anchor->da_shard) != req_hash) { NOTIMP; + } } - size_t remain_size = sgl->sg_iovs[0].iov_buf_len; + size_t remain_size = sgl->sg_iovs[0].iov_buf_len; uint32_t remain_kds = *nr; - size_t sgl_pos = 0; - *nr = 0; + size_t sgl_pos = 0; + *nr = 0; while (remain_kds > 0 && remain_size > 0 && ongoing_req.size() > 0) { size_t next_size = ongoing_req.back().size(); if (next_size > remain_size) { - if (*nr == 0) + if (*nr == 0) { return -1; + } remain_size = 0; continue; } @@ -783,8 +858,9 @@ int daos_kv_list(daos_handle_t oh, daos_handle_t th, uint32_t* nr, daos_key_desc *nr += 1; } - if (ongoing_req.size() == 0) + if (ongoing_req.size() == 0) { anchor->da_type = DAOS_ANCHOR_TYPE_EOF; + } return 0; } @@ -806,17 +882,19 @@ int daos_array_create(daos_handle_t coh, daos_obj_id_t oid, daos_handle_t th, da daos_size_t chunk_size, daos_handle_t* oh, daos_event_t* ev) { ASSERT(coh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } std::stringstream os; os << std::setw(16) << std::setfill('0') << std::hex << oid.hi; os << "."; os << std::setw(16) << std::setfill('0') << std::hex << oid.lo; - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = coh.impl->path / os.str(); impl->path.touch(); @@ -828,10 +906,12 @@ int daos_array_create(daos_handle_t coh, daos_obj_id_t oid, daos_handle_t th, da int daos_array_destroy(daos_handle_t oh, daos_handle_t th, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } try { @@ -839,8 +919,9 @@ int daos_array_destroy(daos_handle_t oh, daos_handle_t th, daos_event_t* ev) { } catch (eckit::FailedSystemCall& e) { - if (oh.impl->path.exists()) + if (oh.impl->path.exists()) { throw; + } return -DER_NONEXIST; } @@ -851,14 +932,17 @@ int daos_array_open(daos_handle_t coh, daos_obj_id_t oid, daos_handle_t th, unsi daos_size_t* chunk_size, daos_handle_t* oh, daos_event_t* ev) { ASSERT(coh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (mode != DAOS_OO_RW) + } + if (mode != DAOS_OO_RW) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - *cell_size = 1; + *cell_size = 1; *chunk_size = (uint64_t)1048576; std::stringstream os; @@ -866,7 +950,7 @@ int daos_array_open(daos_handle_t coh, daos_obj_id_t oid, daos_handle_t th, unsi os << "."; os << std::setw(16) << std::setfill('0') << std::hex << oid.lo; - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = coh.impl->path / os.str(); if (!impl->path.exists()) { @@ -881,17 +965,22 @@ int daos_array_open_with_attr(daos_handle_t coh, daos_obj_id_t oid, daos_handle_ daos_size_t cell_size, daos_size_t chunk_size, daos_handle_t* oh, daos_event_t* ev) { ASSERT(coh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (mode != DAOS_OO_RW) + } + if (mode != DAOS_OO_RW) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - if (cell_size != 1) + if (cell_size != 1) { NOTIMP; - if (chunk_size != (uint64_t)1048576) + } + if (chunk_size != (uint64_t)1048576) { NOTIMP; + } return daos_array_create(coh, oid, th, cell_size, chunk_size, oh, ev); } @@ -901,8 +990,9 @@ int daos_array_close(daos_handle_t oh, daos_event_t* ev) { ASSERT(oh.impl); delete oh.impl; - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } return 0; } @@ -913,22 +1003,28 @@ int daos_array_close(daos_handle_t oh, daos_event_t* ev) { int daos_array_write(daos_handle_t oh, daos_handle_t th, daos_array_iod_t* iod, d_sg_list_t* sgl, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - if (iod->arr_nr != 1) + if (iod->arr_nr != 1) { NOTIMP; + } - if (sgl->sg_nr != 1) + if (sgl->sg_nr != 1) { NOTIMP; + } // source memory len - if (sgl->sg_iovs[0].iov_buf_len != sgl->sg_iovs[0].iov_len) + if (sgl->sg_iovs[0].iov_buf_len != sgl->sg_iovs[0].iov_len) { NOTIMP; + } // source memory vs. target object len - if (sgl->sg_iovs[0].iov_buf_len != iod->arr_rgs[0].rg_len) + if (sgl->sg_iovs[0].iov_buf_len != iod->arr_rgs[0].rg_len) { NOTIMP; + } // sgl->sg_iovs[0].iov_buf is a void * with the data to write // sgl->sg_iovs[0].iov_buf_len is a size_t with the source len @@ -954,10 +1050,12 @@ int daos_array_write(daos_handle_t oh, daos_handle_t th, daos_array_iod_t* iod, int daos_array_get_size(daos_handle_t oh, daos_handle_t th, daos_size_t* size, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } *size = (daos_size_t)oh.impl->path.size(); @@ -967,22 +1065,28 @@ int daos_array_get_size(daos_handle_t oh, daos_handle_t th, daos_size_t* size, d int daos_array_read(daos_handle_t oh, daos_handle_t th, daos_array_iod_t* iod, d_sg_list_t* sgl, daos_event_t* ev) { ASSERT(oh.impl); - if (th.impl != DAOS_TX_NONE.impl) + if (th.impl != DAOS_TX_NONE.impl) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } - if (iod->arr_nr != 1) + if (iod->arr_nr != 1) { NOTIMP; + } - if (sgl->sg_nr != 1) + if (sgl->sg_nr != 1) { NOTIMP; + } // target memory len - if (sgl->sg_iovs[0].iov_buf_len != sgl->sg_iovs[0].iov_len) + if (sgl->sg_iovs[0].iov_buf_len != sgl->sg_iovs[0].iov_len) { NOTIMP; + } // target memory vs. source object len - if (sgl->sg_iovs[0].iov_buf_len != iod->arr_rgs[0].rg_len) + if (sgl->sg_iovs[0].iov_buf_len != iod->arr_rgs[0].rg_len) { NOTIMP; + } // sgl->sg_iovs[0].iov_buf is a void * where to read the data into // iod->arr_rgs[0].rg_len is a size_t with the source size @@ -990,8 +1094,9 @@ int daos_array_read(daos_handle_t oh, daos_handle_t th, daos_array_iod_t* iod, d eckit::FileHandle fh(oh.impl->path); eckit::Length len = fh.size(); - if (iod->arr_rgs[0].rg_len + iod->arr_rgs[0].rg_idx > len) + if (iod->arr_rgs[0].rg_len + iod->arr_rgs[0].rg_idx > len) { return -1; + } fh.openForRead(); eckit::AutoClose closer(fh); fh.seek(iod->arr_rgs[0].rg_idx); @@ -1005,12 +1110,15 @@ int daos_cont_create_snap_opt(daos_handle_t coh, daos_epoch_t* epoch, char* name daos_event_t* ev) { ASSERT(coh.impl); - if (name != NULL) + if (name != NULL) { NOTIMP; - if (opts != (DAOS_SNAP_OPT_CR | DAOS_SNAP_OPT_OIT)) + } + if (opts != (DAOS_SNAP_OPT_CR | DAOS_SNAP_OPT_OIT)) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } std::vector files; std::vector dirs; @@ -1018,15 +1126,16 @@ int daos_cont_create_snap_opt(daos_handle_t coh, daos_epoch_t* epoch, char* name coh.impl->path.children(files, dirs); std::string oids = ""; - std::string sep = ""; + std::string sep = ""; for (std::vector* fileset : {&files, &dirs}) { for (std::vector::iterator it = fileset->begin(); it != fileset->end(); ++it) { std::string oid = it->baseName(); - if (strstr(oid.c_str(), ".snap")) + if (strstr(oid.c_str(), ".snap")) { continue; + } ASSERT(oid.length() == 33); @@ -1059,18 +1168,21 @@ int daos_cont_create_snap_opt(daos_handle_t coh, daos_epoch_t* epoch, char* name int daos_cont_destroy_snap(daos_handle_t coh, daos_epoch_range_t epr, daos_event_t* ev) { ASSERT(coh.impl); - if (epr.epr_hi != epr.epr_lo) + if (epr.epr_hi != epr.epr_lo) { NOTIMP; - if (ev != NULL) + } + if (ev != NULL) { NOTIMP; + } std::stringstream os; os << std::setw(16) << std::setfill('0') << std::hex << epr.epr_hi; eckit::PathName snap = coh.impl->path / os.str() + ".snap"; - if (!snap.exists()) + if (!snap.exists()) { return -1; + } snap.unlink(); @@ -1080,15 +1192,16 @@ int daos_cont_destroy_snap(daos_handle_t coh, daos_epoch_range_t epr, daos_event int daos_oit_open(daos_handle_t coh, daos_epoch_t epoch, daos_handle_t* oh, daos_event_t* ev) { ASSERT(coh.impl); - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } std::stringstream os; os << std::setw(16) << std::setfill('0') << std::hex << epoch; std::string ts = os.str(); - auto impl = std::make_unique(); + auto impl = std::make_unique(); impl->path = coh.impl->path / ts + ".snap"; if (!impl->path.exists()) { @@ -1104,8 +1217,9 @@ int daos_oit_close(daos_handle_t oh, daos_event_t* ev) { ASSERT(oh.impl); delete oh.impl; - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } return 0; } @@ -1117,29 +1231,37 @@ int daos_oit_list(daos_handle_t oh, daos_obj_id_t* oids, uint32_t* oids_nr, daos static unsigned long long n = (((unsigned long long)::getpid()) << 32); ASSERT(oh.impl); - if (ev != NULL) + if (ev != NULL) { NOTIMP; + } - if (oids_nr == NULL) + if (oids_nr == NULL) { return -1; - if (oids == NULL) + } + if (oids == NULL) { return -1; - if (anchor == NULL) + } + if (anchor == NULL) { return -1; + } - if (!oh.impl->path.exists()) + if (!oh.impl->path.exists()) { return -1; + } - if (anchor->da_type == DAOS_ANCHOR_TYPE_EOF) + if (anchor->da_type == DAOS_ANCHOR_TYPE_EOF) { return -1; - if (anchor->da_type == DAOS_ANCHOR_TYPE_HKEY) + } + if (anchor->da_type == DAOS_ANCHOR_TYPE_HKEY) { NOTIMP; + } if (anchor->da_type == DAOS_ANCHOR_TYPE_ZERO) { /// client process must consume all key names before starting a new request - if (ongoing_req.size() != 0) + if (ongoing_req.size() != 0) { NOTIMP; + } eckit::Length size(oh.impl->path.size()); std::vector v(size); @@ -1157,7 +1279,7 @@ int daos_oit_list(daos_handle_t oh, daos_obj_id_t* oids, uint32_t* oids_nr, daos anchor->da_type = DAOS_ANCHOR_TYPE_KEY; - std::string hostname = eckit::Main::hostname(); + std::string hostname = eckit::Main::hostname(); static std::string format = "%Y%m%d.%H%M%S"; std::ostringstream os; os << eckit::TimeStamp(format) << '.' << hostname << '.' << n++; @@ -1176,17 +1298,19 @@ int daos_oit_list(daos_handle_t oh, daos_obj_id_t* oids, uint32_t* oids_nr, daos } else { - if (anchor->da_type != DAOS_ANCHOR_TYPE_KEY) + if (anchor->da_type != DAOS_ANCHOR_TYPE_KEY) { throw eckit::SeriousBug("Unexpected anchor type"); + } /// different processes cannot collaborate on consuming a same kv_list /// request (i.e. cannot share a hash) - if (std::string((char*)&(anchor->da_buf[0]), anchor->da_shard) != req_hash) + if (std::string((char*)&(anchor->da_buf[0]), anchor->da_shard) != req_hash) { NOTIMP; + } } uint32_t remain_oids = *oids_nr; - *oids_nr = 0; + *oids_nr = 0; while (remain_oids > 0 && ongoing_req.size() > 0) { std::string next_oid = ongoing_req.back(); @@ -1200,8 +1324,9 @@ int daos_oit_list(daos_handle_t oh, daos_obj_id_t* oids, uint32_t* oids_nr, daos *oids_nr += 1; } - if (ongoing_req.size() == 0) + if (ongoing_req.size() == 0) { anchor->da_type = DAOS_ANCHOR_TYPE_EOF; + } return 0; } diff --git a/src/dummy_daos/daos.h b/src/dummy_daos/daos.h index c63f1d53b..13943a27d 100644 --- a/src/dummy_daos/daos.h +++ b/src/dummy_daos/daos.h @@ -72,8 +72,8 @@ //---------------------------------------------------------------------------------------------------------------------- enum daos_otype_t { - DAOS_OT_KV_HASHED = 8, - DAOS_OT_ARRAY = 11, + DAOS_OT_KV_HASHED = 8, + DAOS_OT_ARRAY = 11, DAOS_OT_ARRAY_BYTE = 13, }; @@ -83,7 +83,7 @@ enum daos_pool_props { }; enum daos_snapshot_opts { - DAOS_SNAP_OPT_CR = (1 << 0), + DAOS_SNAP_OPT_CR = (1 << 0), DAOS_SNAP_OPT_OIT = (1 << 1) }; @@ -194,8 +194,8 @@ typedef struct { typedef enum { DAOS_ANCHOR_TYPE_ZERO = 0, DAOS_ANCHOR_TYPE_HKEY = 1, - DAOS_ANCHOR_TYPE_KEY = 2, - DAOS_ANCHOR_TYPE_EOF = 3, + DAOS_ANCHOR_TYPE_KEY = 2, + DAOS_ANCHOR_TYPE_EOF = 3, } daos_anchor_type_t; /* cont list oids */ diff --git a/src/dummy_daos/daos/tests_lib.cc b/src/dummy_daos/daos/tests_lib.cc index dfb889d29..121d753e0 100644 --- a/src/dummy_daos/daos/tests_lib.cc +++ b/src/dummy_daos/daos/tests_lib.cc @@ -61,8 +61,9 @@ daos_prop_t* daos_prop_alloc(uint32_t entries_nr) { } D_ALLOC_PTR(prop); - if (prop == NULL) + if (prop == NULL) { return NULL; + } if (entries_nr > 0) { D_ALLOC_ARRAY(prop->dpp_entries, entries_nr); @@ -78,15 +79,17 @@ daos_prop_t* daos_prop_alloc(uint32_t entries_nr) { void daos_prop_fini(daos_prop_t* prop) { int i; - if (!prop->dpp_entries) + if (!prop->dpp_entries) { goto out; + } for (i = 0; i < prop->dpp_nr; i++) { struct daos_prop_entry* entry; entry = &prop->dpp_entries[i]; - if (entry->dpe_type != DAOS_PROP_PO_LABEL) + if (entry->dpe_type != DAOS_PROP_PO_LABEL) { NOTIMP; + } D_FREE(entry->dpe_str); } @@ -96,8 +99,9 @@ void daos_prop_fini(daos_prop_t* prop) { } void daos_prop_free(daos_prop_t* prop) { - if (prop == NULL) + if (prop == NULL) { return; + } daos_prop_fini(prop); D_FREE(prop); @@ -117,22 +121,26 @@ int dmg_pool_create(const char* dmg_config_file, uid_t uid, gid_t gid, const cha if (prop != NULL) { - if (prop->dpp_nr != 1) + if (prop->dpp_nr != 1) { NOTIMP; - if (prop->dpp_entries[0].dpe_type != DAOS_PROP_PO_LABEL) + } + if (prop->dpp_entries[0].dpe_type != DAOS_PROP_PO_LABEL) { NOTIMP; + } struct daos_prop_entry* entry = &prop->dpp_entries[0]; - if (entry == NULL) + if (entry == NULL) { NOTIMP; + } pool_name = std::string(entry->dpe_str); label_symlink_path = dummy_daos_root() / pool_name; - if (label_symlink_path.exists()) + if (label_symlink_path.exists()) { return -1; + } } /// @note: copied from LocalPathName::unique. Ditched StaticMutex as dummy DAOS is not thread safe @@ -164,13 +172,15 @@ int dmg_pool_create(const char* dmg_config_file, uid_t uid, gid_t gid, const cha eckit::PathName pool_path = dummy_daos_root() / pool_uuid_cstr; - if (pool_path.exists()) + if (pool_path.exists()) { throw eckit::SeriousBug("UUID clash in pool create"); + } pool_path.mkdir(); - if (prop == NULL) + if (prop == NULL) { return 0; + } if (::symlink(pool_path.path().c_str(), label_symlink_path.path().c_str()) < 0) { @@ -196,8 +206,9 @@ int dmg_pool_destroy(const char* dmg_config_file, const uuid_t uuid, const char* eckit::PathName pool_path = dummy_daos_root() / uuid_str; - if (!pool_path.exists()) + if (!pool_path.exists()) { return -1; + } std::vector files; std::vector dirs; @@ -209,13 +220,15 @@ int dmg_pool_destroy(const char* dmg_config_file, const uuid_t uuid, const char* for (auto& f : files) { try { - if (f.isLink() && f.realName().baseName() == pool_path.baseName()) + if (f.isLink() && f.realName().baseName() == pool_path.baseName()) { f.unlink(); + } } catch (eckit::FailedSystemCall& e) { - if (f.exists()) + if (f.exists()) { throw; + } } } diff --git a/src/dummy_daos/dummy_daos.cc b/src/dummy_daos/dummy_daos.cc index a0592fc8f..6dd572857 100644 --- a/src/dummy_daos/dummy_daos.cc +++ b/src/dummy_daos/dummy_daos.cc @@ -31,7 +31,7 @@ typedef struct daos_handle_internal_t { const PathName& dummy_daos_root() { - static PathName tmpdir = eckit::Resource("$TMPDIR", "/tmp"); + static PathName tmpdir = eckit::Resource("$TMPDIR", "/tmp"); static PathName daos_root = eckit::Resource("$DUMMY_DAOS_DATA_ROOT", tmpdir / "fdb5_dummy_daos"); return daos_root; } diff --git a/src/fdb5/LibFdb5.cc b/src/fdb5/LibFdb5.cc index 1eb4d663a..00dcbf9cd 100644 --- a/src/fdb5/LibFdb5.cc +++ b/src/fdb5/LibFdb5.cc @@ -106,7 +106,7 @@ static bool getUserEnvSkipSanityCheck() { } RemoteProtocolVersion::RemoteProtocolVersion() { - static unsigned user = getUserEnvRemoteProtocol(); + static unsigned user = getUserEnvRemoteProtocol(); static bool skipcheck = getUserEnvSkipSanityCheck(); if (not user) { @@ -157,8 +157,9 @@ std::string RemoteProtocolVersion::supportedStr() const { bool RemoteProtocolVersion::check(unsigned int version, bool throwOnFail) { std::vector versionsSupported = supported(); for (auto v : versionsSupported) { - if (version == v) + if (version == v) { return true; + } } if (throwOnFail) { std::ostringstream msg; diff --git a/src/fdb5/api/DistFDB.cc b/src/fdb5/api/DistFDB.cc index ffa68e277..3fd78f11d 100644 --- a/src/fdb5/api/DistFDB.cc +++ b/src/fdb5/api/DistFDB.cc @@ -55,8 +55,9 @@ DistFDB::DistFDB(const Config& config, const std::string& name) : FDBBase(config // Configure the available lanes. - if (!config.has("lanes")) + if (!config.has("lanes")) { throw eckit::UserError("No lanes configured for pool", Here()); + } for (const auto& laneCfg : config.getSubConfigs("lanes")) { lanes_.emplace_back(FDB(laneCfg), true); @@ -90,7 +91,7 @@ void DistFDB::archive(const Key& key, const void* data, size_t length) { // one works. n.b. Errors are unacceptable once the FDB is dirty. LOG_DEBUG_LIB(LibFdb5) << "Attempting dist FDB archive" << std::endl; - decltype(laneIndices)::const_iterator it = laneIndices.begin(); + decltype(laneIndices)::const_iterator it = laneIndices.begin(); decltype(laneIndices)::const_iterator end = laneIndices.end(); for (; it != end; ++it) { size_t idx = *it; @@ -159,7 +160,7 @@ auto DistFDB::queryInternal(const FDBToolRequest& request, const QueryFN& fn) -> decltype(fn(*(FDB*)(nullptr), request)) { using QueryIterator = decltype(fn(*(FDB*)(nullptr), request)); - using ValueType = typename QueryIterator::value_type; + using ValueType = typename QueryIterator::value_type; std::vector> futures; std::queue> iterQueue; diff --git a/src/fdb5/api/FDB.h b/src/fdb5/api/FDB.h index 77af5e756..0bba3e13b 100644 --- a/src/fdb5/api/FDB.h +++ b/src/fdb5/api/FDB.h @@ -71,7 +71,7 @@ class FDB { FDB(const Config& config = Config().expandConfig()); ~FDB(); - FDB(const FDB&) = delete; + FDB(const FDB&) = delete; FDB& operator=(const FDB&) = delete; FDB(FDB&&); diff --git a/src/fdb5/api/FDBFactory.cc b/src/fdb5/api/FDBFactory.cc index bbd654f5a..6c1e969e5 100644 --- a/src/fdb5/api/FDBFactory.cc +++ b/src/fdb5/api/FDBFactory.cc @@ -30,7 +30,7 @@ namespace fdb5 { FDBBase::FDBBase(const Config& config, const std::string& name) : name_(name), config_(config) { - bool writable = config.getBool("writable", true); + bool writable = config.getBool("writable", true); bool visitable = config.getBool("visitable", true); if (!config.getBool("list", visitable)) { controlIdentifiers_ |= ControlIdentifier::List; diff --git a/src/fdb5/api/LocalFDB.cc b/src/fdb5/api/LocalFDB.cc index 5d32e97fc..eeb240701 100644 --- a/src/fdb5/api/LocalFDB.cc +++ b/src/fdb5/api/LocalFDB.cc @@ -75,7 +75,7 @@ ListIterator LocalFDB::inspect(const metkit::mars::MarsRequest& request) { template APIIterator LocalFDB::queryInternal(const FDBToolRequest& request, Ts... args) { - using ValueType = typename VisitorType::ValueType; + using ValueType = typename VisitorType::ValueType; using QueryIterator = APIIterator; using AsyncIterator = APIAsyncIterator; diff --git a/src/fdb5/api/RandomFDB.cc b/src/fdb5/api/RandomFDB.cc index 3318d8754..481a7d7a0 100644 --- a/src/fdb5/api/RandomFDB.cc +++ b/src/fdb5/api/RandomFDB.cc @@ -40,13 +40,15 @@ class RandomFDBBuilder : public FDBBuilderBase { // Get a list of FDBs to choose between - if (!config.has("fdbs")) + if (!config.has("fdbs")) { throw UserError("No FDBs configured for random FDB frontend", Here()); + } auto fdbConfigs = config.getSubConfigurations("fdbs"); - if (fdbConfigs.empty()) + if (fdbConfigs.empty()) { throw UserError("No FDBs configured for random FDB frontend", Here()); + } // And pick one of them at random to build diff --git a/src/fdb5/api/RemoteFDB.cc b/src/fdb5/api/RemoteFDB.cc index b8ea5ba84..3163361cb 100644 --- a/src/fdb5/api/RemoteFDB.cc +++ b/src/fdb5/api/RemoteFDB.cc @@ -220,8 +220,8 @@ template auto RemoteFDB::forwardApiCall(const HelperClass& helper, const FDBToolRequest& request) -> APIIterator { - using ValueType = typename HelperClass::ValueType; - using IteratorType = APIIterator; + using ValueType = typename HelperClass::ValueType; + using IteratorType = APIIterator; using AsyncIterator = APIAsyncIterator; // Reconnect if necessary @@ -231,7 +231,7 @@ auto RemoteFDB::forwardApiCall(const HelperClass& helper, const FDBToolRequest& // will result in return messages uint32_t id = generateRequestID(); - auto entry = messageQueues_.emplace(id, std::make_shared(HelperClass::queueSize())); + auto entry = messageQueues_.emplace(id, std::make_shared(HelperClass::queueSize())); ASSERT(entry.second); std::shared_ptr messageQueue(entry.first->second); diff --git a/src/fdb5/api/SelectFDB.cc b/src/fdb5/api/SelectFDB.cc index a5b6ceef8..92c835848 100644 --- a/src/fdb5/api/SelectFDB.cc +++ b/src/fdb5/api/SelectFDB.cc @@ -108,7 +108,7 @@ auto SelectFDB::queryInternal(const FDBToolRequest& request, const QueryFN& fn) -> decltype(fn(*(FDBBase*)(nullptr), request)) { using QueryIterator = decltype(fn(*(FDBBase*)(nullptr), request)); - using ValueType = typename QueryIterator::value_type; + using ValueType = typename QueryIterator::value_type; std::queue> iterQueue; diff --git a/src/fdb5/api/fdb_c.cc b/src/fdb5/api/fdb_c.cc index 0a4123509..87be311f7 100644 --- a/src/fdb5/api/fdb_c.cc +++ b/src/fdb5/api/fdb_c.cc @@ -76,12 +76,12 @@ struct fdb_request_t { } static fdb_request_t* parse(std::string str) { fdb_request_t* req = new fdb_request_t(); - req->request_ = metkit::mars::MarsRequest::parse(str); + req->request_ = metkit::mars::MarsRequest::parse(str); return req; } void expand() { bool inherit = false; - bool strict = true; + bool strict = true; metkit::mars::MarsExpansion expand(inherit, strict); request_ = expand.expand(request_); } @@ -96,7 +96,7 @@ struct fdb_split_key_t { using value_type = std::array; auto operator=(const value_type& keys) -> fdb_split_key_t& { - keys_ = &keys; + keys_ = &keys; level_ = keys_->end(); return *this; } @@ -105,7 +105,7 @@ struct fdb_split_key_t { /// @todo the following "if" is an unfortunate consequence of a flaw in this iterator if (level_ == keys_->end()) { level_ = keys_->begin(); - curr_ = level_->begin(); + curr_ = level_->begin(); return *this; } if (curr_ != level_->end()) { @@ -278,7 +278,7 @@ struct fdb_purge_element_t { static std::string g_current_error_str; static fdb_failure_handler_t g_failure_handler = nullptr; -static void* g_failure_handler_context = nullptr; +static void* g_failure_handler_context = nullptr; const char* fdb_error_string(int err) { switch (err) { @@ -377,7 +377,7 @@ int fdb_initialise() { int fdb_set_failure_handler(fdb_failure_handler_t handler, void* context) { return wrapApiFunction([handler, context] { - g_failure_handler = handler; + g_failure_handler = handler; g_failure_handler_context = context; eckit::Log::info() << "FDB setting failure handler fn." << std::endl; }); @@ -484,7 +484,7 @@ int fdb_wipe_iterator_next(fdb_wipe_iterator_t* it, fdb_wipe_element_t** element ASSERT(element); WipeElement e; - int ret = it->next(e); + int ret = it->next(e); *element = new fdb_wipe_element_t(std::move(e)); return ret; }}); @@ -529,7 +529,7 @@ int fdb_purge_iterator_next(fdb_purge_iterator_t* it, fdb_purge_element_t** elem ASSERT(element); PurgeElement e; - int ret = it->next(e); + int ret = it->next(e); *element = new fdb_purge_element_t(std::move(e)); return ret; }}); @@ -672,8 +672,9 @@ int fdb_datareader_open(fdb_datareader_t* dr, long* size) { ASSERT(dr); long tmp; tmp = dr->open(); - if (size) + if (size) { *size = tmp; + } }); } int fdb_datareader_close(fdb_datareader_t* dr) { diff --git a/src/fdb5/api/fdb_c.h b/src/fdb5/api/fdb_c.h index d7e16873d..b7658d23e 100644 --- a/src/fdb5/api/fdb_c.h +++ b/src/fdb5/api/fdb_c.h @@ -60,10 +60,10 @@ int fdb_vcs_version(const char** sha1); /** Return codes */ enum FdbErrorValues { - FDB_SUCCESS = 0, + FDB_SUCCESS = 0, FDB_ERROR_GENERAL_EXCEPTION = 1, FDB_ERROR_UNKNOWN_EXCEPTION = 2, - FDB_ITERATION_COMPLETE = 3 + FDB_ITERATION_COMPLETE = 3 }; /** Returns a human-readable error message for the last error given an error code diff --git a/src/fdb5/api/helpers/APIIterator.h b/src/fdb5/api/helpers/APIIterator.h index b9aab0ef0..fb15499f5 100644 --- a/src/fdb5/api/helpers/APIIterator.h +++ b/src/fdb5/api/helpers/APIIterator.h @@ -61,8 +61,9 @@ class APIIterator { /// Get the next element. Return false if at end bool next(ValueType& elem) { - if (!impl_) + if (!impl_) { return false; + } return impl_->next(elem); } diff --git a/src/fdb5/api/helpers/Callback.h b/src/fdb5/api/helpers/Callback.h index 9186c9de9..c1f0f5256 100644 --- a/src/fdb5/api/helpers/Callback.h +++ b/src/fdb5/api/helpers/Callback.h @@ -23,13 +23,13 @@ namespace fdb5 { class FDB; class CallbackRegistry; -using ArchiveCallback = std::function>)>; -using FlushCallback = std::function; +using FlushCallback = std::function; using ConstructorCallback = std::function; -static const ArchiveCallback CALLBACK_ARCHIVE_NOOP = [](auto&&...) {}; -static const FlushCallback CALLBACK_FLUSH_NOOP = []() {}; +static const ArchiveCallback CALLBACK_ARCHIVE_NOOP = [](auto&&...) {}; +static const FlushCallback CALLBACK_FLUSH_NOOP = []() {}; static const ConstructorCallback CALLBACK_CONSTRUCTOR_NOOP = [](auto&&...) {}; // ------------------------------------------------------------------------------------------------- @@ -43,7 +43,7 @@ class CallbackRegistry { protected: - FlushCallback flushCallback_ = CALLBACK_FLUSH_NOOP; + FlushCallback flushCallback_ = CALLBACK_FLUSH_NOOP; ArchiveCallback archiveCallback_ = CALLBACK_ARCHIVE_NOOP; }; diff --git a/src/fdb5/api/helpers/ControlIterator.cc b/src/fdb5/api/helpers/ControlIterator.cc index 33fe10671..d3509b1e3 100644 --- a/src/fdb5/api/helpers/ControlIterator.cc +++ b/src/fdb5/api/helpers/ControlIterator.cc @@ -64,8 +64,9 @@ void ControlIdentifierIterator::nextValue() { return; } - if (value_ == 0) + if (value_ == 0) { value_ = 1; + } while ((remaining_ & value_) == 0) { value_ <<= 1; @@ -143,8 +144,9 @@ ControlElement::ControlElement(const Catalogue& catalogue) : key(catalogue.key() controlIdentifiers = ControlIdentifier::None; for (auto id : ControlIdentifierList) { - if (!catalogue.enabled(id)) + if (!catalogue.enabled(id)) { controlIdentifiers |= id; + } } } diff --git a/src/fdb5/api/helpers/ControlIterator.h b/src/fdb5/api/helpers/ControlIterator.h index 4dfe56df7..cceb6314c 100644 --- a/src/fdb5/api/helpers/ControlIterator.h +++ b/src/fdb5/api/helpers/ControlIterator.h @@ -45,10 +45,10 @@ eckit::Stream& operator>>(eckit::Stream& s, ControlAction& a); enum class ControlIdentifier : uint16_t { None = 0, - List = 1 << 0, - Retrieve = 1 << 1, - Archive = 1 << 2, - Wipe = 1 << 3, + List = 1 << 0, + Retrieve = 1 << 1, + Archive = 1 << 2, + Wipe = 1 << 3, UniqueRoot = 1 << 4 }; diff --git a/src/fdb5/api/helpers/FDBToolRequest.cc b/src/fdb5/api/helpers/FDBToolRequest.cc index 4f4efd3d5..6447c8168 100644 --- a/src/fdb5/api/helpers/FDBToolRequest.cc +++ b/src/fdb5/api/helpers/FDBToolRequest.cc @@ -64,7 +64,7 @@ std::vector FDBToolRequest::requestsFromString(const std::string std::make_move_iterator(ps.end()));*/ bool inherit = false; - bool strict = true; + bool strict = true; metkit::mars::MarsExpansion expand(inherit, strict); auto expandedRequests = expand.expand(parsedRequests); diff --git a/src/fdb5/api/helpers/ListElement.cc b/src/fdb5/api/helpers/ListElement.cc index c9046e8a9..c072ee95d 100644 --- a/src/fdb5/api/helpers/ListElement.cc +++ b/src/fdb5/api/helpers/ListElement.cc @@ -49,8 +49,9 @@ ListElement::ListElement(eckit::Stream& stream) { keyParts_[1] = std::move(keys.at(1)); keyParts_[2] = std::move(keys.at(2)); - if (!keyParts_[2].empty()) + if (!keyParts_[2].empty()) { loc_.reset(eckit::Reanimator::reanimate(stream)); + } stream >> timestamp_; } @@ -123,8 +124,9 @@ void ListElement::encode(eckit::Stream& stream) const { keys.push_back(keyParts_[2]); stream << keys; - if (loc_) + if (loc_) { stream << *loc_; + } stream << timestamp_; } diff --git a/src/fdb5/config/Config.cc b/src/fdb5/config/Config.cc index 1d44a97f8..29ad348df 100644 --- a/src/fdb5/config/Config.cc +++ b/src/fdb5/config/Config.cc @@ -53,8 +53,9 @@ Config::Config(const Configuration& config, const eckit::Configuration& userConf Config Config::expandConfig() const { // stops recursion on loading configuration of sub-fdb's - if (has("type")) + if (has("type")) { return *this; + } // If we have explicitly specified a config as an environment variable, use that @@ -82,8 +83,9 @@ Config Config::expandConfig() const { std::string config_path = eckit::Resource("fdb5ConfigFile;$FDB5_CONFIG_FILE", ""); if (!config_path.empty() && !has("fdb_home")) { actual_path = config_path; - if (!actual_path.exists()) + if (!actual_path.exists()) { return *this; + } found = true; } @@ -100,8 +102,9 @@ Config Config::expandConfig() const { break; } } - if (found) + if (found) { break; + } } } @@ -128,8 +131,9 @@ PathName Config::expandPath(const std::string& path) const { if (path[0] == '~') { if (path.length() > 1 && path[1] != '/') { size_t slashpos = path.find('/'); - if (slashpos == std::string::npos) + if (slashpos == std::string::npos) { slashpos = path.length(); + } std::string key = path.substr(1, slashpos - 1) + "_home"; std::transform(key.begin(), key.end(), key.begin(), ::tolower); @@ -159,7 +163,7 @@ void Config::overrideSchema(const eckit::PathName& schemaPath, Schema* schema) { schema->path_ = schemaPath; SchemaRegistry::instance().add(schemaPath, schema); - schemaPath_ = schemaPath; + schemaPath_ = schemaPath; schemaPathInitialised_ = true; } diff --git a/src/fdb5/config/Config.h b/src/fdb5/config/Config.h index bb72140b0..7bd019a75 100644 --- a/src/fdb5/config/Config.h +++ b/src/fdb5/config/Config.h @@ -34,7 +34,7 @@ class Config : public eckit::LocalConfiguration { static Config make(const eckit::PathName& path, const eckit::Configuration& userConfig = eckit::LocalConfiguration(), - const std::string& fdb_home = ""); + const std::string& fdb_home = ""); public: // methods diff --git a/src/fdb5/daos/DaosArrayHandle.cc b/src/fdb5/daos/DaosArrayHandle.cc index 5b28dfa60..5ba86ad93 100644 --- a/src/fdb5/daos/DaosArrayHandle.cc +++ b/src/fdb5/daos/DaosArrayHandle.cc @@ -28,8 +28,9 @@ DaosArrayHandle::DaosArrayHandle(const fdb5::DaosArrayName& name) : name_(name), DaosArrayHandle::~DaosArrayHandle() { - if (open_) + if (open_) { eckit::Log::error() << "DaosArrayHandle not closed before destruction." << std::endl; + } } void DaosArrayHandle::print(std::ostream& s) const { @@ -38,12 +39,13 @@ void DaosArrayHandle::print(std::ostream& s) const { void DaosArrayHandle::openForWrite(const Length& len) { - if (open_) + if (open_) { throw eckit::SeriousBug{"Handle already opened."}; + } session(); - fdb5::DaosPool& p = session_->getPool(name_.poolName()); + fdb5::DaosPool& p = session_->getPool(name_.poolName()); fdb5::DaosContainer& c = p.ensureContainer(name_.containerName()); /// @note: to open/create an array without generating a snapshot, we must: @@ -77,8 +79,9 @@ void DaosArrayHandle::openForWrite(const Length& len) { /// if the size is known in advance, see DaosArrayPartHandle. Length DaosArrayHandle::openForRead() { - if (open_) + if (open_) { throw eckit::SeriousBug{"Handle already opened."}; + } session(); @@ -111,8 +114,9 @@ long DaosArrayHandle::read(void* buf, long len) { /// @note: if the buffer is oversized, daos does not return the actual smaller size read, /// so it is calculated here and returned to the user as expected eckit::Length s = size(); - if (len > s - offset_) + if (len > s - offset_) { read = s - offset_; + } offset_ += read; @@ -121,8 +125,9 @@ long DaosArrayHandle::read(void* buf, long len) { void DaosArrayHandle::close() { - if (!open_) + if (!open_) { return; + } arr_->close(); @@ -169,8 +174,9 @@ std::string DaosArrayHandle::title() const { fdb5::DaosSession& DaosArrayHandle::session() { - if (!session_.has_value()) + if (!session_.has_value()) { session_.emplace(); + } return session_.value(); } diff --git a/src/fdb5/daos/DaosArrayPartHandle.cc b/src/fdb5/daos/DaosArrayPartHandle.cc index 5ff090da2..7b0cae60a 100644 --- a/src/fdb5/daos/DaosArrayPartHandle.cc +++ b/src/fdb5/daos/DaosArrayPartHandle.cc @@ -30,8 +30,9 @@ DaosArrayPartHandle::DaosArrayPartHandle(const fdb5::DaosArrayName& name, const DaosArrayPartHandle::~DaosArrayPartHandle() { - if (open_) + if (open_) { eckit::Log::error() << "DaosArrayPartHandle not closed before destruction." << std::endl; + } } void DaosArrayPartHandle::print(std::ostream& s) const { @@ -40,8 +41,9 @@ void DaosArrayPartHandle::print(std::ostream& s) const { Length DaosArrayPartHandle::openForRead() { - if (open_) + if (open_) { throw eckit::SeriousBug{"Handle already opened."}; + } session(); @@ -61,8 +63,9 @@ long DaosArrayPartHandle::read(void* buf, long len) { /// @note: if the buffer is oversized, daos does not return the actual smaller size read, /// so it is calculated here and returned to the user as expected eckit::Length s = size(); - if (len > s - offset_) + if (len > s - offset_) { len = s - offset_; + } long read = arr_->read(buf, len, offset_); @@ -73,8 +76,9 @@ long DaosArrayPartHandle::read(void* buf, long len) { void DaosArrayPartHandle::close() { - if (!open_) + if (!open_) { return; + } arr_->close(); @@ -127,8 +131,9 @@ std::string DaosArrayPartHandle::title() const { fdb5::DaosSession& DaosArrayPartHandle::session() { - if (!session_.has_value()) + if (!session_.has_value()) { session_.emplace(); + } return session_.value(); } diff --git a/src/fdb5/daos/DaosCatalogue.cc b/src/fdb5/daos/DaosCatalogue.cc index 9cb07576c..cc9ccaa99 100644 --- a/src/fdb5/daos/DaosCatalogue.cc +++ b/src/fdb5/daos/DaosCatalogue.cc @@ -51,7 +51,7 @@ DaosCatalogue::DaosCatalogue(const eckit::URI& uri, const ControlIdentifiers& co std::vector data; eckit::MemoryStream ms = db_kv.getMemoryStream(data, "key", "DB kv"); - dbKey_ = fdb5::Key(ms); + dbKey_ = fdb5::Key(ms); } catch (fdb5::DaosEntityNotFoundException& e) { @@ -125,8 +125,9 @@ std::vector DaosCatalogue::indexes(bool) const { /// @todo: document these well. Single source these reserved values. /// Ensure where appropriate that user-provided keys do not collide. - if (key == "schema" || key == "key") + if (key == "schema" || key == "key") { continue; + } /// @note: performed RPCs: /// - db kv get index location size (daos_kv_get without a buffer) @@ -175,8 +176,9 @@ void DaosCatalogue::remove(const fdb5::DaosNameBase& n, std::ostream& logAlways, logVerbose << "Removing " << (n.hasOID() ? "KV" : "container") << ": "; logAlways << n.URI() << std::endl; - if (doit) + if (doit) { n.destroy(); + } } //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/fdb5/daos/DaosCatalogueReader.cc b/src/fdb5/daos/DaosCatalogueReader.cc index 67711aa58..ca6dc5fa3 100644 --- a/src/fdb5/daos/DaosCatalogueReader.cc +++ b/src/fdb5/daos/DaosCatalogueReader.cc @@ -124,8 +124,9 @@ bool DaosCatalogueReader::retrieve(const Key& key, Field& field) const { eckit::Log::debug() << "Trying to retrieve key " << key << std::endl; eckit::Log::debug() << "Scanning index " << current_.location() << std::endl; - if (!current_.mayContain(key)) + if (!current_.mayContain(key)) { return false; + } return current_.get(key, fdb5::Key(), field); } diff --git a/src/fdb5/daos/DaosCatalogueWriter.cc b/src/fdb5/daos/DaosCatalogueWriter.cc index f7dc09c03..3ea67c192 100644 --- a/src/fdb5/daos/DaosCatalogueWriter.cc +++ b/src/fdb5/daos/DaosCatalogueWriter.cc @@ -77,16 +77,18 @@ DaosCatalogueWriter::DaosCatalogueWriter(const Key& key, const fdb5::Config& con } int db_key_max_len = 512; // @todo: take from config - if (hs.bytesWritten() > db_key_max_len) + if (hs.bytesWritten() > db_key_max_len) { throw eckit::Exception("Serialised db key exceeded configured maximum db key length."); + } fdb5::DaosKeyValue{s, catalogue_kv_name}.put("key", h.data(), hs.bytesWritten()); /// index newly created catalogue kv in main kv int db_loc_max_len = 512; // @todo: take from config - std::string nstr = catalogue_kv_name.URI().asString(); - if (nstr.length() > db_loc_max_len) + std::string nstr = catalogue_kv_name.URI().asString(); + if (nstr.length() > db_loc_max_len) { throw eckit::Exception("Serialised db location exceeded configured maximum db location length."); + } main_kv.put(db_cont_, nstr.data(), nstr.length()); } @@ -155,8 +157,9 @@ bool DaosCatalogueWriter::selectIndex(const Key& idxKey) { /// index index kv in catalogue kv std::string nstr{indexes_[idxKey].location().uri().asString()}; - if (nstr.length() > idx_loc_max_len) + if (nstr.length() > idx_loc_max_len) { throw eckit::Exception("Serialised index location exceeded configured maximum index location length."); + } /// @note: performed RPCs (only if the index wasn't visited yet and index kv doesn't exist yet, i.e. only on /// first write to an index key): /// - record index kv location into catalogue kv (daos_kv_put) -- always performed @@ -177,7 +180,7 @@ bool DaosCatalogueWriter::selectIndex(const Key& idxKey) { void DaosCatalogueWriter::deselectIndex() { - current_ = Index(); + current_ = Index(); currentIndexKey_ = Key(); firstIndexWrite_ = false; } @@ -227,15 +230,16 @@ void DaosCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, std::vector axesToExpand; std::vector valuesToAdd; std::string axisNames = ""; - std::string sep = ""; + std::string sep = ""; for (Key::const_iterator i = datumKey.begin(); i != datumKey.end(); ++i) { const std::string& keyword = i->first; - const std::string& value = i->second; + const std::string& value = i->second; - if (value.length() == 0) + if (value.length() == 0) { continue; + } axisNames += sep + keyword; sep = ","; @@ -271,8 +275,9 @@ void DaosCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, fdb5::DaosKeyValue kv{s, n}; int axis_names_max_len = 512; - if (axisNames.length() > axis_names_max_len) + if (axisNames.length() > axis_names_max_len) { throw eckit::Exception("Serialised axis names exceeded configured maximum axis names length."); + } /// @note: performed RPCs: /// - record axis names into index kv (daos_kv_put) @@ -285,8 +290,9 @@ void DaosCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, /// @todo: axes are supposed to be sorted before persisting. How do we do this with the DAOS approach? /// sort axes every time they are loaded in the read pathway? - if (axesToExpand.empty()) + if (axesToExpand.empty()) { return; + } /// expand axis info in DAOS while (!axesToExpand.empty()) { @@ -314,8 +320,9 @@ void DaosCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, void DaosCatalogueWriter::flush(size_t archivedFields) { - if (!current_.null()) + if (!current_.null()) { current_ = Index(); + } } void DaosCatalogueWriter::closeIndexes() { diff --git a/src/fdb5/daos/DaosCommon.cc b/src/fdb5/daos/DaosCommon.cc index 04f9ea6eb..dbef3174e 100644 --- a/src/fdb5/daos/DaosCommon.cc +++ b/src/fdb5/daos/DaosCommon.cc @@ -38,7 +38,7 @@ DaosCommon::DaosCommon(const fdb5::Config& config, const std::string& component, /// by DB::buildReader in EntryVisitMechanism, where validity of URIs is ensured beforehand fdb5::DaosName db_name{uri}; - pool_ = db_name.poolName(); + pool_ = db_name.poolName(); db_cont_ = db_name.containerName(); readConfig(config, component, false); @@ -46,37 +46,45 @@ DaosCommon::DaosCommon(const fdb5::Config& config, const std::string& component, void DaosCommon::readConfig(const fdb5::Config& config, const std::string& component, bool readPool) { - if (readPool) + if (readPool) { pool_ = "default"; + } root_cont_ = "root"; eckit::LocalConfiguration c{}; - if (config.has("daos")) + if (config.has("daos")) { c = config.getSubConfiguration("daos"); - if (readPool) - if (c.has(component)) + } + if (readPool) { + if (c.has(component)) { pool_ = c.getSubConfiguration(component).getString("pool", pool_); - if (c.has(component)) + } + } + if (c.has(component)) { root_cont_ = c.getSubConfiguration(component).getString("root_cont", root_cont_); + } std::string first_cap{component}; first_cap[0] = toupper(component[0]); std::string all_caps{component}; - for (auto& c : all_caps) + for (auto& c : all_caps) { c = toupper(c); + } - if (readPool) + if (readPool) { pool_ = eckit::Resource("fdbDaos" + first_cap + "Pool;$FDB_DAOS_" + all_caps + "_POOL", pool_); + } root_cont_ = eckit::Resource("fdbDaos" + first_cap + "RootCont;$FDB_DAOS_" + all_caps + "_ROOT_CONT", root_cont_); root_kv_.emplace(fdb5::DaosKeyValueName{pool_, root_cont_, main_kv_}); db_kv_.emplace(fdb5::DaosKeyValueName{pool_, db_cont_, catalogue_kv_}); - if (c.has("client")) + if (c.has("client")) { fdb5::DaosManager::instance().configure(c.getSubConfiguration("client")); + } } //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/fdb5/daos/DaosContainer.cc b/src/fdb5/daos/DaosContainer.cc index 731374bf5..6b6e1ed68 100644 --- a/src/fdb5/daos/DaosContainer.cc +++ b/src/fdb5/daos/DaosContainer.cc @@ -43,8 +43,9 @@ DaosContainer::~DaosContainer() { /// objects in the container. /// What happens if we do obj.open() and then cont.close()? - if (open_) + if (open_) { close(); + } } void DaosContainer::create() { @@ -54,8 +55,9 @@ void DaosContainer::create() { // and return accordingly. But the container may have been destroyed by another // process or DaosContainer instance. - if (open_) + if (open_) { return; + } ASSERT(label_.size() > 0); @@ -71,8 +73,9 @@ void DaosContainer::create() { void DaosContainer::open() { - if (open_) + if (open_) { return; + } ASSERT(label_.size() > 0); @@ -94,9 +97,10 @@ void DaosContainer::close() { int code = daos_cont_close(coh_, NULL); - if (code < 0) + if (code < 0) { eckit::Log::warning() << "DAOS error in call to daos_cont_close(), file " << __FILE__ << ", line " << __LINE__ << ", function " << __func__ << " [" << code << "] (" << code << ")" << std::endl; + } LOG_DEBUG_LIB(LibFdb5) << "DAOS_CALL <= daos_cont_close()" << std::endl; @@ -123,8 +127,9 @@ fdb5::DaosArray DaosContainer::createArray(const daos_oclass_id_t& oclass, bool daos_otype_t otype = DAOS_OT_ARRAY; - if (!with_attr) + if (!with_attr) { otype = DAOS_OT_ARRAY_BYTE; + } fdb5::DaosOID new_oid{0, allocateOIDLo(), otype, oclass}; new_oid.generateReservedBits(*this); diff --git a/src/fdb5/daos/DaosEngine.cc b/src/fdb5/daos/DaosEngine.cc index a0933fdb3..7ed28b132 100644 --- a/src/fdb5/daos/DaosEngine.cc +++ b/src/fdb5/daos/DaosEngine.cc @@ -25,14 +25,17 @@ namespace fdb5 { void DaosEngine::configureDaos(const Config& config) const { - if (daos_config_.has_value()) + if (daos_config_.has_value()) { return; + } daos_config_.emplace(eckit::LocalConfiguration()); - if (config.has("daos")) + if (config.has("daos")) { daos_config_.emplace(config.getSubConfiguration("daos")); - if (daos_config_->has("client")) + } + if (daos_config_->has("client")) { fdb5::DaosManager::instance().configure(daos_config_->getSubConfiguration("client")); + } } std::string DaosEngine::name() const { @@ -43,18 +46,20 @@ bool DaosEngine::canHandle(const eckit::URI& uri, const Config& config) const { configureDaos(config); - if (uri.scheme() != "daos") + if (uri.scheme() != "daos") { return false; + } fdb5::DaosName n{uri}; - if (!n.hasOID()) + if (!n.hasOID()) { return false; + } /// @todo: check containerName is not root_cont_. root_cont_ should be populated in /// configureDaos as done in DaosCommon // bool is_root_name = (n.containerName().find(root_cont_) != std::string::npos); - bool is_root_name = false; + bool is_root_name = false; bool is_store_name = (n.containerName().find("_") != std::string::npos); /// @note: performed RPCs: @@ -77,15 +82,17 @@ std::vector DaosEngine::visitableLocations(const Key& key, const Con configureDaos(config); - std::string pool = "default"; + std::string pool = "default"; std::string root_cont = "root"; - if (daos_config_->has("catalogue")) + if (daos_config_->has("catalogue")) { pool = daos_config_->getSubConfiguration("catalogue").getString("pool", pool); - if (daos_config_->has("catalogue")) + } + if (daos_config_->has("catalogue")) { root_cont = daos_config_->getSubConfiguration("catalogue").getString("root_cont", root_cont); + } - pool = eckit::Resource("fdbDaosCataloguePool;$FDB_DAOS_CATALOGUE_POOL", pool); + pool = eckit::Resource("fdbDaosCataloguePool;$FDB_DAOS_CATALOGUE_POOL", pool); root_cont = eckit::Resource("fdbDaosCatalogueRootCont;$FDB_DAOS_CATALOGUE_ROOT_CONT", root_cont); fdb5::DaosOID main_kv_oid{0, 0, DAOS_OT_KV_HASHED, OC_S1}; /// @todo: take oclass from config @@ -169,15 +176,17 @@ std::vector DaosEngine::visitableLocations(const metkit::mars::MarsRequest& configureDaos(config); - std::string pool = "default"; + std::string pool = "default"; std::string root_cont = "root"; - if (daos_config_->has("catalogue")) + if (daos_config_->has("catalogue")) { pool = daos_config_->getSubConfiguration("catalogue").getString("pool", pool); - if (daos_config_->has("catalogue")) + } + if (daos_config_->has("catalogue")) { root_cont = daos_config_->getSubConfiguration("catalogue").getString("root_cont", root_cont); + } - pool = eckit::Resource("fdbDaosCataloguePool;$FDB_DAOS_CATALOGUE_POOL", pool); + pool = eckit::Resource("fdbDaosCataloguePool;$FDB_DAOS_CATALOGUE_POOL", pool); root_cont = eckit::Resource("fdbDaosCatalogueRootCont;$FDB_DAOS_CATALOGUE_ROOT_CONT", root_cont); fdb5::DaosOID main_kv_oid{0, 0, DAOS_OT_KV_HASHED, OC_S1}; /// @todo: take oclass from config diff --git a/src/fdb5/daos/DaosFieldLocation.cc b/src/fdb5/daos/DaosFieldLocation.cc index 779d8af42..118e7c63e 100644 --- a/src/fdb5/daos/DaosFieldLocation.cc +++ b/src/fdb5/daos/DaosFieldLocation.cc @@ -67,16 +67,18 @@ class DaosURIManager : public eckit::URIManager { eckit::DataHandle* newWriteHandle(const eckit::URI& f) override { - if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) + if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) { NOTIMP; + } return fdb5::DaosArrayName(f).dataHandle(); } eckit::DataHandle* newReadHandle(const eckit::URI& f) override { - if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) + if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) { NOTIMP; + } return fdb5::DaosArrayName(f).dataHandle(); } @@ -84,19 +86,22 @@ class DaosURIManager : public eckit::URIManager { eckit::DataHandle* newReadHandle(const eckit::URI& f, const eckit::OffsetList& ol, const eckit::LengthList& ll) override { - if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) + if (fdb5::DaosName(f).OID().otype() != DAOS_OT_ARRAY) { NOTIMP; + } return fdb5::DaosArrayName(f).dataHandle(); } std::string asString(const eckit::URI& uri) const override { std::string q = uri.query(); - if (!q.empty()) + if (!q.empty()) { q = "?" + q; + } std::string f = uri.fragment(); - if (!f.empty()) + if (!f.empty()) { f = "#" + f; + } return uri.scheme() + ":" + uri.name() + q + f; } diff --git a/src/fdb5/daos/DaosIndex.cc b/src/fdb5/daos/DaosIndex.cc index af17d9fa7..05c2f00c2 100644 --- a/src/fdb5/daos/DaosIndex.cc +++ b/src/fdb5/daos/DaosIndex.cc @@ -54,8 +54,9 @@ DaosIndex::DaosIndex(const Key& key, const Catalogue& catalogue, const fdb5::Dao int idx_key_max_len = 512; - if (hs.bytesWritten() > idx_key_max_len) + if (hs.bytesWritten() > idx_key_max_len) { throw eckit::Exception("Serialised index key exceeded configured maximum index key length."); + } /// @note: performed RPCs: /// - record index key into index kv (daos_kv_put) @@ -65,8 +66,9 @@ DaosIndex::DaosIndex(const Key& key, const Catalogue& catalogue, const fdb5::Dao DaosIndex::DaosIndex(const Key& key, const Catalogue& catalogue, const fdb5::DaosKeyValueName& name, bool readAxes) : IndexBase(key, "daosKeyValue"), location_(name, 0) { - if (readAxes) + if (readAxes) { updateAxes(); + } } void DaosIndex::updateAxes() { @@ -144,7 +146,7 @@ bool DaosIndex::get(const Key& key, const Key& remapKey, Field& field) const { ms >> ts; auto loc = std::shared_ptr(eckit::Reanimator::reanimate(ms)); - field = fdb5::Field(loc, ts, fdb5::FieldDetails()); + field = fdb5::Field(loc, ts, fdb5::FieldDetails()); /// @note: performed RPCs: /// - close index kv (daos_obj_close) @@ -175,8 +177,9 @@ void DaosIndex::add(const Key& key, const Field& field) { } int field_loc_max_len = 512; /// @todo: read from config - if (hs.bytesWritten() > field_loc_max_len) + if (hs.bytesWritten() > field_loc_max_len) { throw eckit::Exception("Serialised field location exceeded configured maximum location length."); + } fdb5::DaosSession s{}; @@ -203,8 +206,9 @@ void DaosIndex::entries(EntryVisitor& visitor) const { for (const auto& key : index_kv.keys()) { - if (key == "axes" || key == "key") + if (key == "axes" || key == "key") { continue; + } /// @note: the DaosCatalogue is currently indexing a serialised DaosFieldLocation for each /// archived field key. In the list pathway, DaosLazyFieldLocations are built for all field @@ -242,8 +246,9 @@ std::vector DaosIndex::dataURIs() const { for (const auto& key : index_kv.keys()) { - if (key == "axes" || key == "key") + if (key == "axes" || key == "key") { continue; + } std::vector data; eckit::MemoryStream ms = index_kv.getMemoryStream(data, key, "index kv"); diff --git a/src/fdb5/daos/DaosKeyValueHandle.cc b/src/fdb5/daos/DaosKeyValueHandle.cc index 00df59823..2dcc50e25 100644 --- a/src/fdb5/daos/DaosKeyValueHandle.cc +++ b/src/fdb5/daos/DaosKeyValueHandle.cc @@ -29,8 +29,9 @@ DaosKeyValueHandle::DaosKeyValueHandle(const fdb5::DaosKeyValueName& name, const DaosKeyValueHandle::~DaosKeyValueHandle() { - if (open_) + if (open_) { eckit::Log::error() << "DaosKeyValueHandle not closed before destruction." << std::endl; + } } void DaosKeyValueHandle::print(std::ostream& s) const { @@ -39,13 +40,14 @@ void DaosKeyValueHandle::print(std::ostream& s) const { void DaosKeyValueHandle::openForWrite(const Length& len) { - if (open_) + if (open_) { throw eckit::SeriousBug{"Handle already opened."}; + } session(); /// @todo: alternatively call name_.create() and the like - fdb5::DaosPool& p = session_->getPool(name_.poolName()); + fdb5::DaosPool& p = session_->getPool(name_.poolName()); fdb5::DaosContainer& c = p.ensureContainer(name_.containerName()); /// @note: only way to check kv existence without generating a snapshot is @@ -63,8 +65,9 @@ void DaosKeyValueHandle::openForWrite(const Length& len) { Length DaosKeyValueHandle::openForRead() { - if (open_) + if (open_) { throw eckit::SeriousBug{"Handle already opened."}; + } session(); @@ -103,8 +106,9 @@ long DaosKeyValueHandle::read(void* buf, long len) { void DaosKeyValueHandle::close() { - if (!open_) + if (!open_) { return; + } kv_->close(); @@ -146,8 +150,9 @@ std::string DaosKeyValueHandle::title() const { fdb5::DaosSession& DaosKeyValueHandle::session() { - if (!session_.has_value()) + if (!session_.has_value()) { session_.emplace(); + } return session_.value(); } diff --git a/src/fdb5/daos/DaosLazyFieldLocation.cc b/src/fdb5/daos/DaosLazyFieldLocation.cc index 3b8563c8a..4d5bb6e71 100644 --- a/src/fdb5/daos/DaosLazyFieldLocation.cc +++ b/src/fdb5/daos/DaosLazyFieldLocation.cc @@ -47,8 +47,9 @@ std::shared_ptr DaosLazyFieldLocation::stableLocation() con std::unique_ptr& DaosLazyFieldLocation::realise() const { - if (fl_) + if (fl_) { return fl_; + } /// @note: performed RPCs: /// - index kv get (daos_kv_get) diff --git a/src/fdb5/daos/DaosName.cc b/src/fdb5/daos/DaosName.cc index 486eb9fef..97d4fc81e 100644 --- a/src/fdb5/daos/DaosName.cc +++ b/src/fdb5/daos/DaosName.cc @@ -49,10 +49,12 @@ DaosNameBase::DaosNameBase(const eckit::URI& uri) { ASSERT(bits.size() < 4); pool_ = bits[0]; - if (bits.size() > 1) + if (bits.size() > 1) { cont_.emplace(bits[1]); - if (bits.size() > 2) + } + if (bits.size() > 2) { oid_.emplace(bits[2]); + } } DaosNameBase::DaosNameBase(const fdb5::DaosObject& obj) : @@ -64,7 +66,7 @@ fdb5::DaosOID DaosNameBase::allocOID(const daos_otype_t& otype, const daos_oclas ASSERT(!oid_.has_value()); fdb5::DaosSession s{}; - fdb5::DaosPool& p = s.getPool(pool_); + fdb5::DaosPool& p = s.getPool(pool_); fdb5::DaosContainer& c = p.getContainer(cont_.value()); return fdb5::DaosOID{0, c.allocateOIDLo(), otype, oclass}; @@ -78,11 +80,12 @@ void DaosNameBase::ensureGeneratedOID() const { ASSERT(cont_.has_value()); ASSERT(oid_.has_value()); - if (oid_.value().wasGenerated()) + if (oid_.value().wasGenerated()) { return; + } fdb5::DaosSession s{}; - fdb5::DaosPool& p = s.getPool(pool_); + fdb5::DaosPool& p = s.getPool(pool_); fdb5::DaosContainer& c = p.getContainer(cont_.value()); oid_.value().generateReservedBits(c); @@ -92,10 +95,12 @@ void DaosNameBase::ensureGeneratedOID() const { std::unique_ptr DaosNameBase::buildObject(fdb5::DaosSession& s) const { /// @note: will throw DaosEntityNotFoundException if not exists - if (oid_->otype() == DAOS_OT_ARRAY || oid_->otype() == DAOS_OT_ARRAY_BYTE) + if (oid_->otype() == DAOS_OT_ARRAY || oid_->otype() == DAOS_OT_ARRAY_BYTE) { return std::make_unique(s, *this); - if (oid_->otype() == DAOS_OT_KV_HASHED) + } + if (oid_->otype() == DAOS_OT_KV_HASHED) { return std::make_unique(s, *this); + } throw eckit::Exception("Provided otype not recognised."); } @@ -108,8 +113,9 @@ void DaosNameBase::create() const { fdb5::DaosContainer& c = p.ensureContainer(cont_.value()); - if (!oid_.has_value()) + if (!oid_.has_value()) { return; + } ensureGeneratedOID(); @@ -176,8 +182,9 @@ void DaosNameBase::destroy() const { eckit::Length DaosNameBase::size() const { - if (!oid_.has_value()) + if (!oid_.has_value()) { NOTIMP; + } ensureGeneratedOID(); @@ -193,8 +200,9 @@ bool DaosNameBase::exists() const { fdb5::DaosPool& p = s.getPool(pool_); - if (cont_.has_value()) + if (cont_.has_value()) { fdb5::DaosContainer& c = p.getContainer(cont_.value()); + } if (oid_.has_value()) { ensureGeneratedOID(); @@ -209,17 +217,21 @@ bool DaosNameBase::exists() const { std::string DaosNameBase::asString() const { - if (as_string_.has_value()) + if (as_string_.has_value()) { return as_string_.value(); + } - if (oid_.has_value()) + if (oid_.has_value()) { ensureGeneratedOID(); + } eckit::StringList v{pool_}; - if (cont_.has_value()) + if (cont_.has_value()) { v.push_back(cont_.value()); - if (oid_.has_value()) + } + if (oid_.has_value()) { v.push_back(oid_.value().asString()); + } std::ostringstream oss; const char* sep = ""; @@ -370,7 +382,7 @@ std::vector DaosName::listOIDs() const { ASSERT(hasContainerName() && !hasOID()); fdb5::DaosSession s{}; - fdb5::DaosPool& p = s.getPool(pool_); + fdb5::DaosPool& p = s.getPool(pool_); fdb5::DaosContainer& c = p.getContainer(cont_.value()); return c.listOIDs(); diff --git a/src/fdb5/daos/DaosOID.cc b/src/fdb5/daos/DaosOID.cc index f44e78aca..e327fb8e8 100644 --- a/src/fdb5/daos/DaosOID.cc +++ b/src/fdb5/daos/DaosOID.cc @@ -26,7 +26,7 @@ namespace fdb5 { void DaosOID::parseReservedBits() { - otype_ = static_cast((oid_.hi & OID_FMT_TYPE_MASK) >> OID_FMT_TYPE_SHIFT); + otype_ = static_cast((oid_.hi & OID_FMT_TYPE_MASK) >> OID_FMT_TYPE_SHIFT); oclass_ = OBJ_CLASS_DEF(OR_RP_1, (oid_.hi & OID_FMT_CLASS_MASK) >> OID_FMT_CLASS_SHIFT); } @@ -68,8 +68,9 @@ bool DaosOID::operator==(const DaosOID& rhs) const { void DaosOID::generateReservedBits(fdb5::DaosContainer& cont) { - if (wasGenerated_) + if (wasGenerated_) { return; + } DAOS_CALL(daos_obj_generate_oid(cont.getOpenHandle(), &oid_, otype(), oclass(), 0, 0)); @@ -80,8 +81,9 @@ void DaosOID::generateReservedBits(fdb5::DaosContainer& cont) { std::string DaosOID::asString() const { - if (as_string_.has_value()) + if (as_string_.has_value()) { return as_string_.value(); + } ASSERT(wasGenerated_); diff --git a/src/fdb5/daos/DaosObject.cc b/src/fdb5/daos/DaosObject.cc index 455e2e31b..8411590b3 100644 --- a/src/fdb5/daos/DaosObject.cc +++ b/src/fdb5/daos/DaosObject.cc @@ -93,8 +93,9 @@ DaosArray::DaosArray(fdb5::DaosSession& session, const eckit::URI& uri) : DaosAr DaosArray::~DaosArray() { - if (open_) + if (open_) { close(); + } } /// @note: non-existing arrays (DAOS_OT_ARRAY) and byte-arrays @@ -116,11 +117,13 @@ bool DaosArray::exists() { void DaosArray::create() { - if (open_) + if (open_) { throw eckit::SeriousBug("Attempted create() on an open DaosArray"); + } - if (oid_.otype() == DAOS_OT_ARRAY_BYTE) + if (oid_.otype() == DAOS_OT_ARRAY_BYTE) { return open(); + } const daos_handle_t& coh = cont_.getOpenHandle(); @@ -141,8 +144,9 @@ void DaosArray::destroy() { void DaosArray::open() { - if (open_) + if (open_) { return; + } const daos_handle_t& coh = cont_.getOpenHandle(); @@ -181,9 +185,10 @@ void DaosArray::close() { int code = daos_array_close(oh_, NULL); - if (code < 0) + if (code < 0) { eckit::Log::warning() << "DAOS error in call to daos_array_close(), file " << __FILE__ << ", line " << __LINE__ << ", function " << __func__ << " [" << code << "] (" << code << ")" << std::endl; + } LOG_DEBUG_LIB(LibFdb5) << "DAOS_CALL <= daos_array_close()" << std::endl; @@ -205,9 +210,9 @@ uint64_t DaosArray::write(const void* buf, const uint64_t& len, const eckit::Off d_sg_list_t sgl; d_iov_t iov; - iod.arr_nr = 1; - rg.rg_len = (daos_size_t)len; - rg.rg_idx = (daos_off_t)off; + iod.arr_nr = 1; + rg.rg_len = (daos_size_t)len; + rg.rg_idx = (daos_off_t)off; iod.arr_rgs = &rg; sgl.sg_nr = 1; @@ -246,9 +251,9 @@ uint64_t DaosArray::read(void* buf, uint64_t len, const eckit::Offset& off) { d_sg_list_t sgl; d_iov_t iov; - iod.arr_nr = 1; - rg.rg_len = len; - rg.rg_idx = (daos_off_t)off; + iod.arr_nr = 1; + rg.rg_len = len; + rg.rg_idx = (daos_off_t)off; iod.arr_rgs = &rg; sgl.sg_nr = 1; @@ -293,8 +298,9 @@ DaosKeyValue::DaosKeyValue(fdb5::DaosSession& session, const eckit::URI& uri) : DaosKeyValue::~DaosKeyValue() { - if (open_) + if (open_) { close(); + } } bool DaosKeyValue::exists() { @@ -306,8 +312,9 @@ bool DaosKeyValue::exists() { void DaosKeyValue::create() { - if (open_) + if (open_) { throw eckit::SeriousBug("Attempted create() on an open DaosKeyValue"); + } const daos_handle_t& coh = cont_.getOpenHandle(); @@ -327,8 +334,9 @@ void DaosKeyValue::destroy() { void DaosKeyValue::open() { - if (open_) + if (open_) { return; + } create(); } @@ -344,9 +352,10 @@ void DaosKeyValue::close() { int code = daos_obj_close(oh_, NULL); - if (code < 0) + if (code < 0) { eckit::Log::warning() << "DAOS error in call to daos_obj_close(), file " << __FILE__ << ", line " << __LINE__ << ", function " << __func__ << " [" << code << "] (" << code << ")" << std::endl; + } LOG_DEBUG_LIB(LibFdb5) << "DAOS_CALL <= daos_obj_close()" << std::endl; @@ -388,8 +397,9 @@ uint64_t DaosKeyValue::get(const std::string& key, void* buf, const uint64_t& le DAOS_CALL(daos_kv_get(oh_, DAOS_TX_NONE, 0, key.c_str(), &res, buf, NULL)); - if (res == 0) + if (res == 0) { throw fdb5::DaosEntityNotFoundException("Key '" + key + "' not found in KeyValue with OID " + oid_.asString()); + } return res; } @@ -412,9 +422,9 @@ std::vector DaosKeyValue::keys() { const size_t bufsize = 1_KiB; eckit::Buffer list_buf{bufsize}; d_iov_set(&sg_iov, (char*)list_buf, bufsize); - sgl.sg_nr = 1; - sgl.sg_nr_out = 0; - sgl.sg_iovs = &sg_iov; + sgl.sg_nr = 1; + sgl.sg_nr_out = 0; + sgl.sg_iovs = &sg_iov; daos_anchor_t listing_status = DAOS_ANCHOR_INIT; std::vector listed_keys; @@ -438,8 +448,9 @@ eckit::MemoryStream DaosKeyValue::getMemoryStream(std::vector& v, const st const std::string& kvTitle) { uint64_t sz = size(key); - if (sz == 0) + if (sz == 0) { throw fdb5::DaosEntityNotFoundException(std::string("Key '") + key + "' not found in " + kvTitle); + } v.resize(sz); get(key, &v[0], sz); diff --git a/src/fdb5/daos/DaosObject.h b/src/fdb5/daos/DaosObject.h index 728444a88..9c28b5ddf 100644 --- a/src/fdb5/daos/DaosObject.h +++ b/src/fdb5/daos/DaosObject.h @@ -46,10 +46,10 @@ class DaosObject { virtual daos_otype_t type() const = 0; - virtual bool exists() = 0; - virtual void destroy() = 0; - virtual void open() = 0; - virtual void close() = 0; + virtual bool exists() = 0; + virtual void destroy() = 0; + virtual void open() = 0; + virtual void close() = 0; virtual uint64_t size() = 0; std::string name() const; diff --git a/src/fdb5/daos/DaosPool.cc b/src/fdb5/daos/DaosPool.cc index 2885952e7..c55f31f70 100644 --- a/src/fdb5/daos/DaosPool.cc +++ b/src/fdb5/daos/DaosPool.cc @@ -50,17 +50,18 @@ DaosPool::~DaosPool() { cont_cache_.clear(); - if (open_) + if (open_) { close(); + } } DaosPool& DaosPool::operator=(DaosPool&& other) noexcept { - uuid_ = std::move(other.uuid_); + uuid_ = std::move(other.uuid_); known_uuid_ = other.known_uuid_; - label_ = std::move(other.label_); - poh_ = std::move(other.poh_); - open_ = other.open_; + label_ = std::move(other.label_); + poh_ = std::move(other.poh_); + open_ = other.open_; cont_cache_ = std::move(other.cont_cache_); other.open_ = false; @@ -87,7 +88,7 @@ void DaosPool::create(const uint64_t& scmSize, const uint64_t& nvmeSize) { /// @todo: Ensure freeing. default_delete. // Throw exception if that fails. - prop = daos_prop_alloc(1); + prop = daos_prop_alloc(1); prop->dpp_entries[0].dpe_type = DAOS_PROP_PO_LABEL; D_STRNDUP(prop->dpp_entries[0].dpe_str, label_.c_str(), DAOS_PROP_LABEL_MAX_LEN); } @@ -97,8 +98,9 @@ void DaosPool::create(const uint64_t& scmSize, const uint64_t& nvmeSize) { /// @todo: query the pool to ensure it's ready - if (prop != NULL) + if (prop != NULL) { daos_prop_free(prop); + } D_FREE(svcl.rl_ranks); @@ -108,8 +110,9 @@ void DaosPool::create(const uint64_t& scmSize, const uint64_t& nvmeSize) { void DaosPool::open() { - if (open_) + if (open_) { return; + } ASSERT(known_uuid_ || label_.size() > 0); @@ -138,10 +141,11 @@ void DaosPool::close() { int code = daos_pool_disconnect(poh_, NULL); - if (code < 0) + if (code < 0) { eckit::Log::warning() << "DAOS error in call to daos_pool_disconnect(), file " << __FILE__ << ", line " << __LINE__ << ", function " << __func__ << " [" << code << "] (" << code << ")" << std::endl; + } LOG_DEBUG_LIB(LibFdb5) << "DAOS_CALL <= daos_pool_disconnect()" << std::endl; @@ -157,8 +161,9 @@ fdb5::DaosContainer& DaosPool::getContainer(const std::string& label, bool verif std::map::iterator it = getCachedContainer(label); - if (it != cont_cache_.end()) + if (it != cont_cache_.end()) { return it->second; + } fdb5::DaosContainer c{*this, label}; @@ -191,8 +196,9 @@ fdb5::DaosContainer& DaosPool::ensureContainer(const std::string& label) { /// @todo: if the container is found in the cache, it can be assumed /// it exists and this check could be skipped - if (c.exists()) + if (c.exists()) { return c; + } c.create(); @@ -230,8 +236,9 @@ void DaosPool::destroyContainer(const std::string& label) { void DaosPool::closeContainers() { std::map::iterator it; - for (it = cont_cache_.begin(); it != cont_cache_.end(); ++it) + for (it = cont_cache_.begin(); it != cont_cache_.end(); ++it) { it->second.close(); + } } std::vector DaosPool::listContainers() { @@ -241,14 +248,16 @@ std::vector DaosPool::listContainers() { daos_size_t ncont{0}; DAOS_CALL(daos_pool_list_cont(getOpenHandle(), &ncont, NULL, NULL)); - if (ncont == 0) + if (ncont == 0) { return res; + } std::vector info(ncont); DAOS_CALL(daos_pool_list_cont(getOpenHandle(), &ncont, info.data(), NULL)); - for (const auto& c : info) + for (const auto& c : info) { res.push_back(c.pci_label); + } return res; } @@ -280,8 +289,9 @@ std::string DaosPool::name() const { /// Either create it or provide a label upon construction. ASSERT(label_.size() > 0 || known_uuid_); - if (label_.size() > 0) + if (label_.size() > 0) { return label_; + } char name_cstr[37]; uuid_unparse(uuid_.internal, name_cstr); diff --git a/src/fdb5/daos/DaosSession.cc b/src/fdb5/daos/DaosSession.cc index c3e539756..8525e01ca 100644 --- a/src/fdb5/daos/DaosSession.cc +++ b/src/fdb5/daos/DaosSession.cc @@ -45,9 +45,10 @@ DaosManager::~DaosManager() { int code = daos_fini(); - if (code < 0) + if (code < 0) { eckit::Log::warning() << "DAOS error in call to daos_fini(), file " << __FILE__ << ", line " << __LINE__ << ", function " << __func__ << " [" << code << "] (" << code << ")" << std::endl; + } LOG_DEBUG_LIB(LibFdb5) << "DAOS_CALL <= daos_fini()" << std::endl; } @@ -64,7 +65,7 @@ void DaosManager::configure(const eckit::LocalConfiguration& config) { std::lock_guard lock(mutex_); containerOidsPerAlloc_ = config.getInt("container_oids_per_alloc", containerOidsPerAlloc_); - objectCreateCellSize_ = config.getInt64("object_create_cell_size", objectCreateCellSize_); + objectCreateCellSize_ = config.getInt64("object_create_cell_size", objectCreateCellSize_); objectCreateChunkSize_ = config.getInt64("object_create_chunk_size", objectCreateChunkSize_); #ifdef fdb5_HAVE_DAOS_ADMIN @@ -85,8 +86,9 @@ std::deque::iterator DaosSession::getCachedPool(const fdb5::UUID std::deque::iterator it; for (it = pool_cache_.begin(); it != pool_cache_.end(); ++it) { - if (uuid_compare(uuid.internal, it->uuid().internal) == 0) + if (uuid_compare(uuid.internal, it->uuid().internal) == 0) { break; + } } return it; @@ -97,8 +99,9 @@ std::deque::iterator DaosSession::getCachedPool(const std::strin std::deque::iterator it; for (it = pool_cache_.begin(); it != pool_cache_.end(); ++it) { - if (it->label() == label) + if (it->label() == label) { break; + } } return it; @@ -132,8 +135,9 @@ fdb5::DaosPool& DaosSession::getPool(const fdb5::UUID& uuid) { std::deque::iterator it = getCachedPool(uuid); - if (it != pool_cache_.end()) + if (it != pool_cache_.end()) { return *it; + } fdb5::DaosPool p(uuid); @@ -153,8 +157,9 @@ fdb5::DaosPool& DaosSession::getPool(const std::string& label) { std::deque::iterator it = getCachedPool(label); - if (it != pool_cache_.end()) + if (it != pool_cache_.end()) { return *it; + } fdb5::DaosPool p(label); @@ -183,16 +188,18 @@ DaosPool& DaosSession::getPool(const fdb5::UUID& uuid, const std::string& label) std::deque::iterator it = getCachedPool(uuid); if (it != pool_cache_.end()) { - if (it->label() == label) + if (it->label() == label) { return *it; + } pool_cache_.push_front(fdb5::DaosPool(uuid, label)); return pool_cache_.at(0); } it = getCachedPool(label); - if (it != pool_cache_.end()) + if (it != pool_cache_.end()) { return *it; + } fdb5::DaosPool p(uuid, label); @@ -213,7 +220,7 @@ DaosPool& DaosSession::getPool(const fdb5::UUID& uuid, const std::string& label) void DaosSession::destroyPool(const fdb5::UUID& uuid, const int& force) { - bool found = false; + bool found = false; std::string label = std::string(); std::deque::iterator it = pool_cache_.begin(); diff --git a/src/fdb5/daos/DaosSession.h b/src/fdb5/daos/DaosSession.h index e374b2c71..5c70b1428 100644 --- a/src/fdb5/daos/DaosSession.h +++ b/src/fdb5/daos/DaosSession.h @@ -106,10 +106,12 @@ static inline int daos_call(int code, const char* msg, const char* file, int lin if (code < 0) { eckit::Log::error() << "DAOS_FAIL !! " << msg << std::endl; - if (code == -DER_NONEXIST) + if (code == -DER_NONEXIST) { throw fdb5::DaosEntityNotFoundException(msg); - if (code == -DER_EXIST) + } + if (code == -DER_EXIST) { throw fdb5::DaosEntityAlreadyExistsException(msg); + } DaosManager::error(code, msg, file, line, func); } diff --git a/src/fdb5/daos/DaosStore.cc b/src/fdb5/daos/DaosStore.cc index a8b6f90e9..0833a9590 100644 --- a/src/fdb5/daos/DaosStore.cc +++ b/src/fdb5/daos/DaosStore.cc @@ -58,16 +58,19 @@ std::vector DaosStore::collocatedDataURIs() const { fdb5::DaosName db_cont{pool_, db_str_}; - if (!db_cont.exists()) + if (!db_cont.exists()) { return collocated_data_uris; + } for (const auto& oid : db_cont.listOIDs()) { - if (oid.otype() != DAOS_OT_KV_HASHED && oid.otype() != DAOS_OT_ARRAY_BYTE) + if (oid.otype() != DAOS_OT_KV_HASHED && oid.otype() != DAOS_OT_ARRAY_BYTE) { throw eckit::SeriousBug("Found non-KV non-ByteArray objects in DB container " + db_cont.URI().asString()); + } - if (oid.otype() == DAOS_OT_KV_HASHED) + if (oid.otype() == DAOS_OT_KV_HASHED) { continue; + } collocated_data_uris.push_back(fdb5::DaosArrayName(pool_, db_str_, oid).URI()); } @@ -79,9 +82,10 @@ std::set DaosStore::asCollocatedDataURIs(const std::vector res; - for (auto& uri : uris) + for (auto& uri : uris) { /// @note: seems redundant, but intends to check validity of input URIs res.insert(fdb5::DaosName(uri).URI()); + } return res; } @@ -157,8 +161,9 @@ void DaosStore::remove(const eckit::URI& uri, std::ostream& logAlways, std::ostr } logAlways << n.asString() << std::endl; - if (doit) + if (doit) { n.destroy(); + } } void DaosStore::print(std::ostream& out) const { diff --git a/src/fdb5/daos/DaosWipeVisitor.cc b/src/fdb5/daos/DaosWipeVisitor.cc index 803148588..a9f849003 100644 --- a/src/fdb5/daos/DaosWipeVisitor.cc +++ b/src/fdb5/daos/DaosWipeVisitor.cc @@ -137,8 +137,9 @@ void DaosWipeVisitor::ensureSafeURIs() { // Very explicitly ensure that we cannot delete anything marked as safe - for (const auto& p : safeStoreURIs_) + for (const auto& p : safeStoreURIs_) { storeURIs_.erase(p); + } } void DaosWipeVisitor::calculateResidualURIs() { @@ -154,8 +155,9 @@ void DaosWipeVisitor::calculateResidualURIs() { std::set deleteKvNames; deleteKvNames.insert(indexNames_.begin(), indexNames_.end()); deleteKvNames.insert(axisNames_.begin(), axisNames_.end()); - if (dbKvName_.poolName().size()) + if (dbKvName_.poolName().size()) { deleteKvNames.insert(dbKvName_.URI()); + } std::set allKvNames; /// @note: given a database container, list DB kv, index kvs and axis kvs @@ -285,24 +287,27 @@ void DaosWipeVisitor::report(bool wipeAll) { } out_ << "Index KVs to delete: " << std::endl; - if (indexNames_.empty()) + if (indexNames_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& n : indexNames_) { out_ << " " << n.URI() << std::endl; } out_ << std::endl; out_ << "Axis KVs to delete: " << std::endl; - if (axisNames_.empty()) + if (axisNames_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& n : axisNames_) { out_ << " " << n.URI() << std::endl; } out_ << std::endl; out_ << "Store units (store files or arrays) to delete: " << std::endl; - if (storeURIs_.empty()) + if (storeURIs_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& f : storeURIs_) { out_ << " " << f << std::endl; } @@ -354,8 +359,9 @@ void DaosWipeVisitor::wipe(bool wipeAll) { catalogue_.remove(name, logAlways, logVerbose, doit_); fdb5::DaosKeyValue db_kv{s, catalogue_.dbKeyValue()}; - if (doit_) + if (doit_) { db_kv.remove(idx); + } } else { NOTIMP; @@ -367,18 +373,20 @@ void DaosWipeVisitor::wipe(bool wipeAll) { if (wipeAll) { - if (store_.type() != "daos") + if (store_.type() != "daos") { /// @todo: if the store is holding catalogue information (e.g. index files) it /// should not be removed store_.remove(store_.uri(), logAlways, logVerbose, doit_); + } - const fdb5::DaosKeyValueName& db_kv = catalogue_.dbKeyValue(); + const fdb5::DaosKeyValueName& db_kv = catalogue_.dbKeyValue(); const fdb5::DaosKeyValueName& root_kv = catalogue_.rootKeyValue(); fdb5::DaosName db_cont{db_kv.poolName(), db_kv.containerName()}; - if (db_cont.exists() && doit_) + if (db_cont.exists() && doit_) { db_cont.destroy(); + } std::string db_key = db_kv.containerName(); fdb5::DaosSession s{}; @@ -403,44 +411,50 @@ void DaosWipeVisitor::catalogueComplete(const Catalogue& catalogue) { dbKvName_ = fdb5::DaosName(""); if (wipeAll) { const fdb5::DaosKeyValueName& n = catalogue_.dbKeyValue(); - dbKvName_ = fdb5::DaosName(n.poolName(), n.containerName(), n.OID()); + dbKvName_ = fdb5::DaosName(n.poolName(), n.containerName(), n.OID()); } ensureSafeURIs(); if (anythingToWipe()) { - if (wipeAll) + if (wipeAll) { calculateResidualURIs(); + } - if (!porcelain_) + if (!porcelain_) { report(wipeAll); + } // This is here as it needs to run whatever combination of doit/porcelain/... if (wipeAll && !residualKvNames_.empty()) { out_ << "Unexpected KVs present in DB container: " << std::endl; - for (const auto& n : residualKvNames_) + for (const auto& n : residualKvNames_) { out_ << " " << n.URI() << std::endl; + } out_ << std::endl; } if (wipeAll && !residualStoreURIs_.empty()) { out_ << "Unexpected store units (store files or arrays) present in store: " << std::endl; - for (const auto& u : residualStoreURIs_) + for (const auto& u : residualStoreURIs_) { out_ << " " << store_.type() << "://" << u << std::endl; + } out_ << std::endl; } if (wipeAll && (!residualKvNames_.empty() || !residualStoreURIs_.empty())) { if (!unsafeWipeAll_) { out_ << "Full wipe will not proceed without --unsafe-wipe-all" << std::endl; - if (doit_) + if (doit_) { throw Exception("Cannot fully wipe unclean Daos DB", Here()); + } } } - if (doit_ || porcelain_) + if (doit_ || porcelain_) { wipe(wipeAll); + } } } diff --git a/src/fdb5/daos/UUID.cc b/src/fdb5/daos/UUID.cc index fc505f901..c3adbe8fd 100644 --- a/src/fdb5/daos/UUID.cc +++ b/src/fdb5/daos/UUID.cc @@ -18,8 +18,9 @@ namespace fdb5 { UUID::UUID(const std::string& uuid) { - if (uuid_parse(uuid.c_str(), internal) != 0) + if (uuid_parse(uuid.c_str(), internal) != 0) { throw eckit::BadParameter("The provided string is not a uuid."); + } } //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/fdb5/database/ArchiveVisitor.cc b/src/fdb5/database/ArchiveVisitor.cc index f2b656c06..191890df9 100644 --- a/src/fdb5/database/ArchiveVisitor.cc +++ b/src/fdb5/database/ArchiveVisitor.cc @@ -41,7 +41,7 @@ bool ArchiveVisitor::selectDatum(const Key& datumKey, const Key& fullKey) { auto p = std::make_shared>>(); std::shared_ptr self = shared_from_this(); - auto writer = catalogue(); + auto writer = catalogue(); store()->archiveCb(idxKey, data_, size_, [self, idxKey, datumKey, p, writer](std::unique_ptr loc) mutable { diff --git a/src/fdb5/database/Archiver.cc b/src/fdb5/database/Archiver.cc index 29b69d18f..e60f870d7 100644 --- a/src/fdb5/database/Archiver.cc +++ b/src/fdb5/database/Archiver.cc @@ -74,7 +74,7 @@ void Archiver::selectDatabase(const Key& dbKey) { auto i = databases_.find(dbKey); if (i != databases_.end()) { - db_ = &(i->second); + db_ = &(i->second); i->second.time_ = ::time(0); return; } @@ -84,13 +84,13 @@ void Archiver::selectDatabase(const Key& dbKey) { { std::lock_guard cacheLock(cacheMutex_); if (databases_.size() >= fdbMaxNbDBsOpen) { - bool found = false; + bool found = false; time_t oldest = ::time(0) + 24 * 60 * 60; Key oldK; for (auto i = databases_.begin(); i != databases_.end(); ++i) { if (i->second.time_ <= oldest) { - found = true; - oldK = i->first; + found = true; + oldK = i->first; oldest = i->second.time_; } } diff --git a/src/fdb5/database/AxisRegistry.cc b/src/fdb5/database/AxisRegistry.cc index 0d7658bed..4eca6435a 100644 --- a/src/fdb5/database/AxisRegistry.cc +++ b/src/fdb5/database/AxisRegistry.cc @@ -27,8 +27,9 @@ AxisRegistry& AxisRegistry::instance() { void AxisRegistry::release(const keyword_t& keyword, std::shared_ptr& ptr) { - if (ptr.use_count() != 2) + if (ptr.use_count() != 2) { return; + } eckit::AutoLock lock(mutex_); @@ -39,8 +40,9 @@ void AxisRegistry::release(const keyword_t& keyword, std::shared_ptr& pt ASSERT(ptr.use_count() == 1); - if (it->second.empty()) + if (it->second.empty()) { axes_.erase(it); + } } void AxisRegistry::deduplicate(const keyword_t& keyword, std::shared_ptr& ptr) { @@ -49,7 +51,7 @@ void AxisRegistry::deduplicate(const keyword_t& keyword, std::shared_ptr // static std::size_t dedups = 0; - axis_store_t& axis = axes_[keyword]; + axis_store_t& axis = axes_[keyword]; axis_store_t::iterator it = axis.find(ptr); if (it == axis.end()) { axis.insert(ptr); diff --git a/src/fdb5/database/BaseKey.cc b/src/fdb5/database/BaseKey.cc index 3f2d568fb..f8360ff70 100644 --- a/src/fdb5/database/BaseKey.cc +++ b/src/fdb5/database/BaseKey.cc @@ -36,12 +36,12 @@ class ReverseName { public: // methods - ReverseName() = delete; - ReverseName(const ReverseName&) = delete; + ReverseName() = delete; + ReverseName(const ReverseName&) = delete; ReverseName& operator=(const ReverseName&) = delete; - ReverseName(ReverseName&&) = delete; - ReverseName& operator=(ReverseName&&) = delete; - ~ReverseName() = default; + ReverseName(ReverseName&&) = delete; + ReverseName& operator=(ReverseName&&) = delete; + ~ReverseName() = default; explicit ReverseName(const value_type& value) : value_{value} {} diff --git a/src/fdb5/database/BaseKey.h b/src/fdb5/database/BaseKey.h index e09cccc67..7e5081b9c 100644 --- a/src/fdb5/database/BaseKey.h +++ b/src/fdb5/database/BaseKey.h @@ -33,10 +33,10 @@ namespace fdb5 { class BaseKey { public: // types - using pair_type = std::pair; - using value_type = eckit::StringDict; - using iterator = value_type::iterator; - using const_iterator = value_type::const_iterator; + using pair_type = std::pair; + using value_type = eckit::StringDict; + using iterator = value_type::iterator; + using const_iterator = value_type::const_iterator; using const_reverse_iterator = value_type::const_reverse_iterator; public: // methods @@ -58,12 +58,12 @@ class BaseKey { // RULES - BaseKey() = default; - BaseKey(const BaseKey& other) = default; + BaseKey() = default; + BaseKey(const BaseKey& other) = default; BaseKey& operator=(const BaseKey& other) = default; - BaseKey(BaseKey&& other) = default; - BaseKey& operator=(BaseKey&& other) = default; - virtual ~BaseKey() = default; + BaseKey(BaseKey&& other) = default; + BaseKey& operator=(BaseKey&& other) = default; + virtual ~BaseKey() = default; virtual std::string type() const = 0; diff --git a/src/fdb5/database/Catalogue.cc b/src/fdb5/database/Catalogue.cc index 3af07da34..3c7cc8516 100644 --- a/src/fdb5/database/Catalogue.cc +++ b/src/fdb5/database/Catalogue.cc @@ -134,7 +134,7 @@ void CatalogueReaderFactory::list(std::ostream& out) { } std::unique_ptr CatalogueReaderFactory::build(const Key& dbKey, const Config& config) { - std::string name = Manager(config).engine(dbKey); + std::string name = Manager(config).engine(dbKey); std::string nameLowercase = eckit::StringTools::lower(name); eckit::AutoLock lock(mutex_); @@ -145,8 +145,9 @@ std::unique_ptr CatalogueReaderFactory::build(const Key& dbKey, if (j == builders_.end()) { eckit::Log::error() << "No CatalogueReaderBuilder for [" << nameLowercase << "]" << std::endl; eckit::Log::error() << "CatalogueReaderBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No CatalogueReaderBuilder called ") + nameLowercase); } @@ -154,7 +155,7 @@ std::unique_ptr CatalogueReaderFactory::build(const Key& dbKey, } std::unique_ptr CatalogueReaderFactory::build(const eckit::URI& uri, const fdb5::Config& config) { - std::string name = uri.scheme(); + std::string name = uri.scheme(); std::string nameLowercase = eckit::StringTools::lower(name); eckit::AutoLock lock(mutex_); @@ -165,8 +166,9 @@ std::unique_ptr CatalogueReaderFactory::build(const eckit::URI& if (j == builders_.end()) { eckit::Log::error() << "No CatalogueReaderBuilder for [" << nameLowercase << "]" << std::endl; eckit::Log::error() << "CatalogueReaderBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No CatalogueReaderBuilder called ") + nameLowercase); } @@ -180,8 +182,9 @@ CatalogueReaderBuilderBase::CatalogueReaderBuilderBase(const std::string& name) } CatalogueReaderBuilderBase::~CatalogueReaderBuilderBase() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } CatalogueReaderFactory::instance().remove(name_); } @@ -230,7 +233,7 @@ void CatalogueWriterFactory::list(std::ostream& out) { } std::unique_ptr CatalogueWriterFactory::build(const Key& dbKey, const Config& config) { - std::string name = Manager(config).engine(dbKey); + std::string name = Manager(config).engine(dbKey); std::string nameLowercase = eckit::StringTools::lower(name); eckit::AutoLock lock(mutex_); @@ -241,8 +244,9 @@ std::unique_ptr CatalogueWriterFactory::build(const Key& dbKey, if (j == builders_.end()) { eckit::Log::error() << "No CatalogueWriterBuilder for [" << nameLowercase << "]" << std::endl; eckit::Log::error() << "CatalogueWriterBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No CatalogueWriterBuilder called ") + nameLowercase); } @@ -250,7 +254,7 @@ std::unique_ptr CatalogueWriterFactory::build(const Key& dbKey, } std::unique_ptr CatalogueWriterFactory::build(const eckit::URI& uri, const fdb5::Config& config) { - std::string name = uri.scheme(); + std::string name = uri.scheme(); std::string nameLowercase = eckit::StringTools::lower(name); eckit::AutoLock lock(mutex_); @@ -261,8 +265,9 @@ std::unique_ptr CatalogueWriterFactory::build(const eckit::URI& if (j == builders_.end()) { eckit::Log::error() << "No CatalogueWriterBuilder for [" << nameLowercase << "]" << std::endl; eckit::Log::error() << "CatalogueWriterBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No CatalogueWriterBuilder called ") + nameLowercase); } @@ -276,8 +281,9 @@ CatalogueWriterBuilderBase::CatalogueWriterBuilderBase(const std::string& name) } CatalogueWriterBuilderBase::~CatalogueWriterBuilderBase() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } CatalogueWriterFactory::instance().remove(name_); } diff --git a/src/fdb5/database/Catalogue.h b/src/fdb5/database/Catalogue.h index e06c9085a..822f75091 100644 --- a/src/fdb5/database/Catalogue.h +++ b/src/fdb5/database/Catalogue.h @@ -50,19 +50,19 @@ typedef std::map IndexStore; class Catalogue { public: - Catalogue() = default; + Catalogue() = default; virtual ~Catalogue() = default; - virtual const Key& key() const = 0; - virtual const Key& indexKey() const = 0; + virtual const Key& key() const = 0; + virtual const Key& indexKey() const = 0; virtual const Config& config() const = 0; virtual std::unique_ptr buildStore() const = 0; - virtual const Schema& schema() const = 0; - virtual const Rule& rule() const = 0; + virtual const Schema& schema() const = 0; + virtual const Rule& rule() const = 0; virtual bool selectIndex(const Key& idxKey) = 0; - virtual void deselectIndex() = 0; + virtual void deselectIndex() = 0; virtual std::vector metadataPaths() const = 0; @@ -73,10 +73,10 @@ class Catalogue { virtual void dump(std::ostream& out, bool simple = false, const eckit::Configuration& conf = eckit::LocalConfiguration()) const = 0; - virtual StatsReportVisitor* statsReportVisitor() const = 0; - virtual PurgeVisitor* purgeVisitor(const Store& store) const = 0; + virtual StatsReportVisitor* statsReportVisitor() const = 0; + virtual PurgeVisitor* purgeVisitor(const Store& store) const = 0; virtual WipeVisitor* wipeVisitor(const Store& store, const metkit::mars::MarsRequest& request, std::ostream& out, - bool doit, bool porcelain, bool unsafeWipeAll) const = 0; + bool doit, bool porcelain, bool unsafeWipeAll) const = 0; virtual MoveVisitor* moveVisitor(const Store& store, const metkit::mars::MarsRequest& request, const eckit::URI& dest, eckit::Queue& queue) const = 0; @@ -96,13 +96,13 @@ class Catalogue { friend std::ostream& operator<<(std::ostream& s, const Catalogue& x); virtual void print(std::ostream& out) const = 0; - virtual std::string type() const = 0; - virtual bool open() = 0; + virtual std::string type() const = 0; + virtual bool open() = 0; virtual void flush(size_t archivedFields) = 0; - virtual void clean() = 0; - virtual void close() = 0; + virtual void clean() = 0; + virtual void close() = 0; - virtual bool exists() const = 0; + virtual bool exists() const = 0; virtual void checkUID() const = 0; virtual eckit::URI uri() const = 0; @@ -175,14 +175,14 @@ class CatalogueWriter : virtual public Catalogue { ~CatalogueWriter() override {} virtual bool createIndex(const Key& idxKey, size_t datumKeySize) = 0; - virtual const Index& currentIndex() = 0; + virtual const Index& currentIndex() = 0; virtual const Key currentIndexKey(); virtual void archive(const Key& idxKey, const Key& datumKey, - std::shared_ptr fieldLocation) = 0; + std::shared_ptr fieldLocation) = 0; virtual void overlayDB(const Catalogue& otherCatalogue, const std::set& variableKeys, - bool unmount) = 0; + bool unmount) = 0; virtual void index(const Key& key, const eckit::URI& uri, eckit::Offset offset, eckit::Length length) = 0; - virtual void reconsolidate() = 0; + virtual void reconsolidate() = 0; virtual size_t archivedLocations() const { NOTIMP; } }; @@ -195,7 +195,7 @@ class CatalogueReaderBuilderBase { CatalogueReaderBuilderBase(const std::string&); virtual ~CatalogueReaderBuilderBase(); - virtual std::unique_ptr make(const fdb5::Key& key, const fdb5::Config& config) = 0; + virtual std::unique_ptr make(const fdb5::Key& key, const fdb5::Config& config) = 0; virtual std::unique_ptr make(const eckit::URI& uri, const fdb5::Config& config) = 0; }; @@ -247,7 +247,7 @@ class CatalogueWriterBuilderBase { CatalogueWriterBuilderBase(const std::string&); virtual ~CatalogueWriterBuilderBase(); - virtual std::unique_ptr make(const fdb5::Key& key, const fdb5::Config& config) = 0; + virtual std::unique_ptr make(const fdb5::Key& key, const fdb5::Config& config) = 0; virtual std::unique_ptr make(const eckit::URI& uri, const fdb5::Config& config) = 0; }; diff --git a/src/fdb5/database/Engine.cc b/src/fdb5/database/Engine.cc index 52fc563c5..d9e139999 100644 --- a/src/fdb5/database/Engine.cc +++ b/src/fdb5/database/Engine.cc @@ -23,13 +23,13 @@ namespace fdb5 { //---------------------------------------------------------------------------------------------------------------------- eckit::Mutex* local_mutex = 0; -pthread_once_t once = PTHREAD_ONCE_INIT; +pthread_once_t once = PTHREAD_ONCE_INIT; static std::map* m; void init() { local_mutex = new eckit::Mutex(); - m = new std::map(); + m = new std::map(); } bool EngineRegistry::has(const std::string& name) { diff --git a/src/fdb5/database/Engine.h b/src/fdb5/database/Engine.h index 733964336..71c4ecf57 100644 --- a/src/fdb5/database/Engine.h +++ b/src/fdb5/database/Engine.h @@ -50,7 +50,7 @@ class Engine { virtual ~Engine(); /// @returns the named identifier of this engine - virtual std::string name() const = 0; + virtual std::string name() const = 0; virtual std::string dbType() const = 0; /// @returns if an Engine is capable of opening this path @@ -62,7 +62,7 @@ class Engine { /// Lists the roots that can be visited given a DB key virtual std::vector visitableLocations(const Key& key, const Config& config) const = 0; virtual std::vector visitableLocations(const metkit::mars::MarsRequest& rq, - const Config& config) const = 0; + const Config& config) const = 0; friend std::ostream& operator<<(std::ostream& s, const Engine& x); @@ -113,7 +113,7 @@ class EngineBuilder : public EngineRegistry { EngineBuilder() { Engine* e = new T(); - name_ = e->name(); + name_ = e->name(); EngineRegistry::add(e); } diff --git a/src/fdb5/database/EntryVisitMechanism.cc b/src/fdb5/database/EntryVisitMechanism.cc index a382b2f7e..2183ce04d 100644 --- a/src/fdb5/database/EntryVisitMechanism.cc +++ b/src/fdb5/database/EntryVisitMechanism.cc @@ -59,9 +59,9 @@ Store& EntryVisitor::store() const { bool EntryVisitor::visitDatabase(const Catalogue& catalogue) { currentCatalogue_ = &catalogue; - currentStore_ = nullptr; - currentIndex_ = nullptr; - rule_ = ¤tCatalogue_->rule(); + currentStore_ = nullptr; + currentIndex_ = nullptr; + rule_ = ¤tCatalogue_->rule(); return true; } @@ -73,13 +73,13 @@ void EntryVisitor::catalogueComplete(const Catalogue& catalogue) { delete currentStore_; currentStore_ = nullptr; currentIndex_ = nullptr; - rule_ = nullptr; + rule_ = nullptr; } bool EntryVisitor::visitIndex(const Index& index) { ASSERT(currentCatalogue_); currentIndex_ = &index; - rule_ = ¤tCatalogue_->schema().matchingRule(currentCatalogue_->key(), currentIndex_->key()); + rule_ = ¤tCatalogue_->schema().matchingRule(currentCatalogue_->key(), currentIndex_->key()); return true; } @@ -152,8 +152,9 @@ void EntryVisitMechanism::visit(const FDBToolRequest& request, EntryVisitor& vis } catch (eckit::Exception& e) { Log::warning() << e.what() << std::endl; - if (fail_) + if (fail_) { throw; + } } } diff --git a/src/fdb5/database/FieldLocation.cc b/src/fdb5/database/FieldLocation.cc index 621587ee9..208afcefc 100644 --- a/src/fdb5/database/FieldLocation.cc +++ b/src/fdb5/database/FieldLocation.cc @@ -71,8 +71,9 @@ FieldLocation* FieldLocationFactory::build(const std::string& name, const eckit: if (j == builders_.end()) { eckit::Log::error() << "No FieldLocationBuilder for [" << name << "]" << std::endl; eckit::Log::error() << "FieldLocationBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No FieldLocationBuilder called ") + name); } @@ -90,8 +91,9 @@ FieldLocation* FieldLocationFactory::build(const std::string& name, const eckit: if (j == builders_.end()) { eckit::Log::error() << "No FieldLocationBuilder for [" << name << "]" << std::endl; eckit::Log::error() << "FieldLocationBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No FieldLocationBuilder called ") + name); } @@ -105,8 +107,9 @@ FieldLocationBuilderBase::FieldLocationBuilderBase(const std::string& name) : na } FieldLocationBuilderBase::~FieldLocationBuilderBase() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } FieldLocationFactory::instance().remove(name_); } diff --git a/src/fdb5/database/FieldLocation.h b/src/fdb5/database/FieldLocation.h index c4d47ba53..3efeb3536 100644 --- a/src/fdb5/database/FieldLocation.h +++ b/src/fdb5/database/FieldLocation.h @@ -44,7 +44,7 @@ class FieldLocation : public eckit::OwnedLock, public eckit::Streamable { FieldLocation(const eckit::URI& uri, eckit::Offset offset, eckit::Length length, const Key& remapKey); FieldLocation(eckit::Stream&); - FieldLocation(const FieldLocation&) = delete; + FieldLocation(const FieldLocation&) = delete; FieldLocation& operator=(const FieldLocation&) = delete; virtual const eckit::URI& uri() const { return uri_; } @@ -105,7 +105,7 @@ class FieldLocationBuilderBase { virtual ~FieldLocationBuilderBase(); virtual FieldLocation* make(const eckit::URI& uri) = 0; virtual FieldLocation* make(const eckit::URI& uri, eckit::Offset offset, eckit::Length length, - const Key& remapKey) = 0; + const Key& remapKey) = 0; }; template diff --git a/src/fdb5/database/Index.cc b/src/fdb5/database/Index.cc index cc15469f3..579d72605 100644 --- a/src/fdb5/database/Index.cc +++ b/src/fdb5/database/Index.cc @@ -85,10 +85,12 @@ void IndexBase::decodeLegacy(eckit::Stream& s, } IndexBase::IndexBase(eckit::Stream& s, const int version) { - if (version >= 3) + if (version >= 3) { decodeCurrent(s, version); - else + } + else { decodeLegacy(s, version); + } } IndexBase::~IndexBase() {} @@ -216,7 +218,7 @@ Index::Index(const Index& s) : content_(s.content_), null_(s.null_) { Index& Index::operator=(const Index& s) { content_->detach(); content_ = s.content_; - null_ = s.null_; + null_ = s.null_; content_->attach(); return *this; } diff --git a/src/fdb5/database/Index.h b/src/fdb5/database/Index.h index fff1f4b8d..5af7c2e61 100644 --- a/src/fdb5/database/Index.h +++ b/src/fdb5/database/Index.h @@ -64,9 +64,9 @@ class IndexBase : public eckit::Counted { virtual bool dirty() const = 0; - virtual void open() = 0; + virtual void open() = 0; virtual void reopen() = 0; - virtual void close() = 0; + virtual void close() = 0; /// Flush and Sync data (for mediums where sync() is required) virtual void flush() = 0; @@ -98,7 +98,7 @@ class IndexBase : public eckit::Counted { virtual void print(std::ostream& out) const = 0; - virtual void flock() const = 0; + virtual void flock() const = 0; virtual void funlock() const = 0; protected: // methods diff --git a/src/fdb5/database/IndexAxis.cc b/src/fdb5/database/IndexAxis.cc index 619819224..9e089b290 100644 --- a/src/fdb5/database/IndexAxis.cc +++ b/src/fdb5/database/IndexAxis.cc @@ -29,8 +29,9 @@ namespace fdb5 { IndexAxis::IndexAxis() : readOnly_(false), dirty_(false) {} IndexAxis::~IndexAxis() { - if (!readOnly_) + if (!readOnly_) { return; + } for (AxisMap::iterator it = axis_.begin(); it != axis_.end(); ++it) { AxisRegistry::instance().release(it->first, it->second); @@ -46,23 +47,26 @@ IndexAxis::IndexAxis(IndexAxis&& rhs) noexcept : axis_(std::move(rhs.axis_)), readOnly_(rhs.readOnly_), dirty_(rhs.dirty_) {} IndexAxis& IndexAxis::operator=(IndexAxis&& rhs) noexcept { - axis_ = std::move(rhs.axis_); + axis_ = std::move(rhs.axis_); readOnly_ = rhs.readOnly_; - dirty_ = rhs.dirty_; + dirty_ = rhs.dirty_; return *this; } bool IndexAxis::operator==(const IndexAxis& rhs) const { - if (axis_.size() != rhs.axis_.size()) + if (axis_.size() != rhs.axis_.size()) { return false; + } for (const auto& kv : axis_) { auto it = rhs.axis_.find(kv.first); - if (it == rhs.axis_.end()) + if (it == rhs.axis_.end()) { return false; - if (*kv.second != *it->second) + } + if (*kv.second != *it->second) { return false; + } } return true; @@ -131,10 +135,12 @@ void IndexAxis::encodeLegacy(eckit::Stream& s, const int version) const { void IndexAxis::decode(eckit::Stream& s, const int version) { - if (version >= 3) + if (version >= 3) { decodeCurrent(s, version); - else + } + else { decodeLegacy(s, version); + } } enum IndexAxisStreamKeys { @@ -319,11 +325,13 @@ void IndexAxis::insert(const std::string& axis, const std::vector& std::shared_ptr>& axis_set = axis_[axis]; - if (!axis_set) + if (!axis_set) { axis_set.reset(new eckit::DenseSet()); + } - for (const auto& value : values) + for (const auto& value : values) { axis_set->insert(value); + } dirty_ = true; } @@ -338,8 +346,9 @@ void IndexAxis::clean() { } void IndexAxis::sort() { - for (AxisMap::iterator i = axis_.begin(); i != axis_.end(); ++i) + for (AxisMap::iterator i = axis_.begin(); i != axis_.end(); ++i) { i->second->sort(); + } } void IndexAxis::wipe() { diff --git a/src/fdb5/database/IndexFactory.cc b/src/fdb5/database/IndexFactory.cc index eeaf0c40e..4f110f425 100644 --- a/src/fdb5/database/IndexFactory.cc +++ b/src/fdb5/database/IndexFactory.cc @@ -26,12 +26,12 @@ namespace fdb5 { //---------------------------------------------------------------------------------------------------------------------- -static eckit::Mutex* local_mutex = 0; +static eckit::Mutex* local_mutex = 0; static std::map* m = 0; -static pthread_once_t once = PTHREAD_ONCE_INIT; +static pthread_once_t once = PTHREAD_ONCE_INIT; static void init() { local_mutex = new eckit::Mutex(); - m = new std::map(); + m = new std::map(); } //---------------------------------------------------------------------------------------------------------------------- @@ -45,8 +45,9 @@ BTreeIndexFactory::BTreeIndexFactory(const std::string& name) : name_(name) { } BTreeIndexFactory::~BTreeIndexFactory() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } eckit::AutoLock lock(local_mutex); m->erase(name_); } @@ -61,8 +62,9 @@ BTreeIndex* BTreeIndexFactory::build(const std::string& name, const eckit::PathN if (j == m->end()) { eckit::Log::error() << "No IndexFactory for [" << name << "]" << std::endl; eckit::Log::error() << "Values are:" << std::endl; - for (j = m->begin(); j != m->end(); ++j) + for (j = m->begin(); j != m->end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No IndexFactory called ") + name); } diff --git a/src/fdb5/database/IndexStats.h b/src/fdb5/database/IndexStats.h index 4b82ce4f1..0c9aaad09 100644 --- a/src/fdb5/database/IndexStats.h +++ b/src/fdb5/database/IndexStats.h @@ -31,16 +31,16 @@ class IndexStatsContent : public eckit::Counted, public eckit::Statistics, publi ~IndexStatsContent() override; - virtual size_t fieldsCount() const = 0; + virtual size_t fieldsCount() const = 0; virtual size_t duplicatesCount() const = 0; - virtual size_t fieldsSize() const = 0; + virtual size_t fieldsSize() const = 0; virtual size_t duplicatesSize() const = 0; - virtual size_t addFieldsCount(size_t) = 0; + virtual size_t addFieldsCount(size_t) = 0; virtual size_t addDuplicatesCount(size_t) = 0; - virtual size_t addFieldsSize(size_t i) = 0; + virtual size_t addFieldsSize(size_t i) = 0; virtual size_t addDuplicatesSize(size_t i) = 0; virtual void add(const IndexStatsContent&) = 0; diff --git a/src/fdb5/database/Inspector.cc b/src/fdb5/database/Inspector.cc index bad000aaf..da426331c 100644 --- a/src/fdb5/database/Inspector.cc +++ b/src/fdb5/database/Inspector.cc @@ -39,8 +39,9 @@ void InspectIterator::emplace(ListElement&& elem) { } bool InspectIterator::next(ListElement& elem) { - if (index_ >= queue_.size()) + if (index_ >= queue_.size()) { return false; + } elem = queue_[index_]; index_++; return true; diff --git a/src/fdb5/database/Key.cc b/src/fdb5/database/Key.cc index ca46ad048..98a26a952 100644 --- a/src/fdb5/database/Key.cc +++ b/src/fdb5/database/Key.cc @@ -175,7 +175,7 @@ Key TypedKey::canonical() const { Key key; for (const auto& keyword : names()) { const auto& value = get(keyword); - const Type& type = registry_.lookupType(keyword); + const Type& type = registry_.lookupType(keyword); value.empty() ? key.push(type.alias(), value) : key.push(type.alias(), type.toKey(value)); } return key; diff --git a/src/fdb5/database/Key.h b/src/fdb5/database/Key.h index 4ee437478..b634b8437 100644 --- a/src/fdb5/database/Key.h +++ b/src/fdb5/database/Key.h @@ -76,11 +76,11 @@ class TypedKey : public BaseKey { explicit TypedKey(const TypesRegistry& reg) : registry_{reg} {} // RULES - TypedKey(const TypedKey& other) = delete; + TypedKey(const TypedKey& other) = delete; TypedKey& operator=(const TypedKey& other) = delete; - TypedKey(TypedKey&& other) = delete; - TypedKey& operator=(TypedKey&& other) = delete; - ~TypedKey() = default; + TypedKey(TypedKey&& other) = delete; + TypedKey& operator=(TypedKey&& other) = delete; + ~TypedKey() = default; std::string type() const override { return "TypedKey"; } diff --git a/src/fdb5/database/Manager.cc b/src/fdb5/database/Manager.cc index d52df7550..5cf7580ce 100644 --- a/src/fdb5/database/Manager.cc +++ b/src/fdb5/database/Manager.cc @@ -113,7 +113,7 @@ static const EngineTable& readEngineTypes(const eckit::PathName enginesFile) { switch (s.size()) { case 2: { - const std::string& regex = s[0]; + const std::string& regex = s[0]; const std::string& engine = s[1]; table.push_back(EngineType(engine, regex)); @@ -146,8 +146,9 @@ Manager::~Manager() {} std::string Manager::engine(const Key& key) { // If we have set the engine in the config, use that - if (!explicitEngine_.empty()) + if (!explicitEngine_.empty()) { return explicitEngine_; + } std::string expanded(key.valuesToString()); @@ -217,8 +218,9 @@ std::set Manager::engines(const metkit::mars::MarsRequest& rq, bool const EngineTable& engineTypes(readEngineTypes(enginesFile_)); if (all) { - for (auto e = engineTypes.begin(); e != engineTypes.end(); ++e) + for (auto e = engineTypes.begin(); e != engineTypes.end(); ++e) { s.insert(e->engine()); + } } else { @@ -233,8 +235,9 @@ std::set Manager::engines(const metkit::mars::MarsRequest& rq, bool for (auto e = engineTypes.begin(); e != engineTypes.end(); ++e) { for (auto expanded = expandedKeys.begin(); expanded != expandedKeys.end(); ++expanded) { - if (e->match(*expanded)) + if (e->match(*expanded)) { s.insert(e->engine()); + } } } } @@ -251,8 +254,9 @@ std::set Manager::engines(const metkit::mars::MarsRequest& rq, bool std::string Manager::engine(const URI& uri) { // If we have set the engine in the config, use that - if (!explicitEngine_.empty()) + if (!explicitEngine_.empty()) { return explicitEngine_; + } // Otherwise, check which engines can handle the given path. diff --git a/src/fdb5/database/ReadVisitor.h b/src/fdb5/database/ReadVisitor.h index db0f1dd31..481e35d1a 100644 --- a/src/fdb5/database/ReadVisitor.h +++ b/src/fdb5/database/ReadVisitor.h @@ -48,7 +48,7 @@ class ReadVisitor { virtual ~ReadVisitor() {} virtual bool selectDatabase(const Key& dbKey, const Key& fullKey) = 0; - virtual bool selectIndex(const Key& idxKey) = 0; + virtual bool selectIndex(const Key& idxKey) = 0; virtual bool selectDatum(const Key& datumKey, const Key& fullKey) = 0; virtual void deselectDatabase() = 0; diff --git a/src/fdb5/database/Report.cc b/src/fdb5/database/Report.cc index bd7daa91a..a5f9afe4d 100644 --- a/src/fdb5/database/Report.cc +++ b/src/fdb5/database/Report.cc @@ -101,16 +101,19 @@ void Report::print(std::ostream& out) const { out << sep << "Database Type \'" << dbType << "\'" << std::endl; std::map::const_iterator db = dbStats_.find(dbType); - if (db != dbStats_.end()) + if (db != dbStats_.end()) { db->second.report(out); + } std::map::const_iterator idx = indexStats_.find(dbType); - if (idx != indexStats_.end()) + if (idx != indexStats_.end()) { idx->second.report(out); + } std::map::const_iterator data = dataStats_.find(dbType); - if (data != dataStats_.end()) + if (data != dataStats_.end()) { data->second.report(out); + } sep = "\n"; } diff --git a/src/fdb5/database/StatsReportVisitor.h b/src/fdb5/database/StatsReportVisitor.h index e655c45d5..f405a826f 100644 --- a/src/fdb5/database/StatsReportVisitor.h +++ b/src/fdb5/database/StatsReportVisitor.h @@ -29,7 +29,7 @@ class StatsReportVisitor : public EntryVisitor { using EntryVisitor::EntryVisitor; virtual IndexStats indexStatistics() const = 0; - virtual DbStats dbStatistics() const = 0; + virtual DbStats dbStatistics() const = 0; }; //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/fdb5/database/Store.cc b/src/fdb5/database/Store.cc index 385740a72..bb8e997f4 100644 --- a/src/fdb5/database/Store.cc +++ b/src/fdb5/database/Store.cc @@ -83,7 +83,7 @@ void StoreFactory::list(std::ostream& out) { } std::unique_ptr StoreFactory::build(const Key& key, const Config& config) { - std::string name = config.getString("store", "file"); + std::string name = config.getString("store", "file"); std::string nameLowercase = eckit::StringTools::lower(name); eckit::AutoLock lock(mutex_); @@ -94,8 +94,9 @@ std::unique_ptr StoreFactory::build(const Key& key, const Config& config) if (j == builders_.end()) { eckit::Log::error() << "No StoreBuilder for [" << nameLowercase << "]" << std::endl; eckit::Log::error() << "StoreBuilders are:" << std::endl; - for (j = builders_.begin(); j != builders_.end(); ++j) + for (j = builders_.begin(); j != builders_.end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No StoreBuilder called ") + nameLowercase); } @@ -109,8 +110,9 @@ StoreBuilderBase::StoreBuilderBase(const std::string& name) : name_(name) { } StoreBuilderBase::~StoreBuilderBase() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } StoreFactory::instance().remove(name_); } diff --git a/src/fdb5/database/Store.h b/src/fdb5/database/Store.h index ee11b2922..d3901da43 100644 --- a/src/fdb5/database/Store.h +++ b/src/fdb5/database/Store.h @@ -49,12 +49,12 @@ class Store { virtual void print(std::ostream& out) const = 0; virtual std::string type() const = 0; - virtual bool open() = 0; - virtual size_t flush() = 0; - virtual void close() = 0; + virtual bool open() = 0; + virtual size_t flush() = 0; + virtual void close() = 0; // virtual std::string owner() const = 0; - virtual bool exists() const = 0; + virtual bool exists() const = 0; virtual void checkUID() const = 0; virtual bool canMoveTo(const Key& key, const Config& config, const eckit::URI& dest) const; @@ -64,10 +64,10 @@ class Store { } virtual void remove(const Key& key) const { NOTIMP; } - virtual eckit::URI uri() const = 0; - virtual bool uriBelongs(const eckit::URI&) const = 0; - virtual bool uriExists(const eckit::URI& uri) const = 0; - virtual std::vector collocatedDataURIs() const = 0; + virtual eckit::URI uri() const = 0; + virtual bool uriBelongs(const eckit::URI&) const = 0; + virtual bool uriExists(const eckit::URI& uri) const = 0; + virtual std::vector collocatedDataURIs() const = 0; virtual std::set asCollocatedDataURIs(const std::vector&) const = 0; virtual std::vector getAuxiliaryURIs(const eckit::URI&) const { NOTIMP; } diff --git a/src/fdb5/database/UriStore.cc b/src/fdb5/database/UriStore.cc index c7d3b5891..f0867a4a8 100644 --- a/src/fdb5/database/UriStore.cc +++ b/src/fdb5/database/UriStore.cc @@ -41,15 +41,16 @@ UriStore::UriStore(const eckit::PathName& directory, eckit::Stream& s) : if ((uri.scheme() == "unix") || (uri.scheme() == "file")) { eckit::PathName path = uri.path(); - std::string q = path.asString(); + std::string q = path.asString(); - if (!q.empty() && q[0] != '/') + if (!q.empty() && q[0] != '/') { path = directory_ / path; + } uri = eckit::URI("file", path); } paths_[id] = uri; - ids_[uri] = id; + ids_[uri] = id; next_ = std::max(id + 1, next_); } @@ -77,12 +78,13 @@ UriStore::UriID UriStore::insert(const eckit::URI& path) { IdStore::iterator itr = ids_.find(path); - if (itr != ids_.end()) + if (itr != ids_.end()) { return itr->second; + } UriStore::UriID current = next_; next_++; - ids_[path] = current; + ids_[path] = current; paths_[current] = path; return current; diff --git a/src/fdb5/database/WriteVisitor.h b/src/fdb5/database/WriteVisitor.h index 4b94611e6..df4670fd4 100644 --- a/src/fdb5/database/WriteVisitor.h +++ b/src/fdb5/database/WriteVisitor.h @@ -47,8 +47,8 @@ class WriteVisitor { virtual ~WriteVisitor() = default; virtual bool selectDatabase(const Key& dbKey, const Key& fullKey) = 0; - virtual bool selectIndex(const Key& idxKey) = 0; - virtual bool createIndex(const Key& idxKey, size_t datumKeySize) = 0; + virtual bool selectIndex(const Key& idxKey) = 0; + virtual bool createIndex(const Key& idxKey, size_t datumKeySize) = 0; virtual bool selectDatum(const Key& datumKey, const Key& fullKey) = 0; // Once we have selected a database, return its schema. Used for further iteration. diff --git a/src/fdb5/io/FDBFileHandle.cc b/src/fdb5/io/FDBFileHandle.cc index e18c7eaf8..c56ee718d 100644 --- a/src/fdb5/io/FDBFileHandle.cc +++ b/src/fdb5/io/FDBFileHandle.cc @@ -76,8 +76,9 @@ void FDBFileHandle::flush() { eckit::LibResource("$FDB_DATA_SYNC_ON_FLUSH;fdbDataSyncOnFlush", true); if (file_) { - if (::fflush(file_)) + if (::fflush(file_)) { throw WriteError(std::string("FDBFileHandle::~FDBFileHandle(fflush(") + path_ + "))", Here()); + } if (fdbDataSyncOnFlush) { int ret = eckit::fdatasync(::fileno(file_)); @@ -101,11 +102,11 @@ void FDBFileHandle::close() { if (file_) { if (::fclose(file_)) { file_ = nullptr; - pos_ = 0; + pos_ = 0; throw WriteError(std::string("fclose ") + name()); } file_ = nullptr; - pos_ = 0; + pos_ = 0; } } diff --git a/src/fdb5/io/FieldHandle.cc b/src/fdb5/io/FieldHandle.cc index 51d61be64..498b2de4f 100644 --- a/src/fdb5/io/FieldHandle.cc +++ b/src/fdb5/io/FieldHandle.cc @@ -69,14 +69,14 @@ FieldHandle::FieldHandle(ListIterator& it) : for (size_t i = 0; i < cube.size(); i++) { ListElement element; if (cube.find(i, element)) { - eckit::Length len = element.location().length(); + eckit::Length len = element.location().length(); eckit::DataHandle* dh = element.location().dataHandle(); datahandles_.push_back(std::make_pair(len, dh)); totalSize_ += len; bool canSeek = dh->canSeek(); if (!canSeek) { - largest = std::max(largest, len); + largest = std::max(largest, len); seekable_ = false; } } @@ -85,14 +85,14 @@ FieldHandle::FieldHandle(ListIterator& it) : } else { while (it.next(el)) { - eckit::Length len = el.location().length(); + eckit::Length len = el.location().length(); eckit::DataHandle* dh = el.location().dataHandle(); datahandles_.push_back(std::make_pair(len, dh)); totalSize_ += len; bool canSeek = dh->canSeek(); if (!canSeek) { - largest = std::max(largest, len); + largest = std::max(largest, len); seekable_ = false; } } @@ -124,14 +124,14 @@ void FieldHandle::openCurrent() { if (currentIdx_ < datahandles_.size()) { eckit::Length currentSize = datahandles_[currentIdx_].first; - current_ = datahandles_[currentIdx_].second; + current_ = datahandles_[currentIdx_].second; current_->openForRead(); if (!current_->canSeek()) { - long len = 0; + long len = 0; long toRead = currentSize; - long read = 0; - char* buf = buffer_; + long read = 0; + char* buf = buffer_; while (toRead > 0 && (len = current_->read(buf, toRead)) > 0) { toRead -= len; buf += len; @@ -177,8 +177,8 @@ long FieldHandle::read1(char* buffer, long length) { long FieldHandle::read(void* buffer, long length) { long requested = length; - char* p = static_cast(buffer); - long n = 0; + char* p = static_cast(buffer); + long n = 0; long total = 0; while (length > 0 && (n = read1(p, length)) > 0) { @@ -261,7 +261,7 @@ eckit::Offset FieldHandle::seek(const eckit::Offset& offset) { } const long long seekto = offset; - long long accumulated = 0; + long long accumulated = 0; if (!seekable_) { // check that the offset is within the current message of later for (size_t idx = 0; idx < currentIdx_; idx++) { diff --git a/src/fdb5/io/LustreFileHandle.h b/src/fdb5/io/LustreFileHandle.h index 91dd275e0..bf61de6f4 100644 --- a/src/fdb5/io/LustreFileHandle.h +++ b/src/fdb5/io/LustreFileHandle.h @@ -49,8 +49,9 @@ class LustreFileHandle : public HANDLE { std::string pathStr = HANDLE::path_; eckit::PathName path{pathStr}; - if (path.exists()) + if (path.exists()) { return; //< Lustre API outputs ioctl error messages when called on files exist + } /* From the docs: llapi_file_create closes the file descriptor. You must re-open the file afterwards */ diff --git a/src/fdb5/io/SingleGribMungePartFileHandle.cc b/src/fdb5/io/SingleGribMungePartFileHandle.cc index 1f9078583..4a1ea6baa 100644 --- a/src/fdb5/io/SingleGribMungePartFileHandle.cc +++ b/src/fdb5/io/SingleGribMungePartFileHandle.cc @@ -31,10 +31,12 @@ ::eckit::ClassSpec SingleGribMungePartFileHandle::classSpec_ = { ::eckit::Reanimator SingleGribMungePartFileHandle::reanimator_; void SingleGribMungePartFileHandle::print(std::ostream& s) const { - if (format(s) == Log::compactFormat) + if (format(s) == Log::compactFormat) { s << "SingleGribMungePartFileHandle"; - else + } + else { s << "SingleGribMungePartFileHandle[path=" << name_ << ",offset=" << offset_ << ",length=" << length_ << ']'; + } } SingleGribMungePartFileHandle::SingleGribMungePartFileHandle(const PathName& name, const Offset& offset, @@ -61,11 +63,12 @@ SingleGribMungePartFileHandle::~SingleGribMungePartFileHandle() { Length SingleGribMungePartFileHandle::openForRead() { - pos_ = 0; + pos_ = 0; file_ = ::fopen(name_.localPath(), "r"); - if (!file_) + if (!file_) { throw CantOpenFile(name_, errno == ENOENT); + } if (buffer_) { buffer_.reset(); @@ -108,7 +111,7 @@ long SingleGribMungePartFileHandle::read(void* buffer, long length) { CODES_CHECK(codes_set_string(handle, kv.first.c_str(), kv.second.c_str(), &valueSize), 0); } - size_t messageSize = 0; + size_t messageSize = 0; const void* messageBuffer = 0; CODES_CHECK(codes_get_message(handle, &messageBuffer, &messageSize), 0); diff --git a/src/fdb5/message/MessageArchiver.cc b/src/fdb5/message/MessageArchiver.cc index 8d46e7522..088c7ac1d 100644 --- a/src/fdb5/message/MessageArchiver.cc +++ b/src/fdb5/message/MessageArchiver.cc @@ -74,8 +74,9 @@ std::vector str_to_requests(const std::string& str) { std::vector make_filter_requests(const std::string& str) { - if (str.empty()) + if (str.empty()) { return {}; + } std::set keys = Key::parse(str).keys(); //< keys to filter from that request @@ -115,8 +116,9 @@ void MessageArchiver::transform(eckit::message::Message& msg) { static bool matchAny(const metkit::mars::MarsRequest& f, const std::vector& v) { for (auto r = v.begin(); r != v.end(); ++r) { - if (f.matches(*r)) + if (f.matches(*r)) { return true; + } } return false; } @@ -134,13 +136,15 @@ bool MessageArchiver::filterOut(const Key& k) const { // filter includes - if (include_.size() && not matchAny(field, include_)) + if (include_.size() && not matchAny(field, include_)) { return out; + } // filter excludes - if (exclude_.size() && matchAny(field, exclude_)) + if (exclude_.size() && matchAny(field, exclude_)) { return out; + } // datum wasn't filtered out @@ -150,12 +154,13 @@ bool MessageArchiver::filterOut(const Key& k) const { eckit::Length MessageArchiver::archive(eckit::DataHandle& source) { std::optional timer; - if (verbose_) + if (verbose_) { timer.emplace("fdb::service::archive"); + } eckit::message::Reader reader(source); - size_t count = 0; + size_t count = 0; size_t total_size = 0; eckit::Progress progress("FDB archive", 0, source.estimate()); @@ -183,8 +188,9 @@ eckit::Length MessageArchiver::archive(eckit::DataHandle& source) { ASSERT(key.match(key_)); - if (filterOut(key)) + if (filterOut(key)) { continue; + } if (modifiers_.size()) { transform(msg); diff --git a/src/fdb5/message/MessageDecoder.cc b/src/fdb5/message/MessageDecoder.cc index 7ece6b57c..4103d4fe6 100644 --- a/src/fdb5/message/MessageDecoder.cc +++ b/src/fdb5/message/MessageDecoder.cc @@ -88,8 +88,9 @@ void MessageDecoder::messageToKey(const eckit::message::Message& msg, Key& key) metkit::mars::MarsRequest MessageDecoder::messageToRequest(const eckit::PathName& path, const char* verb) { metkit::mars::MarsRequest request(verb); - for (auto& r : messageToRequests(path, verb)) + for (auto& r : messageToRequests(path, verb)) { request.merge(r); + } return request; } diff --git a/src/fdb5/message/MessageIndexer.cc b/src/fdb5/message/MessageIndexer.cc index 8d6cf441f..55c8aecfa 100644 --- a/src/fdb5/message/MessageIndexer.cc +++ b/src/fdb5/message/MessageIndexer.cc @@ -32,7 +32,7 @@ void MessageIndexer::index(const eckit::PathName& path) { eckit::message::Reader reader(path); - size_t count = 0; + size_t count = 0; eckit::Length total_size = 0; eckit::Length totalFileSize = path.size(); diff --git a/src/fdb5/rados/RadosStore.cc b/src/fdb5/rados/RadosStore.cc index a8556c119..7009c3a1e 100644 --- a/src/fdb5/rados/RadosStore.cc +++ b/src/fdb5/rados/RadosStore.cc @@ -75,7 +75,7 @@ size_t RadosStore::flush() { flushDataHandles(); - size_t out = archivedFields_; + size_t out = archivedFields_; archivedFields_ = 0; return out; } @@ -91,23 +91,27 @@ void RadosStore::remove(const eckit::URI& uri, std::ostream& logAlways, std::ost if (path.isDir()) { logVerbose << "rmdir: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.rmdir(false); + } } else { logVerbose << "Unlinking: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.unlink(false); + } } } eckit::DataHandle* RadosStore::getCachedHandle(const eckit::PathName& path) const { HandleStore::const_iterator j = handles_.find(path); - if (j != handles_.end()) + if (j != handles_.end()) { return j->second; - else + } + else { return nullptr; + } } void RadosStore::closeDataHandles() { @@ -143,12 +147,14 @@ eckit::DataHandle* RadosStore::createAsyncHandle(const eckit::PathName& path) { eckit::DataHandle* RadosStore::createDataHandle(const eckit::PathName& path) { static bool fdbWriteToNull = eckit::Resource("fdbWriteToNull;$FDB_WRITE_TO_NULL", false); - if (fdbWriteToNull) + if (fdbWriteToNull) { return new eckit::EmptyHandle(); + } static bool fdbAsyncWrite = eckit::Resource("fdbAsyncWrite;$FDB_ASYNC_WRITE", false); - if (fdbAsyncWrite) + if (fdbAsyncWrite) { return createAsyncHandle(path); + } return createFileHandle(path); } @@ -174,8 +180,9 @@ eckit::PathName RadosStore::generateDataPath(const Key& key) const { eckit::PathName RadosStore::getDataPath(const Key& key) { PathStore::const_iterator j = dataPaths_.find(key); - if (j != dataPaths_.end()) + if (j != dataPaths_.end()) { return j->second; + } eckit::PathName dataPath = generateDataPath(key); diff --git a/src/fdb5/remote/FdbServer.cc b/src/fdb5/remote/FdbServer.cc index 5be4c670e..85b74fd5c 100644 --- a/src/fdb5/remote/FdbServer.cc +++ b/src/fdb5/remote/FdbServer.cc @@ -121,7 +121,7 @@ void FdbServerBase::doRun() { // maintains the list of available ports. startPortReaperThread(config); - int port = config.getInt("serverPort", 7654); + int port = config.getInt("serverPort", 7654); bool threaded = config.getBool("serverThreaded", false); net::TCPServer server(net::Port("fdb", port), net::SocketOptions::server().reusePort(true)); @@ -153,7 +153,7 @@ void FdbServerBase::startPortReaperThread(const Config& config) { ASSERT(config.has("dataPortCount")); int startPort = config.getInt("dataPortStart"); - size_t count = config.getLong("dataPortCount"); + size_t count = config.getLong("dataPortCount"); eckit::Log::info() << "Using custom port list. startPort=" << startPort << ", count=" << count << std::endl; diff --git a/src/fdb5/remote/FdbServer.h b/src/fdb5/remote/FdbServer.h index 0ed1a1f5e..0776cb8da 100644 --- a/src/fdb5/remote/FdbServer.h +++ b/src/fdb5/remote/FdbServer.h @@ -64,7 +64,7 @@ class FdbServerBase { int port_; std::thread reaperThread_; - FdbServerBase(const FdbServerBase&) = delete; + FdbServerBase(const FdbServerBase&) = delete; FdbServerBase& operator=(const FdbServerBase&) = delete; virtual void hookUnique() = 0; diff --git a/src/fdb5/remote/RemoteConfiguration.cc b/src/fdb5/remote/RemoteConfiguration.cc index d3565102f..424071351 100644 --- a/src/fdb5/remote/RemoteConfiguration.cc +++ b/src/fdb5/remote/RemoteConfiguration.cc @@ -98,7 +98,7 @@ bool RemoteConfiguration::singleConnection() const { } eckit::Stream& operator<<(eckit::Stream& s, const RemoteConfiguration& r) { - eckit::Value val = eckit::Value::makeOrderedMap(); + eckit::Value val = eckit::Value::makeOrderedMap(); val["RemoteFieldLocation"] = eckit::toValue(r.remoteFieldLocationVersions_); val["NumberOfConnections"] = eckit::toValue(r.numberOfConnections_); if (r.preferSingleConnection_) { @@ -161,7 +161,7 @@ RemoteConfiguration RemoteConfiguration::common(RemoteConfiguration& clientConf, LOG_DEBUG_LIB(LibFdb5) << "Protocol negotiation - NumberOfConnections " << ncSelected << std::endl; agreedConf.numberOfConnections_ = {ncSelected}; - agreedConf.singleConnection_ = (ncSelected == 1); + agreedConf.singleConnection_ = (ncSelected == 1); return agreedConf; } diff --git a/src/fdb5/remote/RemoteFieldLocation.cc b/src/fdb5/remote/RemoteFieldLocation.cc index ba956811b..c66e8f55b 100644 --- a/src/fdb5/remote/RemoteFieldLocation.cc +++ b/src/fdb5/remote/RemoteFieldLocation.cc @@ -81,7 +81,7 @@ eckit::DataHandle* RemoteFieldLocation::dataHandle() const { RemoteStore& store = RemoteStore::get(uri_); - const std::string scheme = uri_.query("internalScheme"); + const std::string scheme = uri_.query("internalScheme"); const std::string hostport = uri_.query("internalHost"); eckit::URI remote; if (hostport.empty()) { @@ -135,11 +135,13 @@ class FdbURIManager : public eckit::URIManager { std::string asString(const eckit::URI& uri) const override { std::string q = uri.query(); - if (!q.empty()) + if (!q.empty()) { q = "?" + q; + } std::string f = uri.fragment(); - if (!f.empty()) + if (!f.empty()) { f = "#" + f; + } return uri.name() + q + f; } diff --git a/src/fdb5/remote/client/Client.h b/src/fdb5/remote/client/Client.h index c272ae036..c51fde073 100644 --- a/src/fdb5/remote/client/Client.h +++ b/src/fdb5/remote/client/Client.h @@ -39,12 +39,12 @@ class RemoteFDBException : public eckit::RemoteException { class Client { public: // types - using PayloadList = Connection::PayloadList; + using PayloadList = Connection::PayloadList; using EndpointList = std::vector>; static constexpr size_t defaultBufferSizeArchive = 8_KiB; - static constexpr size_t defaultBufferSizeFlush = 1_KiB; - static constexpr size_t defaultBufferSizeKey = 4_KiB; + static constexpr size_t defaultBufferSizeFlush = 1_KiB; + static constexpr size_t defaultBufferSizeKey = 4_KiB; public: // methods @@ -82,7 +82,7 @@ class Client { virtual const eckit::Configuration& clientConfig() const = 0; // handlers for incoming messages - to be defined in the client class - virtual bool handle(Message message, uint32_t requestID) = 0; + virtual bool handle(Message message, uint32_t requestID) = 0; virtual bool handle(Message message, uint32_t requestID, eckit::Buffer&& payload) = 0; virtual void closeConnection() {} diff --git a/src/fdb5/remote/client/ClientConnection.cc b/src/fdb5/remote/client/ClientConnection.cc index 683749815..31dc112ee 100644 --- a/src/fdb5/remote/client/ClientConnection.cc +++ b/src/fdb5/remote/client/ClientConnection.cc @@ -79,8 +79,9 @@ bool ClientConnection::remove(uint32_t clientID) { auto it = clients_.find(clientID); if (it != clients_.end()) { - if (valid()) + if (valid()) { Connection::write(Message::Stop, true, clientID, 0); + } clients_.erase(it); } @@ -117,7 +118,7 @@ bool ClientConnection::connect(const eckit::Configuration& config, bool singleAt } int fdbMaxConnectRetries = (singleAttempt ? 1 : eckit::Resource("fdbMaxConnectRetries", 3)); - int fdbConnectTimeout = eckit::Resource("fdbConnectTimeout", (singleAttempt ? 2 : 5)); // 0 = No timeout + int fdbConnectTimeout = eckit::Resource("fdbConnectTimeout", (singleAttempt ? 2 : 5)); // 0 = No timeout try { // Connect to server, and check that the server is happy on the response @@ -190,7 +191,7 @@ std::future ClientConnection::controlWrite(const Client& client, { std::lock_guard lock(promisesMutex_); auto pp = promises_.emplace(requestID, std::promise{}).first; - f = pp->second.get_future(); + f = pp->second.get_future(); } Connection::write(msg, true, client.clientId(), requestID, payloads); @@ -218,7 +219,7 @@ void ClientConnection::dataWrite(Client& client, remote::Message msg, uint32_t r // Reset the queue after previous done/errors ASSERT(!dataWriteQueue_); - dataWriteQueue_ = std::make_unique>(maxQueueLength); + dataWriteQueue_ = std::make_unique>(maxQueueLength); dataWriteThread_ = std::thread([this] { dataWriteThreadLoop(); }); } } @@ -449,7 +450,7 @@ void ClientConnection::listeningDataThreadLoop() { } else { if (hdr.clientID()) { - bool handled = false; + bool handled = false; Client* client = nullptr; { std::lock_guard lock(clientsMutex_); diff --git a/src/fdb5/remote/client/ClientConnectionRouter.cc b/src/fdb5/remote/client/ClientConnectionRouter.cc index 257a1c8ab..01e861c43 100644 --- a/src/fdb5/remote/client/ClientConnectionRouter.cc +++ b/src/fdb5/remote/client/ClientConnectionRouter.cc @@ -57,7 +57,7 @@ std::shared_ptr ClientConnectionRouter::connection( while (fullEndpoints.size() > 0) { // select a random endpoint - size_t idx = std::rand() % fullEndpoints.size(); + size_t idx = std::rand() % fullEndpoints.size(); eckit::net::Endpoint endpoint = fullEndpoints.at(idx).first; // look for the selected endpoint diff --git a/src/fdb5/remote/client/ReadLimiter.cc b/src/fdb5/remote/client/ReadLimiter.cc index 29190144c..50173dac5 100644 --- a/src/fdb5/remote/client/ReadLimiter.cc +++ b/src/fdb5/remote/client/ReadLimiter.cc @@ -39,7 +39,7 @@ void ReadLimiter::add(RemoteStore* client, uint32_t id, const FieldLocation& fie s << fieldLocation; s << remapKey; size_t requestSize = s.position(); - size_t resultSize = fieldLocation.length(); + size_t resultSize = fieldLocation.length(); if (resultSize > memoryLimit_) { std::stringstream ss; diff --git a/src/fdb5/remote/client/RemoteStore.cc b/src/fdb5/remote/client/RemoteStore.cc index fd1cad3cf..f324c8905 100644 --- a/src/fdb5/remote/client/RemoteStore.cc +++ b/src/fdb5/remote/client/RemoteStore.cc @@ -106,8 +106,9 @@ class FDBRemoteDataHandle : public DataHandle { long read(void* pos, long sz) override { - if (complete_) + if (complete_) { return 0; + } long total = 0; long n; @@ -202,7 +203,7 @@ Client::EndpointList storeEndpoints(const Config& config) { ASSERT(config.has("stores")); ASSERT(config.has("fieldLocationEndpoints")); - const auto stores = config.getStringVector("stores"); + const auto stores = config.getStringVector("stores"); const auto fieldLocationEndpoints = config.getStringVector("fieldLocationEndpoints"); ASSERT(stores.size() == fieldLocationEndpoints.size()); @@ -460,7 +461,7 @@ eckit::DataHandle* RemoteStore::dataHandle(const FieldLocation& fieldLocation, c uint32_t id = generateRequestID(); - static size_t queueSize = 320; + static size_t queueSize = 320; std::shared_ptr queue = nullptr; { std::lock_guard lock(retrieveMessageMutex_); @@ -482,7 +483,7 @@ RemoteStore& RemoteStore::get(const eckit::URI& uri) { std::lock_guard lock(storeMutex_); const std::string& endpoint = uri.hostport(); - auto it = readStores_.find(endpoint); + auto it = readStores_.find(endpoint); if (it != readStores_.end()) { return *(it->second); } diff --git a/src/fdb5/remote/client/RemoteStore.h b/src/fdb5/remote/client/RemoteStore.h index ccb0badd5..d00086ba3 100644 --- a/src/fdb5/remote/client/RemoteStore.h +++ b/src/fdb5/remote/client/RemoteStore.h @@ -70,11 +70,12 @@ class Locations { std::lock_guard lock(locationMutex_); ASSERT(fieldsArchived_ - locationsReceived_ == locations_.size()); - if (fieldsArchived_ == locationsReceived_) + if (fieldsArchived_ == locationsReceived_) { return true; + } promiseArchivalCompleted_ = std::promise{}; - archivalCompleted_ = promiseArchivalCompleted_.get_future(); + archivalCompleted_ = promiseArchivalCompleted_.get_future(); return false; } @@ -86,7 +87,7 @@ class Locations { void reset() { std::lock_guard lock(locationMutex_); ASSERT(fieldsArchived_ - locationsReceived_ == locations_.size()); - fieldsArchived_ = locations_.size(); + fieldsArchived_ = locations_.size(); locationsReceived_ = 0; } @@ -108,7 +109,7 @@ class RemoteStore : public Store, public Client { public: // types using StoredMessage = std::pair; - using MessageQueue = eckit::Queue; + using MessageQueue = eckit::Queue; static const char* typeName() { return "remote"; } diff --git a/src/fdb5/remote/server/AvailablePortList.cc b/src/fdb5/remote/server/AvailablePortList.cc index 94765744d..f811c7574 100644 --- a/src/fdb5/remote/server/AvailablePortList.cc +++ b/src/fdb5/remote/server/AvailablePortList.cc @@ -44,8 +44,9 @@ std::set readServices() { std::set portsToSkip; PathName servicesFile = "/etc/services"; - if (!servicesFile.exists()) + if (!servicesFile.exists()) { return portsToSkip; + } std::ifstream in(servicesFile.localPath()); @@ -85,8 +86,8 @@ std::set readServices() { if (s.size() >= 3) { - const std::string& sname = s[0]; - const std::string& port = s[1]; + const std::string& sname = s[0]; + const std::string& port = s[1]; const std::string& protocol = s[2]; LOG_DEBUG_LIB(LibFdb5) << "Skipping port " << port << " service " << sname << " protocol " << protocol @@ -123,28 +124,30 @@ void AvailablePortList::initialise() { break; } } - if (initialised) + if (initialised) { return; + } // Get a list of everything that needs to be skipped std::set portsToSkip = readServices(); size_t foundCount = 0; - int port = startPort_; + int port = startPort_; eckit::Log::info() << "Initialising port list." << std::endl; while (foundCount < count_) { bool found = true; - if (portsToSkip.find(port) != portsToSkip.end()) + if (portsToSkip.find(port) != portsToSkip.end()) { found = false; + } // if (found && getservbyport(port, 0) != 0) found = false; if (found) { - shared_[foundCount].port = port; - shared_[foundCount].pid = 0; + shared_[foundCount].port = port; + shared_[foundCount].pid = 0; shared_[foundCount].deadTime = 0; foundCount++; } @@ -166,7 +169,7 @@ int AvailablePortList::acquire() { for (auto it = shared_.begin(); it != shared_.end(); ++it) { if (it->pid == 0) { - it->pid = pid; + it->pid = pid; it->deadTime = 0; shared_.sync(); if (::getservbyport(it->port, 0) == 0) { @@ -200,7 +203,7 @@ void AvailablePortList::reap(int deadTime) { ASSERT(it->deadTime <= now); ASSERT(!ProcessControler::isRunning(it->pid)); if ((now - it->deadTime) >= deadTime) { - it->pid = 0; + it->pid = 0; it->deadTime = 0; } } diff --git a/src/fdb5/remote/server/CatalogueHandler.cc b/src/fdb5/remote/server/CatalogueHandler.cc index 3f233cb45..ff1127832 100644 --- a/src/fdb5/remote/server/CatalogueHandler.cc +++ b/src/fdb5/remote/server/CatalogueHandler.cc @@ -55,10 +55,11 @@ Handled CatalogueHandler::handleControl(Message message, uint32_t clientID, uint if (it == fdbs_.end()) { fdbs_[clientID]; fdbControlConnection_ = true; - fdbDataConnection_ = !single_; + fdbDataConnection_ = !single_; numControlConnection_++; - if (fdbDataConnection_) + if (fdbDataConnection_) { numDataConnection_++; + } } } schema(clientID, requestID, eckit::Buffer(0)); @@ -282,7 +283,7 @@ void CatalogueHandler::schema(uint32_t clientID, uint32_t requestID, eckit::Buff Key dbKey(s); // 2. Get catalogue - Catalogue& cat = catalogue(clientID, dbKey); + Catalogue& cat = catalogue(clientID, dbKey); const Schema& schema = cat.schema(); stream << schema; } @@ -403,8 +404,8 @@ void CatalogueHandler::flush(uint32_t clientID, uint32_t requestID, eckit::Buffe { std::lock_guard lock(fieldLocationsMutex_); it->second.fieldLocationsReceived = std::promise{}; - it->second.locationsExpected = 0; - it->second.locationsArchived = 0; + it->second.locationsExpected = 0; + it->second.locationsArchived = 0; } it->second.catalogue->flush(numArchived); diff --git a/src/fdb5/remote/server/ServerConnection.cc b/src/fdb5/remote/server/ServerConnection.cc index 45df3405b..43f7312bc 100644 --- a/src/fdb5/remote/server/ServerConnection.cc +++ b/src/fdb5/remote/server/ServerConnection.cc @@ -59,7 +59,7 @@ namespace fdb5::remote { namespace { constexpr const auto defaultRetrieveQueueSize = 10000; -constexpr const auto defaultArchiveQueueSize = 320; +constexpr const auto defaultArchiveQueueSize = 320; } // namespace @@ -180,7 +180,7 @@ void ServerConnection::initialiseConnections() { RemoteConfiguration serverConf = availableFunctionality(); try { agreedConf_ = RemoteConfiguration::common(clientConf, serverConf); - single_ = agreedConf_.singleConnection(); + single_ = agreedConf_.singleConnection(); } catch (const eckit::Exception& e) { error(e.what(), hdr.clientID(), hdr.requestID); @@ -278,7 +278,7 @@ size_t ServerConnection::archiveThreadLoop() { // Handle MultiBlob const char* firstData = reinterpret_cast(elem.payload_.data()); // For pointer arithmetic - const char* charData = firstData; + const char* charData = firstData; while (size_t(charData - firstData) < elem.payload_.size()) { const MessageHeader* hdr = reinterpret_cast(charData); ASSERT(hdr->message == Message::Blob); @@ -461,8 +461,9 @@ void ServerConnection::handle() { void ServerConnection::handleException(std::exception_ptr e) { try { - if (e) + if (e) { std::rethrow_exception(e); + } } catch (const std::exception& e) { error(e.what(), 0, 0); diff --git a/src/fdb5/remote/server/ServerConnection.h b/src/fdb5/remote/server/ServerConnection.h index b82150dda..903d3fac4 100644 --- a/src/fdb5/remote/server/ServerConnection.h +++ b/src/fdb5/remote/server/ServerConnection.h @@ -50,10 +50,10 @@ class Handler { public: - virtual Handled handleControl(Message message, uint32_t clientID, uint32_t requestID) = 0; + virtual Handled handleControl(Message message, uint32_t clientID, uint32_t requestID) = 0; virtual Handled handleControl(Message message, uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) = 0; - virtual Handled handleData(Message message, uint32_t clientID, uint32_t requestID) = 0; - virtual Handled handleData(Message message, uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) = 0; + virtual Handled handleData(Message message, uint32_t clientID, uint32_t requestID) = 0; + virtual Handled handleData(Message message, uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) = 0; virtual void handleException(std::exception_ptr e) = 0; }; diff --git a/src/fdb5/rules/ExcludeAll.cc b/src/fdb5/rules/ExcludeAll.cc index eb53baa6b..2f95dabeb 100644 --- a/src/fdb5/rules/ExcludeAll.cc +++ b/src/fdb5/rules/ExcludeAll.cc @@ -50,8 +50,9 @@ void ExcludeAll::encode(eckit::Stream& s) const { bool ExcludeAll::match(const std::string& keyword, const Key& key) const { if (const auto [iter, found] = key.find(keyword); found) { - if (!match(iter->second)) + if (!match(iter->second)) { return false; + } } return true; diff --git a/src/fdb5/rules/Matcher.h b/src/fdb5/rules/Matcher.h index 09aa4895d..cd86e728a 100644 --- a/src/fdb5/rules/Matcher.h +++ b/src/fdb5/rules/Matcher.h @@ -49,7 +49,7 @@ class Matcher : public eckit::Streamable { const std::string& keyword) const; virtual const std::string& defaultValue() const; - virtual bool match(const std::string& value) const = 0; + virtual bool match(const std::string& value) const = 0; virtual bool match(const std::string& keyword, const Key& key) const = 0; virtual void fill(Key& key, const std::string& keyword, const std::string& value) const; diff --git a/src/fdb5/rules/Rule.cc b/src/fdb5/rules/Rule.cc index 7c42a1a44..68f4f9521 100644 --- a/src/fdb5/rules/Rule.cc +++ b/src/fdb5/rules/Rule.cc @@ -47,11 +47,11 @@ namespace { class RuleGraph { struct RuleNode { - RuleNode(const RuleNode&) = delete; + RuleNode(const RuleNode&) = delete; RuleNode& operator=(const RuleNode&) = delete; - RuleNode(RuleNode&&) = delete; - RuleNode& operator=(RuleNode&&) = delete; - ~RuleNode() = default; + RuleNode(RuleNode&&) = delete; + RuleNode& operator=(RuleNode&&) = delete; + ~RuleNode() = default; explicit RuleNode(const std::string& keyword) : keyword_{keyword} {} @@ -62,8 +62,8 @@ class RuleGraph { public: // types - using value_type = std::list; - using reference = eckit::StringList&; + using value_type = std::list; + using reference = eckit::StringList&; using const_iterator = value_type::const_iterator; public: // methods @@ -295,7 +295,7 @@ std::vector Rule::findMatchingKeys(const metkit::mars::MarsRequest& request for (const auto& pred : predicates_) { const auto& keyword = pred->keyword(); - const auto& type = registry_.lookupType(keyword); + const auto& type = registry_.lookupType(keyword); const auto& values = pred->values(request); @@ -328,7 +328,7 @@ std::vector Rule::findMatchingKeys(const metkit::mars::MarsRequest& request for (const auto& pred : predicates_) { const auto& keyword = pred->keyword(); - const auto& type = registry_.lookupType(keyword); + const auto& type = registry_.lookupType(keyword); // performance optimization to avoid calling values() on visitor if (!pred->optional() && request.countValues(keyword) == 0) { @@ -403,7 +403,7 @@ bool Rule::tryFill(Key& key, const eckit::StringList& values) const { ASSERT(values.size() <= predicates_.size() + 1); auto it_value = values.begin(); - auto it_pred = predicates_.begin(); + auto it_pred = predicates_.begin(); for (; it_pred != predicates_.end() && it_value != values.end(); ++it_pred, ++it_value) { @@ -504,7 +504,7 @@ void Rule::check(const Key& key) const { const auto& keyword = pred->keyword(); if (const auto [iter, found] = key.find(keyword); found) { - const auto& value = iter->second; + const auto& value = iter->second; const auto& tidyValue = registry().lookupType(keyword).tidy(value); if (value != tidyValue) { std::ostringstream oss; diff --git a/src/fdb5/rules/SchemaParser.cc b/src/fdb5/rules/SchemaParser.cc index c338c665b..ae71d71ed 100644 --- a/src/fdb5/rules/SchemaParser.cc +++ b/src/fdb5/rules/SchemaParser.cc @@ -76,7 +76,7 @@ std::unique_ptr SchemaParser::parsePredicate(eckit::StringDict& types consume(c); ASSERT(types.find(k) == types.end()); types[k] = parseIdent(false, false); - c = peek(); + c = peek(); } if (c == '?') { @@ -97,7 +97,7 @@ std::unique_ptr SchemaParser::parsePredicate(eckit::StringDict& types consume("="); std::string val = parseIdent(true, false); - exclude = val[0] == '!'; + exclude = val[0] == '!'; if (exclude) { values.insert(val.substr(1)); diff --git a/src/fdb5/rules/SelectMatcher.cc b/src/fdb5/rules/SelectMatcher.cc index 6a18592e1..504f3b1c3 100644 --- a/src/fdb5/rules/SelectMatcher.cc +++ b/src/fdb5/rules/SelectMatcher.cc @@ -33,8 +33,9 @@ class KeyAccessor : public metkit::mars::RequestLike { std::optional get(const std::string& keyword) const override { const auto [it, found] = key_.find(keyword); - if (!found) + if (!found) { return std::nullopt; + } return std::cref(it->second); } @@ -70,8 +71,9 @@ bool SelectMatcher::match(const metkit::mars::MarsRequest& request, Matcher::Mat template // T is either a MarsRequest or KeyAccessor bool SelectMatcher::matchInner(const T& vals, Matcher::MatchMissingPolicy matchOnMissing) const { - if (!select_.match(vals, matchOnMissing)) + if (!select_.match(vals, matchOnMissing)) { return false; + } bool excluded = std::any_of(excludes_.begin(), excludes_.end(), [&](const auto& ex) { return ex.match(vals, Matcher::DontMatchOnMissing); }); diff --git a/src/fdb5/toc/BTreeIndex.cc b/src/fdb5/toc/BTreeIndex.cc index ad67eaeec..660bb842c 100644 --- a/src/fdb5/toc/BTreeIndex.cc +++ b/src/fdb5/toc/BTreeIndex.cc @@ -152,7 +152,7 @@ BTREE(64, 65536, FieldRefReduced); BTreeIndex::~BTreeIndex() {} static std::string defaultIndexType = "BTreeIndex"; -static std::string wideIndexType = "BTreeIndex64"; +static std::string wideIndexType = "BTreeIndex64"; const std::string& BTreeIndex::defaultType(size_t keySize) { static std::string fdbIndexType = eckit::Resource("fdbIndexType;$FDB_INDEX_TYPE", ""); diff --git a/src/fdb5/toc/BTreeIndex.h b/src/fdb5/toc/BTreeIndex.h index 7b28ed1ba..e45dc3d18 100644 --- a/src/fdb5/toc/BTreeIndex.h +++ b/src/fdb5/toc/BTreeIndex.h @@ -45,12 +45,12 @@ class BTreeIndex { virtual ~BTreeIndex(); virtual bool get(const std::string& key, FieldRef& data) const = 0; virtual bool set(const std::string& key, const FieldRef& data) = 0; - virtual void flush() = 0; - virtual void sync() = 0; - virtual void visit(BTreeIndexVisitor& visitor) const = 0; - virtual void flock() = 0; - virtual void funlock() = 0; - virtual void preload() = 0; + virtual void flush() = 0; + virtual void sync() = 0; + virtual void visit(BTreeIndexVisitor& visitor) const = 0; + virtual void flock() = 0; + virtual void funlock() = 0; + virtual void preload() = 0; static const std::string& defaultType(size_t keySize); diff --git a/src/fdb5/toc/EnvVarFileSpaceHandler.cc b/src/fdb5/toc/EnvVarFileSpaceHandler.cc index 6969b9a17..283217998 100644 --- a/src/fdb5/toc/EnvVarFileSpaceHandler.cc +++ b/src/fdb5/toc/EnvVarFileSpaceHandler.cc @@ -51,8 +51,9 @@ eckit::PathName EnvVarFileSpaceHandler::selectFileSystem(const Key& key, const F if (value) { eckit::PathName path(value); - if (path.exists()) + if (path.exists()) { return path; + } std::ostringstream msg; msg << ""; diff --git a/src/fdb5/toc/ExpverFileSpaceHandler.cc b/src/fdb5/toc/ExpverFileSpaceHandler.cc index d30857ba3..0482b7ab1 100644 --- a/src/fdb5/toc/ExpverFileSpaceHandler.cc +++ b/src/fdb5/toc/ExpverFileSpaceHandler.cc @@ -68,14 +68,17 @@ void ExpverFileSpaceHandler::load() const { size_t i = 0; while (i < s.size()) /* cleanup entries that are empty */ { - if (s[i].length() == 0) + if (s[i].length() == 0) { s.erase(s.begin() + i); - else + } + else { i++; + } } - if (s.size() == 0 || s[0][0] == '#') + if (s.size() == 0 || s[0][0] == '#') { continue; + } if (s.size() != 2) { std::ostringstream oss; @@ -121,14 +124,17 @@ eckit::PathName ExpverFileSpaceHandler::append(const std::string& expver, const size_t i = 0; while (i < s.size()) /* cleanup entries that are empty */ { - if (s[i].length() == 0) + if (s[i].length() == 0) { s.erase(s.begin() + i); - else + } + else { i++; + } } - if (s.size() == 0 || s[0][0] == '#') + if (s.size() == 0 || s[0][0] == '#') { continue; + } if (s.size() != 2) { std::ostringstream oss; @@ -187,15 +193,17 @@ eckit::PathName ExpverFileSpaceHandler::selectFileSystem(const Key& key, const F // check if key is mapped already to a filesystem - if (table_.empty()) + if (table_.empty()) { load(); + } std::string expver = key.get("expver"); // we can NOT use the type system here because we haven't opened a DB yet // so we have to do validation directly on string - if (not expver_is_valid(expver)) + if (not expver_is_valid(expver)) { throw eckit::BadValue("Invalid expver value " + expver, Here()); + } LOG_DEBUG_LIB(LibFdb5) << "Selecting file system for expver [" << expver << "]" << std::endl; diff --git a/src/fdb5/toc/FieldRef.cc b/src/fdb5/toc/FieldRef.cc index eccff390d..8ed227dcb 100644 --- a/src/fdb5/toc/FieldRef.cc +++ b/src/fdb5/toc/FieldRef.cc @@ -32,7 +32,7 @@ FieldRefLocation::FieldRefLocation(UriStore& store, const Field& field) { const FieldLocation& loc = field.location(); - uriId_ = store.insert(loc.uri()); + uriId_ = store.insert(loc.uri()); length_ = loc.length(); offset_ = loc.offset(); } diff --git a/src/fdb5/toc/FileSpace.cc b/src/fdb5/toc/FileSpace.cc index eb64b03df..8fa31b04c 100644 --- a/src/fdb5/toc/FileSpace.cc +++ b/src/fdb5/toc/FileSpace.cc @@ -123,31 +123,33 @@ eckit::PathName getFullDB(const eckit::PathName& path, const std::string& db) { bool FileSpace::existsDB(const Key& key, const eckit::PathName& db, TocPath& existsDB) const { unsigned count = 0; - bool found = false; + bool found = false; std::string matchList; for (RootVec::const_iterator i = roots_.begin(); i != roots_.end(); ++i) { if (i->enabled(ControlIdentifier::List) && i->exists()) { eckit::PathName fullDB = getFullDB(i->path(), db); - eckit::PathName dbToc = fullDB / "toc"; + eckit::PathName dbToc = fullDB / "toc"; if (fullDB.exists() && dbToc.exists()) { matchList += (count == 0 ? "" : ", ") + fullDB; bool allowMultipleDbs = (fullDB / (controlfile_lookup.find(ControlIdentifier::UniqueRoot)->second)).exists(); if (!count || allowMultipleDbs) { // take last - existsDB.directory_ = fullDB; + existsDB.directory_ = fullDB; existsDB.controlIdentifiers_ = i->controlIdentifiers(); - found = true; + found = true; } - if (!allowMultipleDbs) + if (!allowMultipleDbs) { ++count; + } } } } - if (count <= 1) + if (count <= 1) { return found; + } std::ostringstream msg; msg << "Found multiple FDB roots matching key " << key << ", roots -> [" << matchList << "]"; diff --git a/src/fdb5/toc/FileSpaceHandler.cc b/src/fdb5/toc/FileSpaceHandler.cc index 191ad8cc7..a502c50e3 100644 --- a/src/fdb5/toc/FileSpaceHandler.cc +++ b/src/fdb5/toc/FileSpaceHandler.cc @@ -27,11 +27,11 @@ namespace fdb5 { static eckit::Mutex* local_mutex; typedef std::map HandlerMap; -static HandlerMap* m = 0; +static HandlerMap* m = 0; static pthread_once_t once = PTHREAD_ONCE_INIT; static void init() { local_mutex = new eckit::Mutex(); - m = new HandlerMap(); + m = new HandlerMap(); } //---------------------------------------------------------------------------------------------------------------------- @@ -60,8 +60,9 @@ const FileSpaceHandler& FileSpaceHandler::lookup(const std::string& name, const if (j == m->end()) { eckit::Log::error() << "No FileSpaceHandler factory for [" << name << "]" << std::endl; eckit::Log::error() << "Available FileSpaceHandler's are:" << std::endl; - for (j = m->begin(); j != m->end(); ++j) + for (j = m->begin(); j != m->end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No FileSpaceHandler called ") + name); } diff --git a/src/fdb5/toc/Root.cc b/src/fdb5/toc/Root.cc index 6931ade3a..255009008 100644 --- a/src/fdb5/toc/Root.cc +++ b/src/fdb5/toc/Root.cc @@ -23,14 +23,18 @@ namespace fdb5 { Root::Root(const std::string& path, const std::string& filespace, bool list, bool retrieve, bool archive, bool wipe) : path_(path), filespace_(filespace), checked_(false), exists_(false), controlIdentifiers_() { - if (!list) + if (!list) { controlIdentifiers_ |= ControlIdentifier::List; - if (!retrieve) + } + if (!retrieve) { controlIdentifiers_ |= ControlIdentifier::Retrieve; - if (!archive) + } + if (!archive) { controlIdentifiers_ |= ControlIdentifier::Archive; - if (!wipe) + } + if (!wipe) { controlIdentifiers_ |= ControlIdentifier::Wipe; + } } bool Root::exists() const { diff --git a/src/fdb5/toc/RootManager.cc b/src/fdb5/toc/RootManager.cc index c0b9e5043..47e348914 100644 --- a/src/fdb5/toc/RootManager.cc +++ b/src/fdb5/toc/RootManager.cc @@ -67,8 +67,9 @@ class DbPathNamer { /// but partial match for values bool match(const Key& k, const char* missing = 0) const { - if (k.size() != keyregex_.size()) + if (k.size() != keyregex_.size()) { return false; + } for (Key::const_iterator i = k.begin(); i != k.end(); ++i) { @@ -131,7 +132,7 @@ class DbPathNamer { std::string substituteVars(const std::string& s, const Key& k, const char* missing = 0) const { std::string result; size_t len = s.length(); - bool var = false; + bool var = false; std::string word; std::map::const_iterator j; @@ -143,7 +144,7 @@ class DbPathNamer { os << "FDB RootManager substituteVars: unexpected { found in " << s << " at position " << i; throw UserError(os.str()); } - var = true; + var = true; word = ""; break; @@ -178,10 +179,12 @@ class DbPathNamer { break; default: - if (var) + if (var) { word += s[i]; - else + } + else { result += s[i]; + } break; } } @@ -263,7 +266,7 @@ static const DbPathNamerTable& readDbNamers(const Config& config) { switch (s.size()) { case 2: { - const std::string& regex = s[0]; + const std::string& regex = s[0]; const std::string& format = s[1]; table.push_back(DbPathNamer(regex, format)); @@ -327,10 +330,10 @@ static std::vector readRoots(const eckit::PathName& fdbRootsFile) { switch (s.size()) { case 4: { - const std::string& path = s[0]; + const std::string& path = s[0]; const std::string& filespace = s[1]; - bool writable = str2bool(s[2]); - bool visit = str2bool(s[3]); + bool writable = str2bool(s[2]); + bool visit = str2bool(s[3]); // list retrieve archive wipe result.push_back(Root(path, filespace, visit, visit, writable, writable)); @@ -372,7 +375,7 @@ static std::vector parseMarsDisks(const eckit::PathName& file, const std:: } // these could be gotten from the file if we decide to extend the format - bool writable = true; + bool writable = true; bool visitable = true; std::vector spaceRoots; @@ -447,9 +450,9 @@ static FileSpaceTable parseFileSpacesFile(const eckit::PathName& fdbHome) { switch (s.size()) { case 3: { - const std::string& regex = s[0]; + const std::string& regex = s[0]; const std::string& filespace = s[1]; - const std::string& handler = s[2]; + const std::string& handler = s[2]; std::vector roots = fileSpaceRoots(allRoots, filespace); @@ -475,8 +478,9 @@ static FileSpaceTable parseFileSpacesFile(const eckit::PathName& fdbHome) { std::vector CatalogueRootManager::getSpaceRoots(const LocalConfiguration& space) { ASSERT(space.has("roots") != space.has("catalogueRoots")); - if (space.has("roots")) + if (space.has("roots")) { return space.getSubConfigurations("roots"); + } return space.getSubConfigurations("catalogueRoots"); } @@ -484,8 +488,9 @@ std::vector CatalogueRootManager::getSpaceRoots(const LocalC std::vector StoreRootManager::getSpaceRoots(const LocalConfiguration& space) { ASSERT(space.has("roots") != space.has("storeRoots")); - if (space.has("roots")) + if (space.has("roots")) { return space.getSubConfigurations("roots"); + } return space.getSubConfigurations("storeRoots"); } @@ -514,13 +519,13 @@ FileSpaceTable RootManager::fileSpaces() { if (space.getBool("marsDisks", false)) { PathName file = config_.expandPath(space.getString("path", "~fdb/etc/disks/fdb")); - spaceRoots = parseMarsDisks(file, name); + spaceRoots = parseMarsDisks(file, name); } else { std::vector roots = getSpaceRoots(space); for (const auto& root : roots) { bool writable = root.getBool("writable", true); - bool visit = root.getBool("visit", true); + bool visit = root.getBool("visit", true); spaceRoots.emplace_back(Root(root.getString("path"), root.getString("name", ""), root.getBool("list", visit), root.getBool("retrieve", visit), root.getBool("archive", writable), root.getBool("wipe", writable))); @@ -641,8 +646,9 @@ std::vector RootManager::visitableRoots(const std::set& keys) { } } - if (!matched) + if (!matched) { LOG_DEBUG_LIB(LibFdb5) << "FAIL to match space " << space << std::endl; + } } LOG_DEBUG_LIB(LibFdb5) << "Visitable Roots " << roots << std::endl; @@ -660,8 +666,9 @@ std::vector RootManager::visitableRoots(const metkit::mars::Mar std::map results; std::set keys; config_.schema().matchDatabase(request, results, ""); - for (const auto& [key, rule] : results) + for (const auto& [key, rule] : results) { keys.insert(key); + } return visitableRoots(keys); } diff --git a/src/fdb5/toc/TocCatalogue.cc b/src/fdb5/toc/TocCatalogue.cc index 022fd2336..e21fa3ea6 100644 --- a/src/fdb5/toc/TocCatalogue.cc +++ b/src/fdb5/toc/TocCatalogue.cc @@ -81,7 +81,7 @@ std::vector TocCatalogue::metadataPaths() const { void TocCatalogue::loadSchema() { Timer timer("TocCatalogue::loadSchema()", Log::debug()); schema_ = &SchemaRegistry::instance().get(schemaPath()); - rule_ = &schema_->matchingRule(dbKey_); + rule_ = &schema_->matchingRule(dbKey_); } StatsReportVisitor* TocCatalogue::statsReportVisitor() const { @@ -127,14 +127,16 @@ void TocCatalogue::remove(const eckit::PathName& path, std::ostream& logAlways, if (path.isDir()) { logVerbose << "rmdir: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.rmdir(false); + } } else { logVerbose << "Unlinking: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.unlink(false); + } } } diff --git a/src/fdb5/toc/TocCatalogueWriter.cc b/src/fdb5/toc/TocCatalogueWriter.cc index 352baf73f..4fa765745 100644 --- a/src/fdb5/toc/TocCatalogueWriter.cc +++ b/src/fdb5/toc/TocCatalogueWriter.cc @@ -107,8 +107,8 @@ bool TocCatalogueWriter::createIndex(const Key& idxKey, size_t datumKeySize) { } void TocCatalogueWriter::deselectIndex() { - current_ = Index(); - currentFull_ = Index(); + current_ = Index(); + currentFull_ = Index(); currentIndexKey_ = Key(); } @@ -144,8 +144,9 @@ void TocCatalogueWriter::index(const Key& key, const eckit::URI& uri, eckit::Off current_.put(key, field); - if (useSubToc()) + if (useSubToc()) { currentFull_.put(key, field); + } } void TocCatalogueWriter::reconsolidateIndexesAndTocs() { @@ -180,7 +181,7 @@ void TocCatalogueWriter::reconsolidateIndexesAndTocs() { std::set subtocs; std::vector indexInSubtoc; std::vector readIndexes = loadIndexes(false, &subtocs, &indexInSubtoc); - size_t maskable_indexes = 0; + size_t maskable_indexes = 0; ConsolidateIndexVisitor visitor(*this); @@ -194,8 +195,9 @@ void TocCatalogueWriter::reconsolidateIndexesAndTocs() { Log::info() << "Visiting index: " << idx.location().uri() << std::endl; // We need to explicitly mask indexes in the master TOC - if (!indexInSubtoc[i]) + if (!indexInSubtoc[i]) { maskable_indexes += 1; + } } // Flush the new indexes and add relevant entries! @@ -320,15 +322,17 @@ void TocCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, if (current_.null()) { ASSERT(!currentIndexKey_.empty()); - if (!selectIndex(currentIndexKey_)) + if (!selectIndex(currentIndexKey_)) { createIndex(currentIndexKey_, datumKey.size()); + } } else { // in case of async archival (out of order store/catalogue archival), currentIndexKey_ can differ from the // indexKey used for store archival. Reset it if (currentIndexKey_ != idxKey) { - if (!selectIndex(idxKey)) + if (!selectIndex(idxKey)) { createIndex(idxKey, datumKey.size()); + } } } @@ -336,8 +340,9 @@ void TocCatalogueWriter::archive(const Key& idxKey, const Key& datumKey, current_.put(datumKey, field); - if (useSubToc()) + if (useSubToc()) { currentFull_.put(datumKey, field); + } } void TocCatalogueWriter::flush(size_t archivedFields) { @@ -350,8 +355,8 @@ void TocCatalogueWriter::flush(size_t archivedFields) { flushIndexes(); archivedLocations_ = 0; - current_ = Index(); - currentFull_ = Index(); + current_ = Index(); + currentFull_ = Index(); } eckit::PathName TocCatalogueWriter::generateIndexPath(const Key& key) const { diff --git a/src/fdb5/toc/TocCommon.cc b/src/fdb5/toc/TocCommon.cc index b891f7c74..d129ebdd9 100644 --- a/src/fdb5/toc/TocCommon.cc +++ b/src/fdb5/toc/TocCommon.cc @@ -28,8 +28,9 @@ eckit::LocalPathName TocCommon::findRealPath(const eckit::LocalPathName& path) { // realpath only works on existing paths, so work back up the path until // we find one that does, get the realpath on that, then reconstruct. - if (path.exists()) + if (path.exists()) { return path.realName(); + } return findRealPath(path.dirName()) / path.baseName(); } diff --git a/src/fdb5/toc/TocEngine.cc b/src/fdb5/toc/TocEngine.cc index 40b4372fc..a04002b0b 100644 --- a/src/fdb5/toc/TocEngine.cc +++ b/src/fdb5/toc/TocEngine.cc @@ -59,13 +59,15 @@ void TocEngine::scan_dbs(const std::string& path, std::list& dbs) c } if (e->d_name[0] == '.') { - if (e->d_name[1] == 0 || (e->d_name[1] == '.' && e->d_name[2] == 0)) + if (e->d_name[1] == 0 || (e->d_name[1] == '.' && e->d_name[2] == 0)) { continue; + } } std::string full = path; - if (path[path.length() - 1] != '/') + if (path[path.length() - 1] != '/') { full += "/"; + } full += e->d_name; bool do_stat = true; @@ -86,8 +88,9 @@ void TocEngine::scan_dbs(const std::string& path, std::list& dbs) c dbs.push_back(full); } } - else + else { Log::error() << "Cannot stat " << full << Log::syserr << std::endl; + } } } } @@ -105,11 +108,12 @@ eckit::URI TocEngine::location(const Key& key, const Config& config) const { } bool TocEngine::canHandle(const eckit::URI& uri, const Config& config) const { - if (uri.scheme() != "toc") + if (uri.scheme() != "toc") { return false; + } eckit::PathName path = uri.path(); - eckit::PathName toc = path / "toc"; + eckit::PathName toc = path / "toc"; return path.isDir() && toc.exists(); } @@ -174,8 +178,9 @@ std::map TocEngine::databases(const std::map TocEngine::databases(const metkit::mars::MarsRequest& re matchRequestToDB(request, keys, "", config); LOG_DEBUG_LIB(LibFdb5) << "Matched DB schemas for request " << request << " -> keys ["; - for (const auto& [key, rule] : keys) + for (const auto& [key, rule] : keys) { LOG_DEBUG_LIB(LibFdb5) << key << " | " << *rule << ","; + } LOG_DEBUG_LIB(LibFdb5) << "]" << std::endl; std::map databasesMatchRegex(databases(keys, roots, config)); @@ -230,7 +236,7 @@ std::vector TocEngine::databases(const metkit::mars::MarsRequest& re /// @todo we don't have to open tocs to check if they match the request if (p.exists()) { eckit::PathName path = p.isDir() ? p : p.dirName(); - path = path.realName(); + path = path.realName(); LOG_DEBUG_LIB(LibFdb5) << "FDB processing Path " << path << std::endl; diff --git a/src/fdb5/toc/TocHandler.cc b/src/fdb5/toc/TocHandler.cc index 505d11922..1b026d37e 100644 --- a/src/fdb5/toc/TocHandler.cc +++ b/src/fdb5/toc/TocHandler.cc @@ -48,10 +48,10 @@ namespace fdb5 { //---------------------------------------------------------------------------------------------------------------------- namespace { -constexpr const char* retrieve_lock_file = "retrieve.lock"; -constexpr const char* archive_lock_file = "archive.lock"; -constexpr const char* list_lock_file = "list.lock"; -constexpr const char* wipe_lock_file = "wipe.lock"; +constexpr const char* retrieve_lock_file = "retrieve.lock"; +constexpr const char* archive_lock_file = "archive.lock"; +constexpr const char* list_lock_file = "list.lock"; +constexpr const char* wipe_lock_file = "wipe.lock"; constexpr const char* allow_duplicates_file = "duplicates.allow"; } // namespace @@ -84,8 +84,9 @@ class CachedFDProxy { } long read(void* buf, long len, const char** pdata = nullptr) { - if (pdata && !cached_) + if (pdata && !cached_) { throw SeriousBug("Can only return a pointer to data in memory if cached", Here()); + } if (cached_) { if (pdata) { *pdata = reinterpret_cast(cached_->data()) + cached_->position(); @@ -295,7 +296,7 @@ void TocHandler::openForRead() const { // The masked subtocs and indexes could be updated each time, so reset this. enumeratedMaskedEntries_ = false; - numSubtocsRaw_ = 0; + numSubtocsRaw_ = 0; maskedEntries_.clear(); if (fdbCacheTocsOnRead) { @@ -440,8 +441,9 @@ bool TocHandler::readNext(TocRecord& r, bool walkSubTocs, bool hideSubTocEntries // For some tools (mainly diagnostic) it makes sense to be able to switch the // walking behaviour here. - if (!walkSubTocs) + if (!walkSubTocs) { return readNextInternal(r, data, length); + } // Ensure we are able to skip masked entries as appropriate @@ -480,15 +482,17 @@ bool TocHandler::readNext(TocRecord& r, bool walkSubTocs, bool hideSubTocEntries else if (r.header_.tag_ == TocRecord::TOC_INIT) { eckit::MemoryStream s(&r.payload_[0], r.maxPayloadSize); - if (parentKey_.empty()) + if (parentKey_.empty()) { parentKey_ = Key(s); + } return true; } else if (r.header_.tag_ == TocRecord::TOC_SUB_TOC) { LocalPathName absPath = parseSubTocRecord(r, readMasked); - if (absPath == "") + if (absPath == "") { continue; + } if (parentTocPath) { *parentTocPath = currentTocPath(); @@ -545,8 +549,9 @@ bool TocHandler::readNextInternal(TocRecord& r, const TocRecord** data, size_t* long len = proxy.read(&r.payload_, r.header_.size_ - sizeof(TocRecord::Header)); ASSERT(size_t(len) == r.header_.size_ - sizeof(TocRecord::Header)); - if (length) + if (length) { (*length) = len + sizeof(TocRecord::Header); + } } catch (...) { dumpTocCache(); @@ -568,9 +573,9 @@ std::vector TocHandler::subTocPaths() const { std::vector paths; - bool walkSubTocs = true; + bool walkSubTocs = true; bool hideSubTocEntries = false; - bool hideClearEntries = true; + bool hideClearEntries = true; while (readNext(*r, walkSubTocs, hideSubTocEntries, hideClearEntries)) { eckit::MemoryStream s(&r->payload_[0], r->maxPayloadSize); @@ -629,7 +634,7 @@ void TocHandler::close() const { dirty_ = false; } SYSCALL2(::close(fd_), tocPath_); - fd_ = -1; + fd_ = -1; writeMode_ = false; } } @@ -732,14 +737,15 @@ class SubtocPreloader { AutoFDCloser(AutoFDCloser&& rhs) : fd_(rhs.fd_) { rhs.fd_ = -1; } AutoFDCloser(const AutoFDCloser&) = delete; AutoFDCloser& operator=(AutoFDCloser&& rhs) { - fd_ = rhs.fd_; + fd_ = rhs.fd_; rhs.fd_ = -1; return *this; } AutoFDCloser& operator=(const AutoFDCloser&) = delete; ~AutoFDCloser() { - if (fd_ > 0) + if (fd_ > 0) { ::close(fd_); // n.b. ignore return value + } } }; @@ -785,9 +791,9 @@ class SubtocPreloader { aiocb& aio(aiocbs[i]); zero(aio); - aio.aio_fildes = fd; - aio.aio_offset = 0; - aio.aio_nbytes = tocSize; + aio.aio_fildes = fd; + aio.aio_offset = 0; + aio.aio_nbytes = tocSize; aio.aio_sigevent.sigev_notify = SIGEV_NONE; buffers[i].resize(tocSize); @@ -822,8 +828,9 @@ class SubtocPreloader { for (int n = 0; n < aiocbs.size(); ++n) { - if (done[n]) + if (done[n]) { continue; + } int e = ::aio_error(&aiocbs[n]); if (e == EINPROGRESS) { @@ -837,7 +844,7 @@ class SubtocPreloader { aiocbs[n].aio_nbytes = len; } - bool grow = true; + bool grow = true; auto cachedToc = std::make_unique(buffers[n].size(), grow); { @@ -869,8 +876,9 @@ class SubtocPreloader { void TocHandler::preloadSubTocs(bool readMasked) const { ASSERT(enumeratedMaskedEntries_); - if (numSubtocsRaw_ == 0) + if (numSubtocsRaw_ == 0) { return; + } CachedFDProxy proxy(tocPath_, fd_, cachedToc_); Offset startPosition = proxy.position(); // remember the current position of the file descriptor @@ -891,8 +899,9 @@ void TocHandler::preloadSubTocs(bool readMasked) const { switch (r->header_.tag_) { case TocRecord::TOC_SUB_TOC: { LocalPathName absPath = parseSubTocRecord(*r, readMasked); - if (absPath != "") + if (absPath != "") { preloader.addPath(absPath); + } } break; case TocRecord::TOC_INIT: break; @@ -980,7 +989,7 @@ void TocHandler::populateMaskedEntriesList() const { Offset ret = proxy.seek(startPosition); ASSERT(ret == startPosition); - numSubtocsRaw_ = countSubTocs; + numSubtocsRaw_ = countSubTocs; enumeratedMaskedEntries_ = true; } @@ -1092,7 +1101,7 @@ void TocHandler::writeSubTocRecord(const TocHandler& subToc) { // We use a relative path to this subtoc if it belongs to the current DB // but an absolute one otherwise (e.g. for fdb-overlay). const PathName& absPath = subToc.tocPath(); - eckit::PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; + eckit::PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; s << path; s << off_t{0}; @@ -1174,7 +1183,7 @@ void TocHandler::writeSubTocMaskRecord(const TocHandler& subToc) { // We use a relative path to this subtoc if it belongs to the current DB // but an absolute one otherwise (e.g. for fdb-overlay). const PathName& absPath = subToc.tocPath(); - PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; + PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; appendBlock(*r, buildSubTocMaskRecord(*r, path)); } @@ -1260,9 +1269,9 @@ size_t TocHandler::numberOfRecords() const { auto r = std::make_unique( serialisationVersion_.used()); // allocate (large) TocRecord on heap not stack (MARS-779) - bool walkSubTocs = true; + bool walkSubTocs = true; bool hideSubTocEntries = false; - bool hideClearEntries = false; + bool hideClearEntries = false; while (readNext(*r, walkSubTocs, hideSubTocEntries, hideClearEntries)) { count_++; } @@ -1289,7 +1298,7 @@ std::vector TocHandler::loadIndexes(bool sorted, std::set* s // We've got a bit mangled with our constness here... if (parentKey_.empty() && remapKeys && !isSubToc_) { const auto& k = const_cast(*this).databaseKey(); - parentKey_ = k; + parentKey_ = k; } openForRead(); @@ -1308,11 +1317,11 @@ std::vector TocHandler::loadIndexes(bool sorted, std::set* s }; std::vector indexEntries; - bool debug = LibFdb5::instance().debug(); - bool walkSubTocs = true; + bool debug = LibFdb5::instance().debug(); + bool walkSubTocs = true; bool hideSubTocEntries = true; - bool hideClearEntries = true; - bool readMasked = false; + bool hideClearEntries = true; + bool readMasked = false; const TocRecord* pdata; size_t dataLength; while (readNext(*r, walkSubTocs, hideSubTocEntries, hideClearEntries, readMasked, &pdata, &dataLength)) { @@ -1392,8 +1401,9 @@ std::vector TocHandler::loadIndexes(bool sorted, std::set* s })); } - for (auto& thread : threads) + for (auto& thread : threads) { thread.get(); + } indexes.reserve(indexEntries.size()); for (TocIndex* ti : tocindexes) { @@ -1456,7 +1466,7 @@ void TocHandler::dump(std::ostream& out, bool simple, bool walkSubTocs, bool dum serialisationVersion_.used()); // allocate (large) TocRecord on heap not stack (MARS-779) bool hideSubTocEntries = false; - bool hideClearEntries = false; + bool hideClearEntries = false; bool readMasked = dumpStructure; // disabled by default, to get accurate file offsets we need to read masked data. LocalPathName parentTocPath; @@ -1552,10 +1562,10 @@ void TocHandler::dumpIndexFile(std::ostream& out, const eckit::PathName& indexFi auto r = std::make_unique( serialisationVersion_.used()); // allocate (large) TocRecord on heap not stack (MARS-779) - bool walkSubTocs = true; + bool walkSubTocs = true; bool hideSubTocEntries = true; - bool hideClearEntries = true; - bool readMasked = true; + bool hideClearEntries = true; + bool readMasked = true; while (readNext(*r, walkSubTocs, hideSubTocEntries, hideClearEntries, readMasked)) { eckit::MemoryStream s(&r->payload_[0], r->maxPayloadSize); @@ -1683,8 +1693,9 @@ void TocHandler::enumerateMasked(std::set>& metada if (maskedEntries_.find(key) != maskedEntries_.end()) { if (absPath.exists()) { Index index(new TocIndex(s, r->header_.serialisationVersion_, directory_, absPath, offset)); - for (const auto& dataURI : index.dataURIs()) + for (const auto& dataURI : index.dataURIs()) { data.insert(dataURI); + } } } } @@ -1808,7 +1819,7 @@ size_t TocHandler::buildSubTocMaskRecord(TocRecord& r) { // We use a relative path to this subtoc if it belongs to the current DB // but an absolute one otherwise (e.g. for fdb-overlay). const PathName& absPath = subTocWrite_->tocPath(); - PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; + PathName path = (absPath.dirName().sameAs(directory_)) ? absPath.baseName() : absPath; return buildSubTocMaskRecord(r, path); } @@ -1867,8 +1878,9 @@ std::vector TocHandler::lockfilePaths() const { for (const auto& name : {retrieve_lock_file, archive_lock_file, list_lock_file, wipe_lock_file}) { PathName fullPath = fullControlFilePath(name); - if (fullPath.exists()) + if (fullPath.exists()) { paths.emplace_back(std::move(fullPath)); + } } return paths; diff --git a/src/fdb5/toc/TocHandler.h b/src/fdb5/toc/TocHandler.h index e727e8861..24b147b5e 100644 --- a/src/fdb5/toc/TocHandler.h +++ b/src/fdb5/toc/TocHandler.h @@ -74,7 +74,7 @@ class TocCopyWatcher : public eckit::TransferWatcher { bool next(double& time, eckit::Length& len) { if (tocCopyStats_.size() > idx_) { time = tocCopyStats_[idx_].first; - len = tocCopyStats_[idx_].second; + len = tocCopyStats_[idx_].second; idx_++; return true; @@ -133,7 +133,7 @@ class TocHandler : public TocCommon { /// subTocs that were read to get these indexes std::vector loadIndexes(bool sorted = false, std::set* subTocs = nullptr, std::vector* indexInSubtoc = nullptr, - std::vector* remapKeys = nullptr) const; + std::vector* remapKeys = nullptr) const; Key databaseKey(); size_t numberOfRecords() const; diff --git a/src/fdb5/toc/TocIndex.cc b/src/fdb5/toc/TocIndex.cc index ff00c3782..f30454b91 100644 --- a/src/fdb5/toc/TocIndex.cc +++ b/src/fdb5/toc/TocIndex.cc @@ -98,8 +98,9 @@ void TocIndex::open() { if (!btree_) { LOG_DEBUG_LIB(LibFdb5) << "Opening " << *this << std::endl; btree_.reset(BTreeIndexFactory::build(type_, location_.path_, mode_ == TocIndex::READ, location_.offset_)); - if (mode_ == TocIndex::READ && preloadBTree_) + if (mode_ == TocIndex::READ && preloadBTree_) { btree_->preload(); + } } } diff --git a/src/fdb5/toc/TocMoveVisitor.cc b/src/fdb5/toc/TocMoveVisitor.cc index 54898c35b..31a4ab22a 100644 --- a/src/fdb5/toc/TocMoveVisitor.cc +++ b/src/fdb5/toc/TocMoveVisitor.cc @@ -57,7 +57,7 @@ bool TocMoveVisitor::visitDatabase(const Catalogue& catalogue) { while ((dp = readdir(dirp)) != NULL) { if (strstr(dp->d_name, ".index")) { eckit::PathName src_ = PathName(catalogue_.basePath()) / dp->d_name; - int fd = ::open(src_.asString().c_str(), O_RDWR); + int fd = ::open(src_.asString().c_str(), O_RDWR); if (::flock(fd, LOCK_EX)) { std::stringstream ss; ss << "Index file " << dp->d_name << " is locked"; diff --git a/src/fdb5/toc/TocPurgeVisitor.cc b/src/fdb5/toc/TocPurgeVisitor.cc index 40cc7415a..16f6b7238 100644 --- a/src/fdb5/toc/TocPurgeVisitor.cc +++ b/src/fdb5/toc/TocPurgeVisitor.cc @@ -71,8 +71,9 @@ void TocPurgeVisitor::gatherAuxiliaryURIs() { // Add auxiliary files to the corresponding set eckit::URI uri(store_.type(), eckit::PathName(it.first)); for (const auto& auxURI : store_.getAuxiliaryURIs(uri)) { - if (!store_.auxiliaryURIExists(auxURI)) + if (!store_.auxiliaryURIExists(auxURI)) { continue; + } // Todo: in future can we just use URIs, not paths? eckit::PathName auxPath = auxURI.path(); if (deletable) { diff --git a/src/fdb5/toc/TocRecord.cc b/src/fdb5/toc/TocRecord.cc index 90dea1fe8..6a562f499 100644 --- a/src/fdb5/toc/TocRecord.cc +++ b/src/fdb5/toc/TocRecord.cc @@ -31,7 +31,7 @@ TocRecord::Header::Header(unsigned int serialisationVersion, unsigned char tag) if (tag_ != TOC_NULL) { eckit::zero(*this); - tag_ = tag; + tag_ = tag; serialisationVersion_ = serialisationVersion; fdbVersion_ = ::fdb5_version_int(); @@ -42,8 +42,8 @@ TocRecord::Header::Header(unsigned int serialisationVersion, unsigned char tag) uid_ = ::getuid(); std::string host = eckit::Main::hostname(); - host = host.substr(0, host.find(".")); // guaranteed to be less than 64 chars -- seee RFC 1035 - hostname_ = host; + host = host.substr(0, host.find(".")); // guaranteed to be less than 64 chars -- seee RFC 1035 + hostname_ = host; } } diff --git a/src/fdb5/toc/TocRecord.h b/src/fdb5/toc/TocRecord.h index ff57dc054..ca2a3dede 100644 --- a/src/fdb5/toc/TocRecord.h +++ b/src/fdb5/toc/TocRecord.h @@ -40,10 +40,10 @@ struct TocRecord { /// and does not require bumping the format version (making roll-out more straightforward). enum { - TOC_NULL = 0, - TOC_INIT = 't', - TOC_INDEX = 'i', - TOC_CLEAR = 'c', + TOC_NULL = 0, + TOC_INIT = 't', + TOC_INDEX = 'i', + TOC_CLEAR = 'c', TOC_SUB_TOC = 's' }; diff --git a/src/fdb5/toc/TocSerialisationVersion.cc b/src/fdb5/toc/TocSerialisationVersion.cc index b5396b6ef..b79797c92 100644 --- a/src/fdb5/toc/TocSerialisationVersion.cc +++ b/src/fdb5/toc/TocSerialisationVersion.cc @@ -86,8 +86,9 @@ std::string TocSerialisationVersion::supportedStr() { bool TocSerialisationVersion::check(unsigned int version, bool throwOnFail) const { std::vector versionsSupported = supported(); for (auto v : versionsSupported) { - if (version == v) + if (version == v) { return true; + } } if (throwOnFail) { std::ostringstream msg; diff --git a/src/fdb5/toc/TocStats.cc b/src/fdb5/toc/TocStats.cc index dc19d3b98..1a88fdb9f 100644 --- a/src/fdb5/toc/TocStats.cc +++ b/src/fdb5/toc/TocStats.cc @@ -203,7 +203,7 @@ TocStatsReportVisitor::TocStatsReportVisitor(const TocCatalogue& catalogue, bool directory_(catalogue.basePath()), includeReferencedNonOwnedData_(includeReferenced) { currentCatalogue_ = &catalogue; - dbStats_ = catalogue.stats(); + dbStats_ = catalogue.stats(); } TocStatsReportVisitor::~TocStatsReportVisitor() {} @@ -222,10 +222,12 @@ void TocStatsReportVisitor::visitDatum(const Field& field, const std::string& fi if (!includeReferencedNonOwnedData_) { const TocCatalogue* cat = dynamic_cast(currentCatalogue_); - if (!currentIndex_->location().uri().path().dirName().sameAs(cat->basePath())) + if (!currentIndex_->location().uri().path().dirName().sameAs(cat->basePath())) { return; - if (!field.location().uri().path().dirName().sameAs(cat->basePath())) + } + if (!field.location().uri().path().dirName().sameAs(cat->basePath())) { return; + } } // If this index is not yet in the map, then create an entry @@ -243,7 +245,7 @@ void TocStatsReportVisitor::visitDatum(const Field& field, const std::string& fi stats.addFieldsCount(1); stats.addFieldsSize(len); - const eckit::PathName& dataPath = field.location().uri().path(); + const eckit::PathName& dataPath = field.location().uri().path(); const eckit::PathName& indexPath = currentIndex_->location().uri().path(); if (dataPath != lastDataPath_) { diff --git a/src/fdb5/toc/TocStore.cc b/src/fdb5/toc/TocStore.cc index 5c7266ccc..3cfe71aa7 100644 --- a/src/fdb5/toc/TocStore.cc +++ b/src/fdb5/toc/TocStore.cc @@ -134,7 +134,7 @@ size_t TocStore::flush() { // ensure consistent state before writing Toc entry flushDataHandles(); - size_t out = archivedFields_; + size_t out = archivedFields_; archivedFields_ = 0; return out; @@ -151,14 +151,16 @@ void TocStore::remove(const eckit::URI& uri, std::ostream& logAlways, std::ostre if (path.isDir()) { logVerbose << "rmdir: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.rmdir(false); + } } else { logVerbose << "Unlinking: "; logAlways << path << std::endl; - if (doit) + if (doit) { path.unlink(false); + } } } @@ -198,7 +200,7 @@ std::unique_ptr TocStore::createFileHandle(const eckit::PathN std::unique_ptr TocStore::createAsyncHandle(const eckit::PathName& path) { - static size_t nbBuffers = eckit::Resource("fdbNbAsyncBuffers", 4); + static size_t nbBuffers = eckit::Resource("fdbNbAsyncBuffers", 4); static size_t sizeBuffer = eckit::Resource("fdbSizeAsyncBuffer", 64_MiB); if (stripeLustre()) { @@ -221,8 +223,9 @@ std::unique_ptr TocStore::createDataHandle(const eckit::PathN } static bool fdbAsyncWrite = eckit::Resource("fdbAsyncWrite;$FDB_ASYNC_WRITE", false); - if (fdbAsyncWrite) + if (fdbAsyncWrite) { return createAsyncHandle(path); + } return createFileHandle(path); } @@ -249,8 +252,9 @@ eckit::PathName TocStore::generateDataPath(const Key& key) const { eckit::PathName TocStore::getDataPath(const Key& key) const { PathStore::const_iterator j = dataPaths_.find(key); - if (j != dataPaths_.end()) + if (j != dataPaths_.end()) { return j->second; + } eckit::PathName dataPath = generateDataPath(key); @@ -320,7 +324,7 @@ void TocStore::moveTo(const Key& key, const Config& config, const eckit::URI& de for (const eckit::PathName& root : StoreRootManager(config).canMoveToRoots(key)) { if (root.sameAs(destPath)) { - eckit::PathName src_db = directory_; + eckit::PathName src_db = directory_; eckit::PathName dest_db = destPath / key.valuesToString(); dest_db.mkdir(); diff --git a/src/fdb5/toc/TocWipeVisitor.cc b/src/fdb5/toc/TocWipeVisitor.cc index 86a7f383b..9e3b11ec8 100644 --- a/src/fdb5/toc/TocWipeVisitor.cc +++ b/src/fdb5/toc/TocWipeVisitor.cc @@ -48,8 +48,9 @@ class StdDir { } ~StdDir() { - if (d_) + if (d_) { closedir(d_); + } } void children(std::vector& paths) { @@ -61,8 +62,9 @@ class StdDir { while ((e = readdir(d_)) != nullptr) { if (e->d_name[0] == '.') { - if (e->d_name[1] == '\0' || (e->d_name[1] == '.' && e->d_name[2] == '\0')) + if (e->d_name[1] == '\0' || (e->d_name[1] == '.' && e->d_name[2] == '\0')) { continue; + } } eckit::PathName p(path_ / e->d_name); @@ -194,8 +196,9 @@ std::vector TocWipeVisitor::getAuxiliaryPaths(const eckit::URI& // todo: in future, we should be using URIs, not paths. std::vector paths; for (const auto& auxURI : store_.getAuxiliaryURIs(dataURI)) { - if (store_.auxiliaryURIExists(auxURI)) + if (store_.auxiliaryURIExists(auxURI)) { paths.push_back(auxURI.path()); + } } return paths; } @@ -232,7 +235,7 @@ void TocWipeVisitor::addMetadataPaths() { // toc, schema schemaPath_ = catalogue_.schemaPath().path(); - tocPath_ = catalogue_.tocPath().path(); + tocPath_ = catalogue_.tocPath().path(); // subtocs @@ -249,10 +252,12 @@ void TocWipeVisitor::ensureSafePaths() { // Very explicitly ensure that we cannot delete anything marked as safe - if (safePaths_.find(tocPath_) != safePaths_.end()) + if (safePaths_.find(tocPath_) != safePaths_.end()) { tocPath_ = ""; - if (safePaths_.find(schemaPath_) != safePaths_.end()) + } + if (safePaths_.find(schemaPath_) != safePaths_.end()) { schemaPath_ = ""; + } for (const auto& p : safePaths_) { for (std::set* s : @@ -291,11 +296,13 @@ void TocWipeVisitor::calculateResidualPaths() { } } - if (tocPath_.asString().size() && !tocPath_.exists()) + if (tocPath_.asString().size() && !tocPath_.exists()) { tocPath_ = ""; + } - if (schemaPath_.asString().size() && !schemaPath_.exists()) + if (schemaPath_.asString().size() && !schemaPath_.exists()) { schemaPath_ = ""; + } // Consider the total sets of paths @@ -303,12 +310,15 @@ void TocWipeVisitor::calculateResidualPaths() { deletePaths.insert(subtocPaths_.begin(), subtocPaths_.end()); deletePaths.insert(lockfilePaths_.begin(), lockfilePaths_.end()); deletePaths.insert(indexPaths_.begin(), indexPaths_.end()); - if (store_.type() == "file") + if (store_.type() == "file") { deletePaths.insert(dataPaths_.begin(), dataPaths_.end()); - if (tocPath_.asString().size()) + } + if (tocPath_.asString().size()) { deletePaths.insert(tocPath_); - if (schemaPath_.asString().size()) + } + if (schemaPath_.asString().size()) { deletePaths.insert(schemaPath_); + } deletePaths.insert(auxiliaryDataPaths_.begin(), auxiliaryDataPaths_.end()); std::vector allPathsVector; @@ -342,8 +352,9 @@ void TocWipeVisitor::calculateResidualPaths() { // if the store uses a backend other than POSIX (file), repeat the algorithm specialized // for its store units - if (store_.type() == "file") + if (store_.type() == "file") { return; + } std::vector allCollocatedDataURIs(store_.collocatedDataURIs()); std::vector allDataPathsVector; @@ -391,44 +402,51 @@ void TocWipeVisitor::report(bool wipeAll) { out_ << "FDB owner: " << catalogue_.owner() << std::endl << std::endl; out_ << "Toc files to delete:" << std::endl; - if (!tocPath_.asString().size() && subtocPaths_.empty()) + if (!tocPath_.asString().size() && subtocPaths_.empty()) { out_ << " - NONE -" << std::endl; - if (tocPath_.asString().size()) + } + if (tocPath_.asString().size()) { out_ << " " << tocPath_ << std::endl; + } for (const auto& f : subtocPaths_) { out_ << " " << f << std::endl; } out_ << std::endl; out_ << "Control files to delete:" << std::endl; - if (!schemaPath_.asString().size() && lockfilePaths_.empty()) + if (!schemaPath_.asString().size() && lockfilePaths_.empty()) { out_ << " - NONE -" << std::endl; - if (schemaPath_.asString().size()) + } + if (schemaPath_.asString().size()) { out_ << " " << schemaPath_ << std::endl; + } for (const auto& f : lockfilePaths_) { out_ << " " << f << std::endl; } out_ << std::endl; out_ << "Index files to delete: " << std::endl; - if (indexPaths_.empty()) + if (indexPaths_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& f : indexPaths_) { out_ << " " << f << std::endl; } out_ << std::endl; out_ << "Data files to delete: " << std::endl; - if (dataPaths_.empty()) + if (dataPaths_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& f : dataPaths_) { out_ << " " << f << std::endl; } out_ << std::endl; out_ << "Auxiliary files to delete: " << std::endl; - if (auxiliaryDataPaths_.empty()) + if (auxiliaryDataPaths_.empty()) { out_ << " - NONE -" << std::endl; + } for (const auto& f : auxiliaryDataPaths_) { out_ << " " << f << std::endl; } @@ -446,8 +464,9 @@ void TocWipeVisitor::report(bool wipeAll) { } out_ << "Protected files (explicitly untouched):" << std::endl; - if (safePaths_.empty()) + if (safePaths_.empty()) { out_ << " - NONE - " << std::endl; + } for (const auto& f : safePaths_) { out_ << " " << f << std::endl; } @@ -455,8 +474,9 @@ void TocWipeVisitor::report(bool wipeAll) { if (!safePaths_.empty()) { out_ << "Indexes to mask:" << std::endl; - if (indexesToMask_.empty()) + if (indexesToMask_.empty()) { out_ << " - NONE - " << std::endl; + } for (const auto& i : indexesToMask_) { out_ << " " << i.location() << std::endl; } @@ -498,8 +518,9 @@ void TocWipeVisitor::wipe(bool wipeAll) { for (const auto& index : indexesToMask_) { logVerbose << "Index to mask: "; logAlways << index << std::endl; - if (doit_) + if (doit_) { catalogue_.maskIndexEntry(index); + } } } @@ -534,10 +555,11 @@ void TocWipeVisitor::wipe(bool wipeAll) { } } - if (wipeAll && store_.type() != "file") + if (wipeAll && store_.type() != "file") { /// @todo: if the store is holding catalogue information (e.g. daos KVs) it /// should not be removed store_.remove(store_.uri(), logAlways, logVerbose, doit_); + } for (const std::set& pathset : {indexPaths_, std::set{schemaPath_}, subtocPaths_, std::set{tocPath_}, lockfilePaths_, @@ -568,44 +590,50 @@ void TocWipeVisitor::catalogueComplete(const Catalogue& catalogue) { // Ensure we _really_ don't delete these if not wiping everything subtocPaths_.clear(); lockfilePaths_.clear(); - tocPath_ = ""; + tocPath_ = ""; schemaPath_ = ""; } ensureSafePaths(); if (anythingToWipe()) { - if (wipeAll) + if (wipeAll) { calculateResidualPaths(); + } - if (!porcelain_) + if (!porcelain_) { report(wipeAll); + } // This is here as it needs to run whatever combination of doit/porcelain/... if (wipeAll && !residualPaths_.empty()) { out_ << "Unexpected files present in directory: " << std::endl; - for (const auto& p : residualPaths_) + for (const auto& p : residualPaths_) { out_ << " " << p << std::endl; + } out_ << std::endl; } if (wipeAll && !residualDataPaths_.empty()) { out_ << "Unexpected store units present in store: " << std::endl; - for (const auto& p : residualDataPaths_) + for (const auto& p : residualDataPaths_) { out_ << " " << store_.type() << "://" << p << std::endl; + } out_ << std::endl; } if (wipeAll && (!residualPaths_.empty() || !residualDataPaths_.empty())) { if (!unsafeWipeAll_) { out_ << "Full wipe will not proceed without --unsafe-wipe-all" << std::endl; - if (doit_) + if (doit_) { throw Exception("Cannot fully wipe unclean TocDB", Here()); + } } } - if (doit_ || porcelain_) + if (doit_ || porcelain_) { wipe(wipeAll); + } } } diff --git a/src/fdb5/tools/FDBLock.cc b/src/fdb5/tools/FDBLock.cc index 6e3ee0487..5082c0326 100644 --- a/src/fdb5/tools/FDBLock.cc +++ b/src/fdb5/tools/FDBLock.cc @@ -70,14 +70,18 @@ void FDBLock::execute(const CmdArgs& args) { ControlAction action = unlock_ ? ControlAction::Enable : ControlAction::Disable; ControlIdentifiers identifiers; - if (list_) + if (list_) { identifiers |= ControlIdentifier::List; - if (retrieve_) + } + if (retrieve_) { identifiers |= ControlIdentifier::Retrieve; - if (archive_) + } + if (archive_) { identifiers |= ControlIdentifier::Archive; - if (wipe_) + } + if (wipe_) { identifiers |= ControlIdentifier::Wipe; + } for (const FDBToolRequest& request : requests("read")) { @@ -89,16 +93,21 @@ void FDBLock::execute(const CmdArgs& args) { Log::info() << "Database: " << elem.key << std::endl << " location: " << elem.location.asString() << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Retrieve)) + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Retrieve)) { Log::info() << " retrieve: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Archive)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Archive)) { Log::info() << " archive: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::List)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::List)) { Log::info() << " list: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Wipe)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Wipe)) { Log::info() << " wipe: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::UniqueRoot)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::UniqueRoot)) { Log::info() << " multi-root: PERMITTED" << std::endl; + } count++; } diff --git a/src/fdb5/tools/FDBVisitTool.cc b/src/fdb5/tools/FDBVisitTool.cc index 0c962557f..6182fb78d 100644 --- a/src/fdb5/tools/FDBVisitTool.cc +++ b/src/fdb5/tools/FDBVisitTool.cc @@ -67,7 +67,7 @@ void FDBVisitTool::init(const option::CmdArgs& args) { args.get("minimum-keys", minimumKeys_); bool ignore = args.getBool("ignore-errors", false); - fail_ = !ignore; + fail_ = !ignore; all_ = args.getBool("all", false); diff --git a/src/fdb5/tools/fdb-axes.cc b/src/fdb5/tools/fdb-axes.cc index aeecbfde7..e371b01dc 100644 --- a/src/fdb5/tools/fdb-axes.cc +++ b/src/fdb5/tools/fdb-axes.cc @@ -47,7 +47,7 @@ class FDBAxisTest : public FDBVisitTool { void FDBAxisTest::init(const CmdArgs& args) { FDBVisitTool::init(args); - json_ = args.getBool("json", json_); + json_ = args.getBool("json", json_); level_ = args.getInt("level", level_); } diff --git a/src/fdb5/tools/fdb-copy.cc b/src/fdb5/tools/fdb-copy.cc index fd8c49e77..107fd745a 100644 --- a/src/fdb5/tools/fdb-copy.cc +++ b/src/fdb5/tools/fdb-copy.cc @@ -33,9 +33,9 @@ namespace fdb5::tools { class FDBCopy : public fdb5::tools::FDBVisitTool { - bool verbose_ = false; + bool verbose_ = false; bool fromList_ = false; - bool sort_ = false; + bool sort_ = false; std::string modifiers_; @@ -92,9 +92,9 @@ void FDBCopy::init(const CmdArgs& args) { args.get("modifiers", modifiers_); - verbose_ = args.getBool("verbose", verbose_); + verbose_ = args.getBool("verbose", verbose_); fromList_ = args.getBool("from-list", fromList_); - sort_ = args.getBool("sort", sort_); + sort_ = args.getBool("sort", sort_); std::string from = args.getString("source"); if (from.empty()) { @@ -126,8 +126,9 @@ static std::vector readRequestsFromFile(const CmdArgs auto parsedRequests = parser.parse(); if (args.getBool("raw", false)) { - for (auto r : parsedRequests) + for (auto r : parsedRequests) { requests.push_back(r); + } } else { const bool inherit = false; @@ -151,7 +152,7 @@ void FDBCopy::checkModifiers(const metkit::mars::MarsRequest& request, const eck void FDBCopy::execute(const CmdArgs& args) { - fdb5::Config readConfig = fdb5::Config::make(sourceConfig_); + fdb5::Config readConfig = fdb5::Config::make(sourceConfig_); fdb5::Config writeConfig = fdb5::Config::make(targetConfig_); fdb5::HandleGatherer handles(sort_); @@ -164,7 +165,7 @@ void FDBCopy::execute(const CmdArgs& args) { for (const FDBToolRequest& request : requests("list")) { checkModifiers(request.request(), modifiers); bool deduplicate = true; - auto listObject = fdbRead.list(request, deduplicate); + auto listObject = fdbRead.list(request, deduplicate); handles.add(fdbRead.read(listObject, sort_)); } } diff --git a/src/fdb5/tools/fdb-dump-toc.cc b/src/fdb5/tools/fdb-dump-toc.cc index 72ceed1fd..915533bf9 100644 --- a/src/fdb5/tools/fdb-dump-toc.cc +++ b/src/fdb5/tools/fdb-dump-toc.cc @@ -45,7 +45,7 @@ void FDBDumpToc::usage(const std::string& tool) const { void FDBDumpToc::execute(const eckit::option::CmdArgs& args) { - bool walkSubTocs = args.getBool("walk", false); + bool walkSubTocs = args.getBool("walk", false); bool dumpStructure = args.getBool("structure", false); for (size_t i = 0; i < args.count(); i++) { diff --git a/src/fdb5/tools/fdb-hammer.cc b/src/fdb5/tools/fdb-hammer.cc index 4187ea704..bcc787eaa 100644 --- a/src/fdb5/tools/fdb-hammer.cc +++ b/src/fdb5/tools/fdb-hammer.cc @@ -216,16 +216,16 @@ class HammerVerifier { explicit StoredDigest(const MD5& md5) { auto digest = md5.digest(); - hi_ = std::stoull(digest.substr(0, 8), nullptr, 16); - lo_ = std::stoull(digest.substr(8, 16), nullptr, 16); + hi_ = std::stoull(digest.substr(0, 8), nullptr, 16); + lo_ = std::stoull(digest.substr(8, 16), nullptr, 16); } bool operator==(const StoredDigest& other) const { return hi_ == other.hi_ && lo_ == other.lo_; } void store(char* data) const { auto p = reinterpret_cast(data); - p[0] = hi_; - p[1] = lo_; + p[0] = hi_; + p[1] = lo_; } static StoredDigest load(const char* data) { @@ -287,7 +287,7 @@ class HammerVerifier { } void storeVerificationData(long step, long member, long level, long param, char* data, size_t dataSize) { - auto key_digest = constructKeyDigest(step, member, level, param); + auto key_digest = constructKeyDigest(step, member, level, param); auto unique_digest = constructUniqueDigest(); if (mdCheck_) { storeMDVerificationData(key_digest, unique_digest, data, dataSize); @@ -353,10 +353,10 @@ class HammerVerifier { auto key_digest = StoredDigest(MD5(std::string(key))); long offsetBeforeData = msg.getLong("offsetBeforeData"); - long offsetAfterData = msg.getLong("offsetAfterData"); + long offsetAfterData = msg.getLong("offsetAfterData"); const char* data = &static_cast(msg.data())[offsetBeforeData]; - size_t dataSize = offsetAfterData - offsetBeforeData; + size_t dataSize = offsetAfterData - offsetBeforeData; if (mdCheck_) { verifyMDVerificationData(key_digest, data, dataSize, key.empty()); @@ -385,7 +385,7 @@ class HammerVerifier { ASSERT(dataSize > (sizeof(CheckType) + 4 * sizeof(StoredDigest))); auto p = reinterpret_cast(data); - p[0] = static_cast(CheckType::MD_CHECK); + p[0] = static_cast(CheckType::MD_CHECK); key_digest.store(data + sizeof(CheckType)); unique_digest.store(data + sizeof(CheckType) + sizeof(StoredDigest)); key_digest.store(data + dataSize - 2 * sizeof(StoredDigest)); @@ -398,7 +398,7 @@ class HammerVerifier { ASSERT(dataSize > (sizeof(CheckType) + 3 * sizeof(StoredDigest))); auto p = reinterpret_cast(data); - p[0] = static_cast(CheckType::FULL_CHECK); + p[0] = static_cast(CheckType::FULL_CHECK); key_digest.store(data + sizeof(CheckType)); // Construct a checksum over data including the unique digest @@ -419,10 +419,10 @@ class HammerVerifier { auto p = reinterpret_cast(data); ASSERT(p[0] == static_cast(CheckType::MD_CHECK)); - auto key_digest1 = StoredDigest::load(data + sizeof(CheckType)); + auto key_digest1 = StoredDigest::load(data + sizeof(CheckType)); auto unique_digest1 = StoredDigest::load(data + sizeof(CheckType) + sizeof(StoredDigest)); - auto key_digest2 = StoredDigest::load(data + dataSize - 2 * sizeof(StoredDigest)); + auto key_digest2 = StoredDigest::load(data + dataSize - 2 * sizeof(StoredDigest)); auto unique_digest2 = StoredDigest::load(data + dataSize - sizeof(StoredDigest)); if (!noKey) { @@ -446,7 +446,7 @@ class HammerVerifier { dataSize - sizeof(CheckType) - 2 * sizeof(StoredDigest)); StoredDigest checksum_digest(md5); - auto key_digest_stored = StoredDigest::load(data + sizeof(CheckType)); + auto key_digest_stored = StoredDigest::load(data + sizeof(CheckType)); auto checksum_digest_stored = StoredDigest::load(data + sizeof(CheckType) + sizeof(StoredDigest)); if (!noKey) { @@ -667,7 +667,7 @@ std::vector HammerConfig::parseLevelist(const eckit::option::CmdArgs& args } } else { - long level = args.getLong("level", 0); + long level = args.getLong("level", 0); long nlevels = args.getLong("nlevels"); levelist.reserve(nlevels); for (long i = 0; i < nlevels; ++i) { @@ -710,7 +710,7 @@ std::vector HammerConfig::parseEnsemblelist(const eckit::option::CmdArgs& std::vector HammerConfig::parseSteplist(const eckit::option::CmdArgs& args) { long baseStep = args.getLong("step", 0); - long nsteps = args.getLong("nsteps"); + long nsteps = args.getLong("nsteps"); std::vector steplist; steplist.reserve(nsteps); @@ -763,7 +763,7 @@ metkit::mars::MarsRequest HammerConfig::templateRequest() const { class FDBHammer : public fdb5::FDBTool { struct ReadStats { - size_t totalRead = 0; + size_t totalRead = 0; size_t fieldsRead = 0; Timer totalTimer; Timer readTimer; @@ -919,8 +919,9 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma int fd; fd = ::open(pid_file.localPath(), O_EXCL | O_CREAT | O_WRONLY, 0666); - if (fd < 0 && errno != EEXIST) + if (fd < 0 && errno != EEXIST) { throw eckit::FailedSystemCall("open", Here(), errno); + } if (fd >= 0) { @@ -929,12 +930,14 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma /// a pair of FIFOs are created. One for clients to communicate the leader they are /// waiting, and another to open in blocking mode until leader opens it for write /// once it has synchronised with peer nodes - if (wait_fifo.exists()) + if (wait_fifo.exists()) { wait_fifo.unlink(); + } SYSCALL(::mkfifo(wait_fifo.localPath(), 0666)); - if (barrier_fifo.exists()) + if (barrier_fifo.exists()) { barrier_fifo.unlink(); + } SYSCALL(::mkfifo(barrier_fifo.localPath(), 0666)); /// the leader PID is written into the file @@ -987,7 +990,7 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma eckit::AutoClose closer(*fh_barrier); /// if the inter-node barrier failed, notify the clients via the barrier fifo if (eptr) { - message = {'S', 'I', 'G'}; + message = {'S', 'I', 'G'}; size_t pending = ppn - 1; while (pending > 0) { ASSERT(fh_barrier->write(&message[0], message.size()) == message.size()); @@ -1002,8 +1005,9 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma pid_file.unlink(false); /// throw if the inter-node barrier failed - if (eptr) + if (eptr) { std::rethrow_exception(eptr); + } } else { @@ -1036,8 +1040,9 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma pid_file.unlink(); } catch (eckit::FailedSystemCall& e) { - if (errno != ENOENT) + if (errno != ENOENT) { throw; + } } continue; } @@ -1054,7 +1059,7 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma /// check for any errors reported by leader std::vector message = {'0', '0', '0'}; - long bytes = fh_barrier.read(&message[0], message.size()); + long bytes = fh_barrier.read(&message[0], message.size()); if (bytes > 0) { ASSERT(bytes == message.size()); ASSERT(std::string(message.begin(), message.end()) == "SIG"); @@ -1077,8 +1082,9 @@ void barrier(size_t ppn, const std::vector& nodes, int port, int ma eckit::AutoClose closer(*fh_wait); ASSERT(fh_wait->write(&message[0], message.size()) == message.size()); - if (!future.get()) + if (!future.get()) { throw eckit::Exception("Error receiving response from barrier leader process."); + } } leader_found = true; @@ -1168,11 +1174,11 @@ void FDBHammer::executeWrite() { eckit::Timer timer; eckit::Timer gribTimer; double elapsed_grib = 0; - size_t writeCount = 0; + size_t writeCount = 0; size_t bytesWritten = 0; - int total_slept = 0; + int total_slept = 0; - uint32_t random_seed = generateRandomUint32(); + uint32_t random_seed = generateRandomUint32(); long offsetBeforeData = 0, offsetAfterData = 0, numberOfValues = 0; // get message data offset @@ -1223,15 +1229,18 @@ void FDBHammer::executeWrite() { for (const auto& ilevel : config_.request.levelist) { CODES_CHECK(codes_set_long(handle, "level", ilevel), 0); - if (iter_count > config_.iteration.stopAtChunk) + if (iter_count > config_.iteration.stopAtChunk) { break; + } for (const auto& iparam : config_.request.paramlist) { - if (iter_count > config_.iteration.stopAtChunk) + if (iter_count > config_.iteration.stopAtChunk) { break; - if (iter_count++ < config_.iteration.startAtChunk) + } + if (iter_count++ < config_.iteration.startAtChunk) { continue; + } if (config_.interface.verbose) { Log::info() << "Member: " << imember << ", step: " << istep << ", level: " << ilevel @@ -1274,8 +1283,9 @@ void FDBHammer::executeWrite() { MemoryHandle dh(buffer, messageSize); if (imember == config_.request.ensemblelist.front() && istep == config_.request.steplist.front() && - (iter_count - 1 == config_.iteration.startAtChunk)) + (iter_count - 1 == config_.iteration.startAtChunk)) { gettimeofday(&tval_before_io, NULL); + } archiver.archive(dh); writeCount++; bytesWritten += messageSize; @@ -1287,8 +1297,9 @@ void FDBHammer::executeWrite() { gribTimer.stop(); elapsed_grib += gribTimer.elapsed(); archiver.flush(); - if (imember == config_.request.ensemblelist.back() && istep == config_.request.steplist.back()) + if (imember == config_.request.ensemblelist.back() && istep == config_.request.steplist.back()) { gettimeofday(&tval_after_io, NULL); + } gribTimer.start(); } @@ -1334,8 +1345,9 @@ void FDBHammer::executeWrite() { << std::setfill('0') << (long int)tval_before_io.tv_usec << std::endl; Log::info() << "Timestamp after last IO: " << (long int)tval_after_io.tv_sec << "." << std::setw(6) << std::setfill('0') << (long int)tval_after_io.tv_usec << std::endl; - if (config_.execution.itt) + if (config_.execution.itt) { Log::info() << "Average time slept per step: " << total_slept / config_.request.steplist.size() << std::endl; + } } std::pair, std::deque> FDBHammer::constructReadData(std::optional& fdb, @@ -1388,8 +1400,9 @@ std::pair, std::deque> FDBHammer::constructRead // But ... the expected keys ARE NOT KNOWN. So fill with empty keys, and ignore their value. std::deque expected_keys; - for (const auto& _ : uris) + for (const auto& _ : uris) { expected_keys.emplace_back(Key{}); + } /* for (const auto& istep : config_.request.steplist) { @@ -1440,16 +1453,19 @@ std::pair, std::deque> FDBHammer::constructRead for (const auto& ilevel : config_.request.levelist) { request.setValue("levelist", ilevel); - if (iter_count > config_.iteration.stopAtChunk) + if (iter_count > config_.iteration.stopAtChunk) { break; + } for (const auto& iparam : config_.request.paramlist) { request.setValue("param", iparam); - if (iter_count > config_.iteration.stopAtChunk) + if (iter_count > config_.iteration.stopAtChunk) { break; - if (iter_count++ < config_.iteration.startAtChunk) + } + if (iter_count++ < config_.iteration.startAtChunk) { continue; + } if (config_.interface.verbose) { Log::info() << "Member: " << imember << ", step: " << istep << ", level: " << ilevel @@ -1474,9 +1490,9 @@ std::pair, std::deque> FDBHammer::constructRead // Mutable versions of the config lists, so that we can manipulate them before the run - auto levelist = to_stringvec(config_.request.levelist); + auto levelist = to_stringvec(config_.request.levelist); const size_t nlevels = levelist.size(); - auto paramlist = to_stringvec(config_.request.paramlist); + auto paramlist = to_stringvec(config_.request.paramlist); const size_t nparams = paramlist.size(); // Build the list request(s) matching the whole domain, @@ -1491,7 +1507,7 @@ std::pair, std::deque> FDBHammer::constructRead to_stringvec(config_.request.ensemblelist)); size_t first_level = config_.iteration.startAtChunk / nparams; - size_t last_level = config_.iteration.stopAtChunk / nparams; + size_t last_level = config_.iteration.stopAtChunk / nparams; if (config_.iteration.startAtChunk > 0 && config_.iteration.stopAtChunk < nlevels * nparams - 1 && first_level == last_level) { @@ -1570,8 +1586,9 @@ std::pair, std::deque> FDBHammer::constructRead } if (config_.interface.verbose) { - for (auto& mars_list_request : mars_list_requests) + for (auto& mars_list_request : mars_list_requests) { eckit::Log::info() << "Attempting list of " << mars_list_request << std::endl; + } } size_t expected = 0; @@ -1583,7 +1600,7 @@ std::pair, std::deque> FDBHammer::constructRead std::vector uris; std::deque step_expected_keys; - bool dataReady = false; + bool dataReady = false; size_t attempts = 0; while (!dataReady) { @@ -1596,8 +1613,9 @@ std::pair, std::deque> FDBHammer::constructRead auto listObject = fdb->list(list_request, true); fdb5::ListElement info; while (listObject.next(info)) { - if (config_.interface.verbose) + if (config_.interface.verbose) { Log::info() << info.keys()[2] << std::endl; + } uris.push_back(info.location().fullUri()); fdb5::Key key = info.combinedKey(); @@ -1617,10 +1635,11 @@ std::pair, std::deque> FDBHammer::constructRead if (config_.interface.verbose) { eckit::Log::info() << "Expected " << expected << ", found " << count << std::endl; } - if (attempts >= config_.timing.pollMaxAttempts) + if (attempts >= config_.timing.pollMaxAttempts) { throw eckit::Exception(std::string("List maximum attempts (") + eckit::Translator()(config_.timing.pollMaxAttempts) + ") exceeded"); + } ::sleep(config_.timing.pollPeriod); stats.listTimer.start(); fdb.emplace(config_.fdbConfig); diff --git a/src/fdb5/tools/fdb-hide.cc b/src/fdb5/tools/fdb-hide.cc index 190f35924..bbdd8c0fa 100644 --- a/src/fdb5/tools/fdb-hide.cc +++ b/src/fdb5/tools/fdb-hide.cc @@ -90,7 +90,7 @@ void FdbHide::execute(const CmdArgs& args) { eckit::Log::info() << "Hide contents of DB: " << *db << std::endl; if (doit_) { auto dbWriter = CatalogueWriterFactory::instance().build(key, conf); - auto* tocDB = dynamic_cast(dbWriter.get()); + auto* tocDB = dynamic_cast(dbWriter.get()); tocDB->hideContents(); } else { diff --git a/src/fdb5/tools/fdb-info.cc b/src/fdb5/tools/fdb-info.cc index bdec74cdd..8cc0ea88b 100644 --- a/src/fdb5/tools/fdb-info.cc +++ b/src/fdb5/tools/fdb-info.cc @@ -75,11 +75,11 @@ void FDBInfo::usage(const std::string& tool) const { } void FDBInfo::init(const eckit::option::CmdArgs& args) { - all_ = args.getBool("all", false); - version_ = args.getBool("version", false); - home_ = args.getBool("home", false); - schema_ = args.getBool("schema", false); - config_ = args.getBool("config-file", false); + all_ = args.getBool("all", false); + version_ = args.getBool("version", false); + home_ = args.getBool("home", false); + schema_ = args.getBool("schema", false); + config_ = args.getBool("config-file", false); lustreApi_ = args.getBool("lustre-api", false); } @@ -87,29 +87,33 @@ void FDBInfo::execute(const eckit::option::CmdArgs& args) { if (all_ || version_) { Log::info() << (all_ ? "Version: " : "") << fdb5_version_str() << std::endl; - if (!all_) + if (!all_) { return; + } } if (all_ || home_) { // print FDB_HOME and exit -- note that is used in the bin/fdb wrapper script Log::info() << (all_ ? "Home: " : "") << eckit::PathName("~fdb/") << std::endl; - if (!all_) + if (!all_) { return; + } } Config conf = config(args); if (all_ || schema_) { Log::info() << (all_ ? "Schema: " : "") << conf.schemaPath() << std::endl; - if (!all_) + if (!all_) { return; + } } if (all_ || config_) { Log::info() << (all_ ? "Config: " : "") << conf.configPath() << std::endl; - if (!all_) + if (!all_) { return; + } } if (all_ || lustreApi_) { diff --git a/src/fdb5/tools/fdb-inspect.cc b/src/fdb5/tools/fdb-inspect.cc index 766fdd2fc..6c2a15af5 100644 --- a/src/fdb5/tools/fdb-inspect.cc +++ b/src/fdb5/tools/fdb-inspect.cc @@ -101,7 +101,7 @@ void printHeader(const FDBToolRequest& request) { } void FDBInspectTool::execute(const eckit::option::CmdArgs& args) { - const auto fdbConfig = config(args); + const auto fdbConfig = config(args); const auto toolRequests = requests(); eckit::Log::info() << "Number of requests: " << toolRequests.size() << std::endl; diff --git a/src/fdb5/tools/fdb-list.cc b/src/fdb5/tools/fdb-list.cc index 833acf875..c0bac616e 100644 --- a/src/fdb5/tools/fdb-list.cc +++ b/src/fdb5/tools/fdb-list.cc @@ -79,14 +79,14 @@ void FDBList::init(const CmdArgs& args) { FDBVisitTool::init(args); - location_ = args.getBool("location", location_); + location_ = args.getBool("location", location_); timestamp_ = args.getBool("timestamp", timestamp_); - length_ = args.getBool("length", length_); - full_ = args.getBool("full", full_); + length_ = args.getBool("length", length_); + full_ = args.getBool("full", full_); porcelain_ = args.getBool("porcelain", porcelain_); - json_ = args.getBool("json", json_); - compact_ = args.getBool("compact", compact_); - depth_ = args.getInt("depth", depth_); + json_ = args.getBool("json", json_); + compact_ = args.getBool("compact", compact_); + depth_ = args.getInt("depth", depth_); ASSERT(depth_ > 0 && depth_ < 4); diff --git a/src/fdb5/tools/fdb-move.cc b/src/fdb5/tools/fdb-move.cc index a4157517c..6c08cf348 100644 --- a/src/fdb5/tools/fdb-move.cc +++ b/src/fdb5/tools/fdb-move.cc @@ -53,7 +53,7 @@ class MoveProducer : public eckit::distributed::Producer { const std::vector& requests, const eckit::option::CmdArgs& args) : eckit::distributed::Producer(transport), fdb_(config), keep_(false), removeDelay_(0) { - keep_ = args.getBool("keep", false); + keep_ = args.getBool("keep", false); removeDelay_ = args.getInt("delay", 0); eckit::URI destination; @@ -68,7 +68,7 @@ class MoveProducer : public eckit::distributed::Producer { } fdb5::FDBToolRequest request = metkit::mars::MarsRequest(); - size_t count = 0; + size_t count = 0; for (const FDBToolRequest& toolReq : requests) { if (count) { std::stringstream ss; @@ -84,7 +84,7 @@ class MoveProducer : public eckit::distributed::Producer { // check that the request is only referring a single DB - no ranges of values const metkit::mars::MarsRequest& marsReq = toolReq.request(); - std::vector params = marsReq.params(); + std::vector params = marsReq.params(); for (const std::string& param : params) { const std::vector& values = marsReq.values(param); diff --git a/src/fdb5/tools/fdb-overlay.cc b/src/fdb5/tools/fdb-overlay.cc index cbf44af48..e953c6adc 100644 --- a/src/fdb5/tools/fdb-overlay.cc +++ b/src/fdb5/tools/fdb-overlay.cc @@ -65,7 +65,7 @@ void FdbOverlay::init(const CmdArgs& args) { FDBTool::init(args); args.get("variable-keys", variableKeys_); remove_ = args.getBool("remove", remove_); - force_ = args.getBool("force", force_); + force_ = args.getBool("force", force_); } void FdbOverlay::execute(const CmdArgs& args) { @@ -77,7 +77,7 @@ void FdbOverlay::execute(const CmdArgs& args) { return; } - bool injectDomain = false; + bool injectDomain = false; std::vector sources = parse(args(0), conf); ASSERT(!sources.empty()); diff --git a/src/fdb5/tools/fdb-purge.cc b/src/fdb5/tools/fdb-purge.cc index 971ff932a..01119b41f 100644 --- a/src/fdb5/tools/fdb-purge.cc +++ b/src/fdb5/tools/fdb-purge.cc @@ -55,8 +55,8 @@ class FDBPurge : public FDBVisitTool { void FDBPurge::init(const CmdArgs& args) { FDBVisitTool::init(args); - doit_ = args.getBool("doit", false); - porcelain_ = args.getBool("porcelain", false); + doit_ = args.getBool("doit", false); + porcelain_ = args.getBool("porcelain", false); ignoreNoData_ = args.getBool("ignore-no-data", false); } diff --git a/src/fdb5/tools/fdb-read.cc b/src/fdb5/tools/fdb-read.cc index c1763a56b..1c1516d08 100644 --- a/src/fdb5/tools/fdb-read.cc +++ b/src/fdb5/tools/fdb-read.cc @@ -51,7 +51,7 @@ void FDBRead::usage(const std::string& tool) const { void FDBRead::execute(const eckit::option::CmdArgs& args) { bool extract = args.getBool("extract", false); - bool raw = args.getBool("raw", false); + bool raw = args.getBool("raw", false); std::vector requests; @@ -73,8 +73,9 @@ void FDBRead::execute(const eckit::option::CmdArgs& args) { metkit::mars::MarsParser parser(in); auto parsedRequests = parser.parse(); if (raw) { - for (auto r : parsedRequests) + for (auto r : parsedRequests) { requests.push_back(r); + } } else { metkit::mars::MarsExpansion expand(/* inherit */ false); diff --git a/src/fdb5/tools/fdb-reindex.cc b/src/fdb5/tools/fdb-reindex.cc index a2134df63..cf8774439 100644 --- a/src/fdb5/tools/fdb-reindex.cc +++ b/src/fdb5/tools/fdb-reindex.cc @@ -58,7 +58,7 @@ void FDBReindex::init(const CmdArgs& args) { FDBVisitTool::init(args); source_config_ = args.getString("source-config", ""); - sink_config_ = args.getString("sink-config", ""); + sink_config_ = args.getString("sink-config", ""); // not optional if (source_config_.empty() || sink_config_.empty()) { @@ -86,8 +86,8 @@ void FDBReindex::execute(const CmdArgs& args) { while (it.next(elem)) { LOG_DEBUG_LIB(LibFdb5) << "Reindexing ListElement: " << elem << std::endl; - const FieldLocation& location = elem.location(); - const Key& key = elem.combinedKey(); + const FieldLocation& location = elem.location(); + const Key& key = elem.combinedKey(); ListElement::TimeStamp timestamp = elem.timestamp(); // Only reindex if the timestamp is newer than the one we have. diff --git a/src/fdb5/tools/fdb-stats.cc b/src/fdb5/tools/fdb-stats.cc index 9ccb3e4f7..441522791 100644 --- a/src/fdb5/tools/fdb-stats.cc +++ b/src/fdb5/tools/fdb-stats.cc @@ -74,7 +74,7 @@ void FDBStats::execute(const CmdArgs& args) { if (count == 0) { totalIndexStats = elem.indexStatistics; - totaldbStats = elem.dbStatistics; + totaldbStats = elem.dbStatistics; } else { totalIndexStats += elem.indexStatistics; diff --git a/src/fdb5/tools/fdb-status.cc b/src/fdb5/tools/fdb-status.cc index c7561979a..995a8c23c 100644 --- a/src/fdb5/tools/fdb-status.cc +++ b/src/fdb5/tools/fdb-status.cc @@ -50,16 +50,21 @@ void FDBStatus::execute(const CmdArgs& args) { Log::info() << "Database: " << elem.key << std::endl << " location: " << elem.location.asString() << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Retrieve)) + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Retrieve)) { Log::info() << " retrieve: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Archive)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Archive)) { Log::info() << " archive: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::List)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::List)) { Log::info() << " list: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::Wipe)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::Wipe)) { Log::info() << " wipe: LOCKED" << std::endl; - if (!elem.controlIdentifiers.enabled(ControlIdentifier::UniqueRoot)) + } + if (!elem.controlIdentifiers.enabled(ControlIdentifier::UniqueRoot)) { Log::info() << " multi-root: PERMITTED" << std::endl; + } count++; } diff --git a/src/fdb5/tools/fdb-wipe.cc b/src/fdb5/tools/fdb-wipe.cc index 4952d0396..ebbcb8934 100644 --- a/src/fdb5/tools/fdb-wipe.cc +++ b/src/fdb5/tools/fdb-wipe.cc @@ -73,9 +73,9 @@ void FDBWipe::init(const CmdArgs& args) { FDBVisitTool::init(args); - doit_ = args.getBool("doit", false); - ignoreNoData_ = args.getBool("ignore-no-data", false); - porcelain_ = args.getBool("porcelain", false); + doit_ = args.getBool("doit", false); + ignoreNoData_ = args.getBool("ignore-no-data", false); + porcelain_ = args.getBool("porcelain", false); unsafeWipeAll_ = args.getBool("unsafe-wipe-all", false); } diff --git a/src/fdb5/tools/fdb-write.cc b/src/fdb5/tools/fdb-write.cc index 610a10c3a..25daff20b 100644 --- a/src/fdb5/tools/fdb-write.cc +++ b/src/fdb5/tools/fdb-write.cc @@ -79,7 +79,7 @@ void FDBWrite::init(const eckit::option::CmdArgs& args) { args.get("exclude-filter", filterExclude_); args.get("modifiers", modifiers_); archivers_ = args.getLong("archivers", 1); - verbose_ = args.getBool("verbose", false); + verbose_ = args.getBool("verbose", false); } void FDBWrite::execute(const eckit::option::CmdArgs& args) { diff --git a/src/fdb5/types/TypeDouble.cc b/src/fdb5/types/TypeDouble.cc index 619c5f609..851a42dec 100644 --- a/src/fdb5/types/TypeDouble.cc +++ b/src/fdb5/types/TypeDouble.cc @@ -24,7 +24,7 @@ TypeDouble::TypeDouble(const std::string& name, const std::string& type) : Type( TypeDouble::~TypeDouble() {} std::string TypeDouble::toKey(const std::string& value) const { - double v = eckit::Translator()(value); + double v = eckit::Translator()(value); long long ll = static_cast(v); if (ll == v) { diff --git a/src/fdb5/types/TypesFactory.cc b/src/fdb5/types/TypesFactory.cc index 603c571db..508fbb625 100644 --- a/src/fdb5/types/TypesFactory.cc +++ b/src/fdb5/types/TypesFactory.cc @@ -23,12 +23,12 @@ namespace fdb5 { //---------------------------------------------------------------------------------------------------------------------- -static eckit::Mutex* local_mutex = 0; +static eckit::Mutex* local_mutex = 0; static std::map* m = 0; -static pthread_once_t once = PTHREAD_ONCE_INIT; +static pthread_once_t once = PTHREAD_ONCE_INIT; static void init() { local_mutex = new eckit::Mutex(); - m = new std::map(); + m = new std::map(); } //---------------------------------------------------------------------------------------------------------------------- @@ -42,8 +42,9 @@ TypesFactory::TypesFactory(const std::string& name) : name_(name) { } TypesFactory::~TypesFactory() { - if (LibFdb5::instance().dontDeregisterFactories()) + if (LibFdb5::instance().dontDeregisterFactories()) { return; + } eckit::AutoLock lock(local_mutex); m->erase(name_); } @@ -57,8 +58,9 @@ Type* TypesFactory::build(const std::string& name, const std::string& keyword) { if (j == m->end()) { eckit::Log::error() << "No TypesFactory for [" << name << "]" << std::endl; eckit::Log::error() << "KeywordTypes are:" << std::endl; - for (j = m->begin(); j != m->end(); ++j) + for (j = m->begin(); j != m->end(); ++j) { eckit::Log::error() << " " << (*j).first << std::endl; + } throw eckit::SeriousBug(std::string("No TypesFactory called ") + name); } diff --git a/src/fdb5/types/TypesRegistry.cc b/src/fdb5/types/TypesRegistry.cc index eca33394b..db143500d 100644 --- a/src/fdb5/types/TypesRegistry.cc +++ b/src/fdb5/types/TypesRegistry.cc @@ -119,7 +119,7 @@ metkit::mars::MarsRequest TypesRegistry::canonicalise(const metkit::mars::MarsRe const Type& type = lookupType(param.name()); for (const std::string& v : srcVals) { std::string newVal = type.toKey(v); - auto it = uniqueVals.find(newVal); + auto it = uniqueVals.find(newVal); if (it == uniqueVals.end()) { vals.push_back(newVal); uniqueVals.insert(newVal); diff --git a/tests/chunked_data_view/test_axis.cc b/tests/chunked_data_view/test_axis.cc index e043b3820..7a3986f43 100644 --- a/tests/chunked_data_view/test_axis.cc +++ b/tests/chunked_data_view/test_axis.cc @@ -13,8 +13,8 @@ template bool next_perm(BidirIt first, BidirIt last) { auto r_first = std::make_reverse_iterator(last); - auto r_last = std::make_reverse_iterator(first); - auto left = std::is_sorted_until(r_first, r_last); + auto r_last = std::make_reverse_iterator(first); + auto left = std::is_sorted_until(r_first, r_last); if (left != r_last) { auto right = std::upper_bound(r_first, left, *left); @@ -71,7 +71,7 @@ CASE("RequestManipulation | Axis test multiple axis for Indices | Can create a s "param=v/u," "time=0/6/12/18"}; - auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); + auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); std::vector dates = {"2020-01-01", "2020-01-02", "2020-01-03"}; std::vector times = {"0", "6", "12", "18"}; chunked_data_view::Axis axis({{"date", dates}, {"time", times}}, true); @@ -109,16 +109,16 @@ bool assert_arrays( EXPECT(axis.parameters().size() == 4); - const std::string first_name = axis.parameters()[0].name(); + const std::string first_name = axis.parameters()[0].name(); const std::vector first_values = axis.parameters()[0].values(); - const std::string second_name = axis.parameters()[1].name(); + const std::string second_name = axis.parameters()[1].name(); const std::vector second_values = axis.parameters()[1].values(); - const std::string third_name = axis.parameters()[2].name(); + const std::string third_name = axis.parameters()[2].name(); const std::vector third_values = axis.parameters()[2].values(); - const std::string fourth_name = axis.parameters()[3].name(); + const std::string fourth_name = axis.parameters()[3].name(); const std::vector fourth_values = axis.parameters()[3].values(); @@ -137,9 +137,9 @@ bool assert_arrays( chunked_data_view::RequestManipulation::updateRequest(request_copy, axis, chunk_index); // Then - auto first_result_values = request_copy[first_name]; + auto first_result_values = request_copy[first_name]; auto second_result_values = request_copy[second_name]; - auto third_result_values = request_copy[third_name]; + auto third_result_values = request_copy[third_name]; auto fourth_result_values = request_copy[fourth_name]; eckit::Log::debug() << "Chunk Index: " << chunk_index << std::endl; @@ -181,15 +181,15 @@ CASE("RequestManipulation | Axis test multiple axis for Indices 2 | Can handle m "step=0/1/2/3/4/5/6/7/8/9/10/11/12," "time=0/6/12/18"}; - auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); - std::vector dates = {"2020-01-01", "2020-01-02", "2020-01-03"}; - std::vector times = {"0", "6", "12", "18"}; - std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; + auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); + std::vector dates = {"2020-01-01", "2020-01-02", "2020-01-03"}; + std::vector times = {"0", "6", "12", "18"}; + std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; std::vector params = {"v"}; - chunked_data_view::Parameter date_parameter = {"date", dates}; - chunked_data_view::Parameter time_parameter = {"time", times}; - chunked_data_view::Parameter step_parameter = {"step", steps}; + chunked_data_view::Parameter date_parameter = {"date", dates}; + chunked_data_view::Parameter time_parameter = {"time", times}; + chunked_data_view::Parameter step_parameter = {"step", steps}; chunked_data_view::Parameter param_parameter = {"param", params}; const chunked_data_view::Axis axis = {{date_parameter, time_parameter, step_parameter, param_parameter}, true}; @@ -211,15 +211,15 @@ CASE("RequestManipulation | Axis test multiple axis | Non-chunked") { "step=0/1/2/3/4/5/6/7/8/9/10/11/12," "time=0/6/12/18"}; - auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); - std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; - std::vector times = {"0000", "0600", "1200", "1800"}; - std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; + auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); + std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; + std::vector times = {"0000", "0600", "1200", "1800"}; + std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; std::vector params = {"v"}; - chunked_data_view::Parameter date_parameter = {"date", dates}; - chunked_data_view::Parameter time_parameter = {"time", times}; - chunked_data_view::Parameter step_parameter = {"step", steps}; + chunked_data_view::Parameter date_parameter = {"date", dates}; + chunked_data_view::Parameter time_parameter = {"time", times}; + chunked_data_view::Parameter step_parameter = {"step", steps}; chunked_data_view::Parameter param_parameter = {"param", params}; const chunked_data_view::Axis axis = {{date_parameter, time_parameter, step_parameter, param_parameter}, false}; @@ -247,15 +247,15 @@ CASE("RequestManipulation | Axis test multiple axis for Indices | Permutations") "step=0/1/2/3/4/5/6/7/8/9/10/11/12," "time=0/6/12/18"}; - const auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); - const std::vector dates = {"2020-01-01", "2020-01-02", "2020-01-03"}; - const std::vector times = {"0", "6", "12", "18"}; - const std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; + const auto request = fdb5::FDBToolRequest::requestsFromString(keys).at(0).request(); + const std::vector dates = {"2020-01-01", "2020-01-02", "2020-01-03"}; + const std::vector times = {"0", "6", "12", "18"}; + const std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; const std::vector params = {"v"}; - const chunked_data_view::Parameter date_parameter = {"date", dates}; - const chunked_data_view::Parameter time_parameter = {"time", times}; - const chunked_data_view::Parameter step_parameter = {"step", steps}; + const chunked_data_view::Parameter date_parameter = {"date", dates}; + const chunked_data_view::Parameter time_parameter = {"time", times}; + const chunked_data_view::Parameter step_parameter = {"step", steps}; const chunked_data_view::Parameter param_parameter = {"param", params}; const std::vector param_vector = {date_parameter, time_parameter, step_parameter, @@ -265,9 +265,9 @@ CASE("RequestManipulation | Axis test multiple axis for Indices | Permutations") do { - auto& first = param_vector[perm[0]]; + auto& first = param_vector[perm[0]]; auto& second = param_vector[perm[1]]; - auto& third = param_vector[perm[2]]; + auto& third = param_vector[perm[2]]; auto& fourth = param_vector[perm[3]]; const chunked_data_view::Axis axis = {{first, second, third, fourth}, true}; diff --git a/tests/chunked_data_view/test_builder.cc b/tests/chunked_data_view/test_builder.cc index c68aaf8ff..09f44fb86 100644 --- a/tests/chunked_data_view/test_builder.cc +++ b/tests/chunked_data_view/test_builder.cc @@ -11,7 +11,7 @@ namespace cdv = chunked_data_view; std::unique_ptr makeHandle(const std::vector& values) { const size_t size = values.size() * sizeof(std::decay_t::value_type) + 2 * sizeof(size_t); const size_t bytesPerValue = 8; - auto handle = std::make_unique(size); + auto handle = std::make_unique(size); size_t _{}; handle->openForWrite(_); @@ -82,7 +82,7 @@ struct FakeExtractor : public cdv::Extractor { if (!res) { break; } - const auto& key = std::get<0>(*res); + const auto& key = std::get<0>(*res); auto& data_handle = std::get<1>(*res); data_handle->openForRead(); diff --git a/tests/chunked_data_view/test_index_mapper.cc b/tests/chunked_data_view/test_index_mapper.cc index c1189856d..34d94a3d5 100644 --- a/tests/chunked_data_view/test_index_mapper.cc +++ b/tests/chunked_data_view/test_index_mapper.cc @@ -9,9 +9,9 @@ CASE("index_mapping | delinearize | 1 axes 1 param | Chunked | Access valid") { // Given - std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; + std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; chunked_data_view::Parameter date_parameter = {"date", dates}; - const chunked_data_view::Axis axis = {{date_parameter}, true}; + const chunked_data_view::Axis axis = {{date_parameter}, true}; EXPECT(chunked_data_view::index_mapping::to_axis_parameter_index({0}, axis) == std::vector{0UL}); } @@ -20,9 +20,9 @@ CASE("index_mapping | delinearize | 1 axes 1 param | Chunked | Access out of bou // Given - std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; + std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; chunked_data_view::Parameter date_parameter = {"date", dates}; - const chunked_data_view::Axis axis = {{date_parameter}, true}; + const chunked_data_view::Axis axis = {{date_parameter}, true}; EXPECT_THROWS(chunked_data_view::index_mapping::to_axis_parameter_index({4}, axis)); } @@ -54,8 +54,8 @@ CASE("index_mapping | 2 axes 2/1 param | Chunked | Valid access") { std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; // std::vector params = {"v"}; - chunked_data_view::Parameter date_parameter = {"date", dates}; - chunked_data_view::Parameter time_parameter = {"time", times}; + chunked_data_view::Parameter date_parameter = {"date", dates}; + chunked_data_view::Parameter time_parameter = {"time", times}; chunked_data_view::Parameter steps_parameter = {"steps", steps}; const std::vector axes = {{{date_parameter, time_parameter}, true}, @@ -69,14 +69,14 @@ CASE("index_mapping | 2 axes 2/1 param | Chunked | Valid access") { CASE("index_mapping | 3 axes 2/1 param | Chunked/Non-Chunked| Valid access") { // Given - std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; - std::vector times = {"0", "6", "12"}; - std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; + std::vector dates = {"20200101", "20200102", "20200103", "20200104"}; + std::vector times = {"0", "6", "12"}; + std::vector steps = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; std::vector params = {"u", "v", "w", "x", "y"}; - chunked_data_view::Parameter date_parameter = {"date", dates}; - chunked_data_view::Parameter time_parameter = {"time", times}; - chunked_data_view::Parameter steps_parameter = {"steps", steps}; + chunked_data_view::Parameter date_parameter = {"date", dates}; + chunked_data_view::Parameter time_parameter = {"time", times}; + chunked_data_view::Parameter steps_parameter = {"steps", steps}; chunked_data_view::Parameter params_parameter = {"param", params}; const std::vector axes = { diff --git a/tests/chunked_data_view/test_view.cc b/tests/chunked_data_view/test_view.cc index 23f910e42..109004377 100644 --- a/tests/chunked_data_view/test_view.cc +++ b/tests/chunked_data_view/test_view.cc @@ -44,7 +44,7 @@ namespace cdv = chunked_data_view; std::unique_ptr makeHandle(const std::vector& values) { const size_t size = values.size() * sizeof(std::decay_t::value_type) + 2 * sizeof(size_t); const size_t bytesPerValue = 8; - auto handle = std::make_unique(size); + auto handle = std::make_unique(size); size_t _{}; handle->openForWrite(_); @@ -119,7 +119,7 @@ struct FakeExtractor : public cdv::Extractor { break; } - const auto& key = std::get<0>(*res); + const auto& key = std::get<0>(*res); auto& data_handle = std::get<1>(*res); data_handle->openForRead(); diff --git a/tests/fdb/api/ApiSpy.h b/tests/fdb/api/ApiSpy.h index 05e2d1fbb..0e2de24d7 100644 --- a/tests/fdb/api/ApiSpy.h +++ b/tests/fdb/api/ApiSpy.h @@ -65,7 +65,7 @@ class ApiSpy : public fdb5::FDBBase { size_t move; }; - using Archives = std::vector>; + using Archives = std::vector>; using Retrieves = std::vector; class FakeDataHandle : public eckit::DataHandle { diff --git a/tests/fdb/api/test_auxiliary.cc b/tests/fdb/api/test_auxiliary.cc index cd02fc4b7..fee12c8bf 100644 --- a/tests/fdb/api/test_auxiliary.cc +++ b/tests/fdb/api/test_auxiliary.cc @@ -14,8 +14,8 @@ std::set extensions = {"foo", "bar"}; eckit::PathName writeAuxiliaryData(const eckit::PathName datapath, const std::string ext) { eckit::PathName auxpath(datapath + "." + ext); std::string data_str = "Some extra data"; - const void* data = static_cast(data_str.c_str()); - size_t length = data_str.size(); + const void* data = static_cast(data_str.c_str()); + size_t length = data_str.size(); eckit::FileHandle file(auxpath); file.openForWrite(0); file.write(data, length); @@ -35,8 +35,8 @@ std::set setup(FDB& fdb) { }); std::string data_str = "Raining cats and dogs"; - const void* data = static_cast(data_str.c_str()); - size_t length = data_str.size(); + const void* data = static_cast(data_str.c_str()); + size_t length = data_str.size(); Key key; key.set("class", "od"); @@ -79,8 +79,8 @@ CASE("Wipe with extensions") { // call wipe FDBToolRequest request = FDBToolRequest::requestsFromString("class=od,expver=xxxx")[0]; - bool doit = true; - auto listObject = fdb.wipe(request, doit); + bool doit = true; + auto listObject = fdb.wipe(request, doit); WipeElement elem; while (listObject.next(elem)) { @@ -121,8 +121,8 @@ CASE("Purge with extensions") { // call purge FDBToolRequest request = FDBToolRequest::requestsFromString("class=od,expver=xxxx")[0]; - bool doit = true; - auto listObject = fdb.purge(request, doit, false); + bool doit = true; + auto listObject = fdb.purge(request, doit, false); PurgeElement elem; while (listObject.next(elem)) { diff --git a/tests/fdb/api/test_callback.cc b/tests/fdb/api/test_callback.cc index a17dd63ff..afbed70c4 100644 --- a/tests/fdb/api/test_callback.cc +++ b/tests/fdb/api/test_callback.cc @@ -14,8 +14,8 @@ CASE("Archive and flush callback") { FDB fdb; std::string data_str = "Raining cats and dogs"; - const void* data = static_cast(data_str.c_str()); - size_t length = data_str.size(); + const void* data = static_cast(data_str.c_str()); + size_t length = data_str.size(); Key key; key.set("class", "od"); @@ -35,7 +35,7 @@ CASE("Archive and flush callback") { fdb.registerArchiveCallback([&map](const Key& key, const void* data, size_t length, std::future> future) { std::shared_ptr location = future.get(); - map[key] = location->fullUri(); + map[key] = location->fullUri(); }); fdb.registerFlushCallback([&flushCalled]() { flushCalled = true; }); diff --git a/tests/fdb/api/test_dist.cc b/tests/fdb/api/test_dist.cc index 25aef59c4..ed3e9d94d 100644 --- a/tests/fdb/api/test_dist.cc +++ b/tests/fdb/api/test_dist.cc @@ -84,7 +84,7 @@ CASE("archives_distributed_according_to_dist") { std::vector data = {1, 2, 3, 4, 5}; const int nflush = 5; - const int narch = 5; + const int narch = 5; int flush_count = 0; diff --git a/tests/fdb/api/test_select_exclude.cc b/tests/fdb/api/test_select_exclude.cc index 75c30b49e..28c180f36 100644 --- a/tests/fdb/api/test_select_exclude.cc +++ b/tests/fdb/api/test_select_exclude.cc @@ -28,7 +28,7 @@ namespace fdb5::test { //---------------------------------------------------------------------------------------------------------------------- int count_in_list(FDB& fdb, const std::string& request_str) { - int count = 0; + int count = 0; auto listObject = fdb.list(FDBToolRequest::requestsFromString(request_str, {})[0]); ListElement elem; while (listObject.next(elem)) { @@ -44,7 +44,7 @@ int count_in_inspect(FDB& fdb, const std::string& request_str) { std::string base = "retrieve,class=od,stream=enfo,expver=xxxx,type=pf,date=20000101,domain=g,levtype=sfc,param=167,step=1"; - auto request = metkit::mars::MarsRequest::parse(base + "," + request_str); + auto request = metkit::mars::MarsRequest::parse(base + "," + request_str); auto inspectObject = fdb.inspect(request); ListElement elem; while (inspectObject.next(elem)) { @@ -101,8 +101,8 @@ CASE("write") { // Do some archiving std::string data_str = "Let it snow"; - const void* data = static_cast(data_str.c_str()); - size_t length = data_str.size(); + const void* data = static_cast(data_str.c_str()); + size_t length = data_str.size(); Key k; k.set("class", "od"); @@ -124,7 +124,7 @@ CASE("write") { // enfo,yyyy -> lane 3 // enfo,zzzz -> lane 2 - auto times = {"0000", "1200"}; + auto times = {"0000", "1200"}; auto numbers = {"1", "2", "3"}; for (const auto& t : times) { diff --git a/tests/fdb/daos/test_daos_catalogue.cc b/tests/fdb/daos/test_daos_catalogue.cc index d40a6fddf..76f81647c 100644 --- a/tests/fdb/daos/test_daos_catalogue.cc +++ b/tests/fdb/daos/test_daos_catalogue.cc @@ -99,8 +99,9 @@ CASE("Setup") { // ensure fdb root directory exists. If not, then that root is // registered as non existing and Catalogue/Store tests fail. - if (catalogue_tests_tmp_root().exists()) + if (catalogue_tests_tmp_root().exists()) { deldir(catalogue_tests_tmp_root()); + } catalogue_tests_tmp_root().mkdir(); ::setenv("FDB_ROOT_DIRECTORY", catalogue_tests_tmp_root().path().c_str(), 1); @@ -579,7 +580,7 @@ CASE("DaosCatalogue tests") { // list all listObject = fdb.list(all_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -594,28 +595,31 @@ CASE("DaosCatalogue tests") { // dry run attempt to wipe with too specific request auto wipeObject = fdb.wipe(full_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count == 0); // dry run wipe index and store unit wipeObject = fdb.wipe(index_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); // dry run wipe database wipeObject = fdb.wipe(db_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); // ensure field still exists listObject = fdb.list(full_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -625,27 +629,30 @@ CASE("DaosCatalogue tests") { // attempt to wipe with too specific request wipeObject = fdb.wipe(full_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count == 0); /// @todo: really needed? fdb.flush(); // wipe index and store unit wipeObject = fdb.wipe(index_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); /// @todo: really needed? fdb.flush(); // ensure field does not exist listObject = fdb.list(full_req); - count = 0; - while (listObject.next(info)) + count = 0; + while (listObject.next(info)) { count++; + } EXPECT(count == 0); /// @todo: ensure index and corresponding container do not exist @@ -667,7 +674,7 @@ CASE("DaosCatalogue tests") { fdb2.flush(); listObject = fdb2.list(full_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -678,9 +685,10 @@ CASE("DaosCatalogue tests") { // wipe full database wipeObject = fdb2.wipe(db_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); /// @todo: really needed? fdb2.flush(); @@ -688,7 +696,7 @@ CASE("DaosCatalogue tests") { // ensure field does not exist listObject = fdb2.list(full_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -851,9 +859,11 @@ CASE("DaosCatalogue tests") { /// created above with an ephemeral session fdb5::DaosSession().destroyPool(pool_uuid); #else - for (auto& c : fdb5::DaosSession().getPool(pool_uuid).listContainers()) - if (c == root_cont_name || c == "11:22") + for (auto& c : fdb5::DaosSession().getPool(pool_uuid).listContainers()) { + if (c == root_cont_name || c == "11:22") { fdb5::DaosSession().getPool(pool_uuid).destroyContainer(c); + } + } #endif } diff --git a/tests/fdb/daos/test_daos_handle.cc b/tests/fdb/daos/test_daos_handle.cc index e887a132b..135cd5be5 100644 --- a/tests/fdb/daos/test_daos_handle.cc +++ b/tests/fdb/daos/test_daos_handle.cc @@ -154,7 +154,7 @@ CASE("DaosContainer, DaosArray and DaosKeyValue") { pool_name = eckit::Resource("fdbDaosTestPool;$FDB_DAOS_TEST_POOL", pool_name); EXPECT(pool_name.length() > 0); #endif - fdb5::DaosPool& pool = s.getPool(pool_name); + fdb5::DaosPool& pool = s.getPool(pool_name); fdb5::DaosContainer& cont = pool.createContainer(cont_name); fdb5::AutoContainerDestroy destroyer(cont); #endif @@ -240,7 +240,7 @@ CASE("DaosContainer, DaosArray and DaosKeyValue") { uint64_t res; char read_data[20] = ""; - res = kv.get(test_key, read_data, sizeof(read_data)); + res = kv.get(test_key, read_data, sizeof(read_data)); EXPECT(res == size); EXPECT(std::memcmp(data, read_data, sizeof(data)) == 0); @@ -464,7 +464,7 @@ CASE("DaosName and DaosHandle workflows") { pool_name = eckit::Resource("fdbDaosTestPool;$FDB_DAOS_TEST_POOL", pool_name); EXPECT(pool_name.length() > 0); #endif - fdb5::DaosPool& pool = s.getPool(pool_name); + fdb5::DaosPool& pool = s.getPool(pool_name); fdb5::DaosContainer& cont = pool.createContainer(cont_name); fdb5::AutoContainerDestroy destroyer(cont); #endif @@ -646,7 +646,7 @@ CASE("DaosName and DaosHandle workflows") { fdb5::DaosArrayName na_read{pool_name, cont_name, na.OID()}; std::unique_ptr h2(na_read.dataHandle()); long skip_bytes = 10; - Length t = h2->openForRead(); + Length t = h2->openForRead(); std::vector read_data((size_t)(t - eckit::Length(skip_bytes)), 0); { eckit::AutoClose closer(*h2); diff --git a/tests/fdb/daos/test_daos_store.cc b/tests/fdb/daos/test_daos_store.cc index 64dc49aa7..c5718f40d 100644 --- a/tests/fdb/daos/test_daos_store.cc +++ b/tests/fdb/daos/test_daos_store.cc @@ -94,8 +94,9 @@ CASE("Setup") { // ensure fdb root directory exists. If not, then that root is // registered as non existing and Store tests fail. - if (store_tests_tmp_root().exists()) + if (store_tests_tmp_root().exists()) { deldir(store_tests_tmp_root()); + } store_tests_tmp_root().mkdir(); ::setenv("FDB_ROOT_DIRECTORY", store_tests_tmp_root().path().c_str(), 1); @@ -315,7 +316,7 @@ CASE("DaosStore tests") { { fdb5::TocCatalogueWriter tcat{db_key, config}; - fdb5::Catalogue& cat = static_cast(tcat); + fdb5::Catalogue& cat = static_cast(tcat); metkit::mars::MarsRequest r = db_key.request("retrieve"); std::unique_ptr wv(cat.wipeVisitor(store, r, out, true, false, false)); cat.visitEntries(*wv, false); @@ -418,28 +419,31 @@ CASE("DaosStore tests") { // dry run attempt to wipe with too specific request auto wipeObject = fdb.wipe(full_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count == 0); // dry run wipe index and store unit wipeObject = fdb.wipe(index_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); // dry run wipe database wipeObject = fdb.wipe(db_req); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); // ensure field still exists listObject = fdb.list(full_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -449,9 +453,10 @@ CASE("DaosStore tests") { // attempt to wipe with too specific request wipeObject = fdb.wipe(full_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count == 0); /// @todo: really needed? fdb.flush(); @@ -459,9 +464,10 @@ CASE("DaosStore tests") { // wipe index and store unit (and DB container as there is only one index) wipeObject = fdb.wipe(index_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); std::cout << "Wiped 1 field" << std::endl; /// @todo: really needed? @@ -470,9 +476,10 @@ CASE("DaosStore tests") { // ensure field does not exist listObject = fdb.list(full_req); - count = 0; - while (listObject.next(info)) + count = 0; + while (listObject.next(info)) { count++; + } EXPECT(count == 0); std::cout << "Listed 0 fields" << std::endl; @@ -541,9 +548,10 @@ CASE("DaosStore tests") { fdb5::WipeElement elem; auto wipeObject = fdb.wipe(db_req, true); - count = 0; - while (wipeObject.next(elem)) + count = 0; + while (wipeObject.next(elem)) { count++; + } EXPECT(count > 0); /// @todo: really needed? fdb.flush(); @@ -552,7 +560,7 @@ CASE("DaosStore tests") { fdb5::ListElement info; auto listObject = fdb.list(full_req); - count = 0; + count = 0; while (listObject.next(info)) { // info.print(std::cout, true, true); // std::cout << std::endl; @@ -570,9 +578,11 @@ CASE("DaosStore tests") { /// created above with an ephemeral session fdb5::DaosSession().destroyPool(pool_uuid); #else - for (auto& c : fdb5::DaosSession().getPool(pool_uuid).listContainers()) - if (c == "1:2") + for (auto& c : fdb5::DaosSession().getPool(pool_uuid).listContainers()) { + if (c == "1:2") { fdb5::DaosSession().getPool(pool_uuid).destroyContainer(c); + } + } #endif } diff --git a/tests/fdb/daos/test_dummy_daos_write_read.cc b/tests/fdb/daos/test_dummy_daos_write_read.cc index 8eb2d3567..4119bf5f3 100644 --- a/tests/fdb/daos/test_dummy_daos_write_read.cc +++ b/tests/fdb/daos/test_dummy_daos_write_read.cc @@ -60,9 +60,9 @@ CASE("dummy_daos_write_then_read") { // create a pool with user-defined label - std::string label = "test_pool"; - daos_prop_t* prop = NULL; - prop = daos_prop_alloc(1); + std::string label = "test_pool"; + daos_prop_t* prop = NULL; + prop = daos_prop_alloc(1); prop->dpp_entries[0].dpe_type = DAOS_PROP_PO_LABEL; D_STRNDUP(prop->dpp_entries[0].dpe_str, label.c_str(), DAOS_PROP_LABEL_MAX_LEN); @@ -105,7 +105,7 @@ CASE("dummy_daos_write_then_read") { // create, open and close a container with auto-generated uuid uuid_t cont_uuid = {0}; - rc = daos_cont_create(poh, &cont_uuid, NULL, NULL); + rc = daos_cont_create(poh, &cont_uuid, NULL, NULL); EXPECT(rc == 0); char cont_uuid_label[37] = ""; uuid_unparse(cont_uuid, cont_uuid_label); @@ -138,7 +138,7 @@ CASE("dummy_daos_write_then_read") { std::string cont = "b"; uuid_t cont_uuid2 = {0}; - rc = daos_cont_create_with_label(poh, cont.c_str(), NULL, &cont_uuid2, NULL); + rc = daos_cont_create_with_label(poh, cont.c_str(), NULL, &cont_uuid2, NULL); EXPECT(rc == 0); EXPECT((dummy_daos_get_handle_path(poh) / cont).exists()); char cont_uuid2_str[37] = ""; @@ -179,7 +179,7 @@ CASE("dummy_daos_write_then_read") { os_kv << std::setw(16) << std::setfill('0') << std::hex << oid_kv.lo; EXPECT((dummy_daos_get_handle_path(coh) / os_kv.str()).exists()); - std::string key = "key"; + std::string key = "key"; std::string value = "value"; rc = daos_kv_get(oh_kv, DAOS_TX_NONE, 0, key.c_str(), &size, NULL, NULL); @@ -191,7 +191,7 @@ CASE("dummy_daos_write_then_read") { EXPECT((dummy_daos_get_handle_path(oh_kv) / key).exists()); char kv_get_buf[100] = ""; - rc = daos_kv_get(oh_kv, DAOS_TX_NONE, 0, key.c_str(), &size, NULL, NULL); + rc = daos_kv_get(oh_kv, DAOS_TX_NONE, 0, key.c_str(), &size, NULL, NULL); EXPECT(rc == 0); EXPECT(size == (daos_size_t)std::strlen(value.c_str())); rc = daos_kv_get(oh_kv, DAOS_TX_NONE, 0, key.c_str(), &size, kv_get_buf, NULL); @@ -213,9 +213,9 @@ CASE("dummy_daos_write_then_read") { const auto bufsize = 1_KiB; eckit::Buffer list_buf(bufsize); d_iov_set(&iov_kv_list, list_buf, bufsize); - sgl_kv_list.sg_nr = 1; - sgl_kv_list.sg_nr_out = 0; - sgl_kv_list.sg_iovs = &iov_kv_list; + sgl_kv_list.sg_nr = 1; + sgl_kv_list.sg_nr_out = 0; + sgl_kv_list.sg_iovs = &iov_kv_list; daos_anchor_t listing_status = DAOS_ANCHOR_INIT; std::vector listed_keys; while (!daos_anchor_is_eof(&listing_status)) { @@ -273,9 +273,9 @@ CASE("dummy_daos_write_then_read") { d_sg_list_t sgl; d_iov_t iov; - iod.arr_nr = 1; - rg.rg_len = (daos_size_t)sizeof(data); - rg.rg_idx = (daos_off_t)0; + iod.arr_nr = 1; + rg.rg_len = (daos_size_t)sizeof(data); + rg.rg_idx = (daos_off_t)0; iod.arr_rgs = &rg; sgl.sg_nr = 1; @@ -304,9 +304,9 @@ CASE("dummy_daos_write_then_read") { data_read = (char*)malloc(sizeof(char) * ((size_t)array_size)); - iod.arr_nr = 1; - rg.rg_len = array_size; - rg.rg_idx = (daos_off_t)0; + iod.arr_nr = 1; + rg.rg_len = array_size; + rg.rg_idx = (daos_off_t)0; iod.arr_rgs = &rg; sgl.sg_nr = 1; @@ -336,16 +336,17 @@ CASE("dummy_daos_write_then_read") { rc = daos_oit_open(coh, e, &oith, NULL); EXPECT(rc == 0); - daos_anchor_t anchor = DAOS_ANCHOR_INIT; + daos_anchor_t anchor = DAOS_ANCHOR_INIT; constexpr size_t max_oids_per_rpc = 10; std::array oid_batch; std::vector oids; while (!daos_anchor_is_eof(&anchor)) { uint32_t oids_nr = max_oids_per_rpc; - rc = daos_oit_list(oith, oid_batch.data(), &oids_nr, &anchor, NULL); + rc = daos_oit_list(oith, oid_batch.data(), &oids_nr, &anchor, NULL); EXPECT(rc == 0); - for (int i = 0; i < oids_nr; i++) + for (int i = 0; i < oids_nr; i++) { oids.push_back(oid_batch[i]); + } } EXPECT(oids.size() == 2); EXPECT(std::memcmp(&oids[0], &oid_kv, sizeof(daos_obj_id_t)) == 0); diff --git a/tests/fdb/remote/test_remote_api.cc b/tests/fdb/remote/test_remote_api.cc index 1690d57f3..4242c645f 100644 --- a/tests/fdb/remote/test_remote_api.cc +++ b/tests/fdb/remote/test_remote_api.cc @@ -80,9 +80,9 @@ CASE("Remote protocol: the basics") { FDB fdb{}; // Expects the config to be set in the environment // -- write a few fields - const size_t Nfields = 9; + const size_t Nfields = 9; const std::string data_string = "It's gonna be a bright, sunshiny day!"; - std::vector keys = write_data(fdb, data_string, "20000101", 3, 0, 3); + std::vector keys = write_data(fdb, data_string, "20000101", 3, 0, 3); EXPECT_EQUAL(keys.size(), Nfields); // -- list all fields diff --git a/tests/fdb/test_fdb5_service.cc b/tests/fdb/test_fdb5_service.cc index 51cdb1870..ab50f93ed 100644 --- a/tests/fdb/test_fdb5_service.cc +++ b/tests/fdb/test_fdb5_service.cc @@ -60,13 +60,13 @@ struct FixtureService { std::vector modelParams_; FixtureService() : env("environ") { - p["class"] = "rd"; + p["class"] = "rd"; p["stream"] = "oper"; p["domain"] = "g"; p["expver"] = "0001"; - p["date"] = "20120911"; - p["time"] = "0000"; - p["type"] = "fc"; + p["date"] = "20120911"; + p["time"] = "0000"; + p["type"] = "fc"; modelParams_.push_back("130.128"); modelParams_.push_back("138.128"); @@ -123,7 +123,7 @@ CASE("test_fdb_stepunit_archive") { fdb.archive(key, static_cast(data_str.c_str()), data_str.size()); fdb.flush(); - metkit::mars::MarsRequest req = key.request(); + metkit::mars::MarsRequest req = key.request(); metkit::mars::MarsRequest listReq = key.request("list"); { @@ -202,7 +202,7 @@ CASE("test_fdb_service") { SECTION("test_fdb_service_write") { fdb5::Archiver fdb; - f.p["class"] = "rd"; + f.p["class"] = "rd"; f.p["stream"] = "oper"; f.p["domain"] = "g"; f.p["expver"] = "0001"; @@ -241,7 +241,7 @@ CASE("test_fdb_service") { Translator str; std::vector::iterator param = f.modelParams_.begin(); for (; param != f.modelParams_.end(); ++param) { - f.p["param"] = *param; + f.p["param"] = *param; f.p["levtype"] = "pl"; for (size_t step = 0; step < 2; ++step) { @@ -280,9 +280,9 @@ CASE("test_fdb_service") { Translator str; std::vector::iterator param = f.modelParams_.begin(); for (; param != f.modelParams_.end(); ++param) { - f.p["param"] = *param; - f.p["levtype"] = "pl"; - f.p["step"] = str(0); + f.p["param"] = *param; + f.p["levtype"] = "pl"; + f.p["step"] = str(0); f.p["levelist"] = str(0); Log::info() << "Looking for: " << f.p << std::endl; @@ -372,7 +372,7 @@ CASE("test_fdb_service_subtoc") { SECTION("test_fdb_service_subtoc_write") { fdb5::Archiver fdb(config); - f.p["class"] = "rd"; + f.p["class"] = "rd"; f.p["stream"] = "oper"; f.p["domain"] = "g"; f.p["expver"] = "0002"; @@ -412,7 +412,7 @@ CASE("test_fdb_service_subtoc") { Translator str; std::vector::iterator param = f.modelParams_.begin(); for (; param != f.modelParams_.end(); ++param) { - f.p["param"] = *param; + f.p["param"] = *param; f.p["levtype"] = "pl"; for (size_t step = 0; step < 2; ++step) { @@ -454,9 +454,9 @@ CASE("test_fdb_service_subtoc") { std::vector::iterator param = f.modelParams_.begin(); for (; param != f.modelParams_.end(); ++param) { - f.p["param"] = *param; - f.p["levtype"] = "pl"; - f.p["step"] = str(0); + f.p["param"] = *param; + f.p["levtype"] = "pl"; + f.p["step"] = str(0); f.p["levelist"] = str(0); Log::info() << "Looking for: " << f.p << std::endl; @@ -536,7 +536,7 @@ CASE("test_fdb_service_subtoc") { CASE("schemaSerialisation") { - PathName filename = PathName::unique("data"); + PathName filename = PathName::unique("data"); std::string filepath = filename.asString(); std::string original; diff --git a/tests/regressions/FDB-310/fdb-url.cc b/tests/regressions/FDB-310/fdb-url.cc index 370d9716e..040d3c358 100644 --- a/tests/regressions/FDB-310/fdb-url.cc +++ b/tests/regressions/FDB-310/fdb-url.cc @@ -54,8 +54,8 @@ void FDBUrl::usage(const std::string& tool) const { void FDBUrl::execute(const eckit::option::CmdArgs& args) { bool extract = args.getBool("extract", false); - bool raw = args.getBool("raw", false); - bool uri = args.getBool("uri", false); + bool raw = args.getBool("raw", false); + bool uri = args.getBool("uri", false); std::vector requests; @@ -77,8 +77,9 @@ void FDBUrl::execute(const eckit::option::CmdArgs& args) { metkit::mars::MarsParser parser(in); auto parsedRequests = parser.parse(); if (raw) { - for (auto r : parsedRequests) + for (auto r : parsedRequests) { requests.push_back(r); + } } else { metkit::mars::MarsExpansion expand(/* inherit */ false); diff --git a/tests/regressions/FDB-419/fdb_419_regression_test.cc b/tests/regressions/FDB-419/fdb_419_regression_test.cc index a7f91bc86..d57d65fae 100644 --- a/tests/regressions/FDB-419/fdb_419_regression_test.cc +++ b/tests/regressions/FDB-419/fdb_419_regression_test.cc @@ -113,9 +113,9 @@ pid_t run_server(const PathName& fdb_server_path, const PathName& log_file) { dup2(fd, 2); close(fd); - std::array argv = {"fdb-server", nullptr}; - const auto server_config_path = get_cwd() / "fdb_server_config.yaml"; - auto env = copy_environment(); + std::array argv = {"fdb-server", nullptr}; + const auto server_config_path = get_cwd() / "fdb_server_config.yaml"; + auto env = copy_environment(); const std::string fdb_config_file_env = std::string("FDB5_CONFIG_FILE=") + server_config_path.asString(); env.emplace_back(fdb_config_file_env.c_str()); env.emplace_back(nullptr); @@ -144,8 +144,8 @@ size_t count_in_file(const PathName& file, const std::string& text) { std::ifstream in(file.asString()); oss << in.rdbuf(); std::string content = oss.str(); - size_t count = 0; - size_t pos = 0; + size_t count = 0; + size_t pos = 0; while ((pos = content.find(text, pos)) != std::string::npos) { ++count; pos += text.length(); @@ -159,11 +159,11 @@ size_t count_in_file(const PathName& file, const std::string& text) { // this server. CASE("FDB-419") { const auto fdb_server_path = get_fdb_server_path(); - auto fdb_server_pid = run_server(fdb_server_path, "srv1.log"); + auto fdb_server_pid = run_server(fdb_server_path, "srv1.log"); const auto config = Config::make("fdb_client_config.yaml"); - auto fdb_a = FDB(config); - auto fdb_b = FDB(config); + auto fdb_a = FDB(config); + auto fdb_b = FDB(config); const auto req = fdb5::FDBToolRequest::requestsFromString("class=rd,expver=xxxx")[0]; EXPECT_NO_THROW(fdb_a.list(req)); diff --git a/tests/regressions/FDB-425/test_subtoc_purge.cc b/tests/regressions/FDB-425/test_subtoc_purge.cc index 860a92991..81070d490 100644 --- a/tests/regressions/FDB-425/test_subtoc_purge.cc +++ b/tests/regressions/FDB-425/test_subtoc_purge.cc @@ -52,8 +52,9 @@ fdb5::Config theconfig(bool useSubToc = false) { eckit::testing::SetEnv env("FDB5_CONFIG", config_str.c_str()); fdb5::Config expanded = fdb5::Config().expandConfig(); - if (!useSubToc) + if (!useSubToc) { return expanded; + } eckit::LocalConfiguration userConf; userConf.set("useSubToc", true); @@ -132,7 +133,7 @@ void list(bool dedup, size_t expected) { { fdb5::FDB fdb(theconfig(false)); fdb5::FDBToolRequest request = fdb5::FDBToolRequest::requestsFromString("class=od,expver=xxxx")[0]; - auto it = fdb.list(request, dedup); + auto it = fdb.list(request, dedup); ListElement elem; size_t count = 0; @@ -187,8 +188,8 @@ CASE("FDB-425: Archive, rearchive, purge, then list.") { cleanup(); - size_t Nparam = 2; - size_t Nsteps = 3; + size_t Nparam = 2; + size_t Nsteps = 3; size_t Nunique = Nsteps * Nparam; size_t Nruns = 3; @@ -215,11 +216,11 @@ CASE("Check more finer-grained purge behaviour (note no forks)") { cleanup(); // Initial run - size_t Nparam = 2; // == Nparams - size_t Nsteps = 3; + size_t Nparam = 2; // == Nparams + size_t Nsteps = 3; size_t Nunique = Nsteps * Nparam; - bool subtocs = true; - bool dofork = false; + bool subtocs = true; + bool dofork = false; runmodel(Nparam, Nsteps, subtocs, dofork); // Rerun #1: rewrite one step for every param @@ -255,8 +256,9 @@ CASE("Check more finer-grained purge behaviour (note no forks)") { int main(int argc, char** argv) { int err = run_tests(argc, argv); - if (err) + if (err) { return err; + } // fdb5::test::cleanup(); return 0; }