Skip to content

Commit

Permalink
Merge branch 'hotfix/5.13.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Nov 14, 2024
2 parents 72fd6af + ad09082 commit d2e36b5
Show file tree
Hide file tree
Showing 41 changed files with 527 additions and 194 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()

set( PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "" ) # needed for generating .b files for persistent support

ecbuild_find_package( NAME eckit VERSION 1.24.4 REQUIRED )
ecbuild_find_package( NAME eckit VERSION 1.28.3 REQUIRED )

### GRIB support

Expand All @@ -31,7 +31,7 @@ ecbuild_add_option( FEATURE GRIB
CONDITION eccodes_FOUND
DESCRIPTION "Support for GRIB via eccodes")

ecbuild_find_package( NAME metkit VERSION 1.5 REQUIRED )
ecbuild_find_package( NAME metkit VERSION 1.11.22 REQUIRED )

### FDB backend in persistent memory, i.e. pmem (NVRAM)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.13.2
5.13.3
2 changes: 1 addition & 1 deletion src/fdb5/api/local/AxesVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AxesVisitor : public QueryVisitor<AxesElement> {
// bool preVisitDatabase(const eckit::URI& uri) override;
bool visitDatabase(const Catalogue& catalogue, const Store& store) override;
bool visitIndex(const Index&) override;
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

private: // members

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/ControlVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ControlVisitor : public QueryVisitor<ControlElement> {

bool visitDatabase(const Catalogue& catalogue, const Store& store) override;
bool visitIndex(const Index&) override { NOTIMP; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

private: // members

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/DumpVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DumpVisitor : public QueryVisitor<DumpElement> {
return true;
}
bool visitIndex(const Index&) override { NOTIMP; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

void visitDatum(const Field& field, const std::string& keyFingerprint) override {
EntryVisitor::visitDatum(field, keyFingerprint);
Expand Down
23 changes: 16 additions & 7 deletions src/fdb5/api/local/ListVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
#include "fdb5/database/DB.h"
#include "fdb5/database/Index.h"
#include "fdb5/database/Key.h"
#include "fdb5/rules/Rule.h"
#include "fdb5/api/local/QueryVisitor.h"
#include "fdb5/api/helpers/ListIterator.h"

#include "metkit/mars/MarsRequest.h"

namespace fdb5 {
namespace api {
namespace local {
Expand Down Expand Up @@ -67,25 +70,31 @@ struct ListVisitor : public QueryVisitor<ListElement> {
bool visitIndex(const Index& index) override {
QueryVisitor::visitIndex(index);

// Subselect the parts of the request
datumRequest_ = indexRequest_;
for (const auto& kv : index.key()) {
datumRequest_.unsetValues(kv.first);
}

if (index.partialMatch(request_)) {

// Subselect the parts of the request
datumRequest_ = indexRequest_;
for (const auto& kv : index.key()) {
datumRequest_.unsetValues(kv.first);
}

// Take into account any rule-specific behaviour in the request
datumRequest_ = rule_->registry().canonicalise(datumRequest_);

return true; // Explore contained entries
}

return false; // Skip contained entries
}

/// Test if entry matches the current request. If so, add to the output queue.
void visitDatum(const Field& field, const TypedKey& datumKey) override {
void visitDatum(const Field& field, const Key& datumKey) override {
ASSERT(currentCatalogue_);
ASSERT(currentIndex_);

if (datumKey.match(datumRequest_)) {
queue_.emplace(ListElement({currentCatalogue_->key(), currentIndex_->key(), datumKey.canonical()}, field.stableLocation(), field.timestamp()));
queue_.emplace(ListElement({currentCatalogue_->key(), currentIndex_->key(), datumKey}, field.stableLocation(), field.timestamp()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/MoveVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MoveVisitor : public QueryVisitor<MoveElement> {

bool visitDatabase(const Catalogue& catalogue, const Store& store) override;
bool visitIndex(const Index&) override { NOTIMP; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }
void visitDatum(const Field& field, const std::string& keyFingerprint) override { NOTIMP; }

private: // members
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/PurgeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PurgeVisitor : public QueryVisitor<PurgeElement> {
bool visitIndex(const Index& index) override;
void catalogueComplete(const Catalogue& catalogue) override;
void visitDatum(const Field& field, const std::string& keyFingerprint) override;
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

private: // members

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/StatsVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class StatsVisitor : public QueryVisitor<StatsElement> {
bool visitIndex(const Index& index) override;
void catalogueComplete(const Catalogue& catalogue) override;
void visitDatum(const Field& field, const std::string& keyFingerprint) override;
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

private: // members

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/StatusVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StatusVisitor : public QueryVisitor<StatusElement> {
bool visitEntries() override { return false; }
bool visitDatabase(const Catalogue& catalogue, const Store& store) override { queue_.emplace(catalogue); return true; }
bool visitIndex(const Index&) override { NOTIMP; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }

void visitDatum(const Field& field, const std::string& keyFingerprint) override {
EntryVisitor::visitDatum(field, keyFingerprint);
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/local/WipeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class WipeVisitor : public QueryVisitor<WipeElement> {
bool visitDatabase(const Catalogue& catalogue, const Store& store) override;
bool visitIndex(const Index& index) override;
void catalogueComplete(const Catalogue& catalogue) override;
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }
void visitDatum(const Field& field, const std::string& keyFingerprint) override { NOTIMP; }

void onDatabaseNotFound(const fdb5::DatabaseNotFoundException& e) override { throw e; }
Expand Down
4 changes: 2 additions & 2 deletions src/fdb5/daos/DaosIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class DaosIndex : public IndexBase {

bool dirty() const override { NOTIMP; }

void open() override { NOTIMP; };
void close() override { NOTIMP; }
void open() override { NOTIMP; }
void close() override {}
void reopen() override { NOTIMP; }

void visit(IndexLocationVisitor& visitor) const override { NOTIMP; }
Expand Down
10 changes: 9 additions & 1 deletion src/fdb5/database/Catalogue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "eckit/config/Resource.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/io/AutoCloser.h"
#include "eckit/thread/AutoLock.h"
#include "eckit/thread/Mutex.h"
#include "eckit/utils/StringTools.h"
Expand All @@ -32,11 +33,18 @@ void Catalogue::visitEntries(EntryVisitor& visitor, const Store& store, bool sor

std::vector<Index> all = indexes(sorted);

// It is likely that many indexes in the same database share resources/files/etc.
// To prevent repeated opening/closing (especially where a PooledFile would facilitate things)
// pre-open the indexes, and keep them open
std::vector<eckit::AutoCloser<Index>> closers;
closers.reserve(all.size());

// Allow the visitor to selectively reject this DB.
if (visitor.visitDatabase(*this, store)) {
if (visitor.visitIndexes()) {
for (const Index& idx : all) {
for (Index& idx : all) {
if (visitor.visitEntries()) {
closers.emplace_back(idx);
idx.entries(visitor); // contains visitIndex
} else {
visitor.visitIndex(idx);
Expand Down
9 changes: 6 additions & 3 deletions src/fdb5/database/EntryVisitMechanism.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class FDBVisitException : public eckit::Exception {
bool EntryVisitor::visitDatabase(const Catalogue& catalogue, const Store& store) {
currentCatalogue_ = &catalogue;
currentStore_ = &store;
currentIndex_ = nullptr;
rule_ = nullptr;
return true;
}

Expand All @@ -46,19 +48,20 @@ void EntryVisitor::catalogueComplete(const Catalogue& catalogue) {
currentCatalogue_ = nullptr;
currentStore_ = nullptr;
currentIndex_ = nullptr;
rule_ = nullptr;
}

bool EntryVisitor::visitIndex(const Index& index) {
currentIndex_ = &index;
rule_ = currentCatalogue_->schema().ruleFor(currentCatalogue_->key(), currentIndex_->key());
return true;
}

void EntryVisitor::visitDatum(const Field& field, const std::string& keyFingerprint) {
ASSERT(currentCatalogue_);
ASSERT(currentIndex_);
const Rule* rule = currentCatalogue_->schema().ruleFor(currentCatalogue_->key(), currentIndex_->key());
ASSERT(rule);
TypedKey key(keyFingerprint, *rule);
ASSERT(rule_);
Key key(keyFingerprint, *rule_);
visitDatum(field, key);
}

Expand Down
3 changes: 2 additions & 1 deletion src/fdb5/database/EntryVisitMechanism.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ class EntryVisitor : public eckit::NonCopyable {

private: // methods

virtual void visitDatum(const Field& field, const TypedKey& datumKey) = 0;
virtual void visitDatum(const Field& field, const Key& datumKey) = 0;

protected: // members

// n.b. non-owning
const Catalogue* currentCatalogue_ = nullptr;
const Store* currentStore_ = nullptr;
const Index* currentIndex_ = nullptr;
const Rule* rule_ = nullptr;
};

//----------------------------------------------------------------------------------------------------------------------
Expand Down
21 changes: 14 additions & 7 deletions src/fdb5/database/Key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ namespace fdb5 {

//----------------------------------------------------------------------------------------------------------------------

BaseKey::BaseKey(const std::string& fingerprint, const Rule& rule) {
eckit::Tokenizer parse(":", true);
eckit::StringList values;
parse(fingerprint, values);

rule.fill(*this, values);
}

void BaseKey::decode(eckit::Stream& s) {

keys_.clear();
Expand All @@ -43,6 +51,7 @@ void BaseKey::decode(eckit::Stream& s) {
}

s >> n;
names_.reserve(n);
for (size_t i = 0; i < n; ++i) {
s >> k;
s >> v; // this is the type (ignoring FTM)
Expand Down Expand Up @@ -146,7 +155,7 @@ bool BaseKey::match(const metkit::mars::MarsRequest& request) const {
}

bool found=false;
auto values = request.values(k);
const auto& values = request.values(k);
std::string can = canonicalise(k, j->second);
for (auto it = values.cbegin(); !found && it != values.cend(); it++) {
found = can == canonicalise(k, *it);
Expand Down Expand Up @@ -307,6 +316,9 @@ Key::Key(eckit::Stream& s) {
Key::Key(std::initializer_list<std::pair<const std::string, std::string>> l) :
BaseKey(l) {}

Key::Key(const std::string& fingerprint, const Rule& rule) :
BaseKey(fingerprint, rule) {}

Key Key::parseString(const std::string& s) {

eckit::Tokenizer parse1(",");
Expand Down Expand Up @@ -342,13 +354,8 @@ TypedKey::TypedKey(const TypesRegistry& reg) :
registry_(std::cref(reg)) {}

TypedKey::TypedKey(const std::string &s, const Rule& rule) :
BaseKey(s, rule),
registry_(std::cref(rule.registry())) {

eckit::Tokenizer parse(":", true);
eckit::StringList values;
parse(s, values);

rule.fill(*this, values);
}

TypedKey::TypedKey(const eckit::StringDict &keys, const TypesRegistry& reg) :
Expand Down
2 changes: 2 additions & 0 deletions src/fdb5/database/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BaseKey {
names_.emplace_back(k.first);
}
}
BaseKey(const std::string& fingerprint, const Rule& rule);

virtual ~BaseKey() = default;

Expand Down Expand Up @@ -162,6 +163,7 @@ class Key : public BaseKey {
explicit Key() = default;
explicit Key(eckit::Stream &);
explicit Key(const eckit::StringDict &keys);
explicit Key(const std::string& fingerprint, const Rule& rule);
Key(std::initializer_list<std::pair<const std::string, std::string>>);

static Key parseString(const std::string& s);
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/database/MoveVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MoveVisitor : public EntryVisitor {
bool visitEntries() override { return false; }

bool visitIndex(const Index&) override { NOTIMP; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }
void visitDatum(const Field& /*field*/, const std::string& /*keyFingerprint*/) override { NOTIMP; }

protected: // members
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/database/WipeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WipeVisitor : public EntryVisitor {
~WipeVisitor() override;

bool visitEntries() override { return false; }
void visitDatum(const Field&, const TypedKey&) override { NOTIMP; }
void visitDatum(const Field&, const Key&) override { NOTIMP; }
void visitDatum(const Field& /*field*/, const std::string& /*keyFingerprint*/) override { NOTIMP; }

protected: // members
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/rules/MatchOptional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool MatchOptional::optional() const {
return true;
}

void MatchOptional::fill(TypedKey& key, const std::string &keyword, const std::string& value) const {
void MatchOptional::fill(BaseKey& key, const std::string &keyword, const std::string& value) const {
if (!value.empty()) {
key.push(keyword, value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/rules/MatchOptional.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MatchOptional : public Matcher {
const std::vector<std::string>& values(const metkit::mars::MarsRequest& rq, const std::string& keyword) const override;
void print( std::ostream &out ) const override;
const std::string &defaultValue() const override;
void fill(TypedKey& key, const std::string &keyword, const std::string& value) const override;
void fill(BaseKey& key, const std::string &keyword, const std::string& value) const override;


std::vector<std::string> default_;
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/rules/Matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const std::vector<std::string> &Matcher::values(const metkit::mars::MarsRequest&
return rq.values(keyword);
}

void Matcher::fill(TypedKey& key, const std::string &keyword, const std::string& value) const {
void Matcher::fill(BaseKey& key, const std::string &keyword, const std::string& value) const {
key.push(keyword, value);
}

Expand Down
5 changes: 2 additions & 3 deletions src/fdb5/rules/Matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ namespace mars {

namespace fdb5 {

class Key;
class TypedKey;
class BaseKey;
class Key;
class TypesRegistry;

Expand All @@ -52,7 +51,7 @@ class Matcher : public eckit::NonCopyable {
virtual const std::string &defaultValue() const;

virtual bool match(const std::string &keyword, const Key& key) const = 0;
virtual void fill(TypedKey& key, const std::string &keyword, const std::string& value) const;
virtual void fill(BaseKey& key, const std::string &keyword, const std::string& value) const;


virtual void dump(std::ostream &s, const std::string &keyword, const TypesRegistry &registry) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/rules/Predicate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const std::vector<std::string>& Predicate::values(const metkit::mars::MarsReques
return matcher_->values(rq, keyword_);
}

void Predicate::fill(TypedKey& key, const std::string& value) const {
void Predicate::fill(BaseKey& key, const std::string& value) const {
matcher_->fill(key, keyword_, value);
}

Expand Down
4 changes: 2 additions & 2 deletions src/fdb5/rules/Predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace metkit { class MarsRequest; }
namespace fdb5 {

class Key;
class TypedKey;
class BaseKey;
class Matcher;
class TypesRegistry;

Expand All @@ -44,7 +44,7 @@ class Predicate : public eckit::NonCopyable {
bool match(const Key& key) const;

void dump( std::ostream &s, const TypesRegistry &registry ) const;
void fill(TypedKey& key, const std::string& value) const;
void fill(BaseKey& key, const std::string& value) const;

const std::string &value(const Key& key) const;
const std::vector<std::string>& values(const metkit::mars::MarsRequest& rq) const;
Expand Down
Loading

0 comments on commit d2e36b5

Please sign in to comment.