Skip to content

Commit

Permalink
Merge branch 'develop' into remoteFDB
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Oct 7, 2024
2 parents 3825bb6 + a789091 commit 253a432
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode
build
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.13.101
5.13.103
6 changes: 5 additions & 1 deletion src/fdb5/api/FDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,17 @@ void FDB::flush() {
IndexAxis FDB::axes(const FDBToolRequest& request, int level) {
IndexAxis axes;
AxesElement elem;
auto it = internal_->axes(request, level);
auto it = axesIterator(request, level);
while (it.next(elem)) {
axes.merge(elem.axes());
}
return axes;
}

AxesIterator FDB::axesIterator(const FDBToolRequest& request, int level) {
return internal_->axesIterator(request, level);
}

bool FDB::dirty() const {
return dirty_;
}
Expand Down
3 changes: 3 additions & 0 deletions src/fdb5/api/FDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "fdb5/api/helpers/StatusIterator.h"
#include "fdb5/api/helpers/WipeIterator.h"
#include "fdb5/api/helpers/MoveIterator.h"
#include "fdb5/api/helpers/AxesIterator.h"
#include "fdb5/config/Config.h"
#include "fdb5/api/helpers/Callback.h"

Expand Down Expand Up @@ -115,6 +116,8 @@ class FDB {

IndexAxis axes(const FDBToolRequest& request, int level=3);

AxesIterator axesIterator(const FDBToolRequest& request, int level=3);

bool enabled(const ControlIdentifier& controlIdentifier) const;

bool dirty() const;
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/FDBFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class FDBBase : private eckit::NonCopyable {

virtual MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) = 0;

virtual AxesIterator axes(const FDBToolRequest& request, int axes) { NOTIMP; }
virtual AxesIterator axesIterator(const FDBToolRequest& request, int axes) { NOTIMP; }

void registerArchiveCallback(ArchiveCallback callback) {callback_ = callback;}

Expand Down
4 changes: 2 additions & 2 deletions src/fdb5/api/LocalFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ ControlIterator LocalFDB::control(const FDBToolRequest& request,
return queryInternal<ControlVisitor>(request, action, identifiers);
}

AxesIterator LocalFDB::axes(const FDBToolRequest& request, int level) {
LOG_DEBUG_LIB(LibFdb5) << "LocalFDB::axes() : " << request << std::endl;
AxesIterator LocalFDB::axesIterator(const FDBToolRequest& request, int level) {
LOG_DEBUG_LIB(LibFdb5) << "LocalFDB::axesIterator() : " << request << std::endl;
return queryInternal<AxesVisitor>(request, config_, level);
}

Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/LocalFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LocalFDB : public FDBBase {

MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) override;

AxesIterator axes(const FDBToolRequest& request, int axes) override;
AxesIterator axesIterator(const FDBToolRequest& request, int axes) override;

void flush() override;

Expand Down
8 changes: 8 additions & 0 deletions src/fdb5/api/SelectFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ ControlIterator SelectFDB::control(const FDBToolRequest& request,
});
}

AxesIterator SelectFDB::axesIterator(const FDBToolRequest& request, int level) {
LOG_DEBUG_LIB(LibFdb5) << "SelectFDB::axesIterator() >> " << request << std::endl;
return queryInternal(request,
[level](FDB& fdb, const FDBToolRequest& request) {
return fdb.axesIterator(request, level);
});
}

void SelectFDB::flush() {
for (auto& iter : subFdbs_) {
FDB& fdb(iter.second);
Expand Down
2 changes: 2 additions & 0 deletions src/fdb5/api/SelectFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class SelectFDB : public FDBBase {

MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) override { NOTIMP; }

AxesIterator axesIterator(const FDBToolRequest& request, int level) override;

void flush() override;

private: // methods
Expand Down
11 changes: 11 additions & 0 deletions src/fdb5/api/fdb_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "eckit/io/FileDescHandle.h"
#include "eckit/message/Message.h"
#include "eckit/runtime/Main.h"
#include "eckit/config/YAMLConfiguration.h"

#include "metkit/mars/MarsRequest.h"
#include "metkit/mars/MarsExpension.h"
Expand Down Expand Up @@ -331,6 +332,16 @@ int fdb_new_handle(fdb_handle_t** fdb) {
});
}

int fdb_new_handle_from_yaml(fdb_handle_t** fdb, const char* system_config, const char* user_config) {
return wrapApiFunction([fdb, system_config, user_config] {
Config cfg{YAMLConfiguration(std::string(system_config)), YAMLConfiguration(std::string(user_config))};
cfg.set("configSource", "yaml");
cfg.expandConfig();
*fdb = new fdb_handle_t(cfg);
});

}

int fdb_archive(fdb_handle_t* fdb, fdb_key_t* key, const char* data, size_t length) {
return wrapApiFunction([fdb, key, data, length] {
ASSERT(fdb);
Expand Down
8 changes: 8 additions & 0 deletions src/fdb5/api/fdb_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ typedef struct fdb_handle_t fdb_handle_t;
*/
int fdb_new_handle(fdb_handle_t** fdb);

/** Creates a FDB instance from a YAML configuration.
* \param fdb FDB instance. Returned instance must be deleted using #fdb_delete_handle.
* \param system_config Override the system config with this YAML string
* \param user_config Supply user level config with this YAML string
* \returns Return code (#FdbErrorValues)
*/
int fdb_new_handle_from_yaml(fdb_handle_t** fdb, const char* system_config, const char* user_config);

/** Archives binary data to a FDB instance.
* \warning this is a low-level API. The provided key and the corresponding data are not checked for consistency
* \param fdb FDB instance.
Expand Down

0 comments on commit 253a432

Please sign in to comment.