Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rule schema key #48

Draft
wants to merge 135 commits into
base: remoteFDB
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
862778c
test(toKey): add check step value
mcakircali Jul 24, 2024
d60aeb8
feat(list): cherry-pick level
mcakircali Jul 29, 2024
d23778c
test(fdb-list): add new
mcakircali Jul 30, 2024
3be1f22
test(fdb-list): prepare grib file
mcakircali Jul 30, 2024
e0a0421
fix(fdb-list): init class member
mcakircali Jul 30, 2024
c2703ab
fix(fdb-list): unnecessary copy in loop
mcakircali Jul 30, 2024
36e6a54
fix(fdb-list): use make_unique not "new"
mcakircali Jul 30, 2024
77e3d77
fix(fdb-list): use "override" (not virtual)
mcakircali Jul 30, 2024
1e3381b
fix(fdb-list): default member init and tab size
mcakircali Jul 30, 2024
7f6be88
test(fdb-list): added --depth option
mcakircali Jul 30, 2024
5dfb6a0
fix(ListVisitor): empty keys
mcakircali Jul 30, 2024
71bbf51
style(fdb-list): clean code
mcakircali Jul 30, 2024
c4ebc5b
fix(fdb-list): porcelain defaults other options
mcakircali Jul 30, 2024
8ce657e
chore(remote/Handler): todo list w/ level
mcakircali Jul 30, 2024
8d9db4e
feat(list)!: separate ListElement
mcakircali Aug 5, 2024
fb4b8a0
fix(ListVisitor): use discrete ListElement ctor for DB, Cat, and Datum
mcakircali Aug 5, 2024
2c2b79d
fix(FDB): missing include
mcakircali Aug 5, 2024
31edc16
fix(FDB): name collisions
mcakircali Aug 5, 2024
376d842
fix(FDB): unnecessary copy in loop
mcakircali Aug 5, 2024
4a81dad
fix(FDB): after new ListElement
mcakircali Aug 5, 2024
e5edc6c
fix(FDB): 'some' include issues
mcakircali Aug 5, 2024
81a3924
chore(c api): param should be sha1
mcakircali Aug 5, 2024
6d67ae6
fix(c api): splitkey iterator
mcakircali Aug 5, 2024
b68231b
fix(fdb-patch): after ListElement
mcakircali Aug 5, 2024
a0cb5fa
fix(fdb-list): includes
mcakircali Aug 5, 2024
dbf974e
feat(fdb-list): options; assert depth and porcelain text
mcakircali Aug 5, 2024
4595fa7
fix(fdb-list): keys api
mcakircali Aug 5, 2024
7c42889
fix(FieldLocation): remove nullLocation
mcakircali Aug 5, 2024
f41ca4d
fix(MultiRetrieveVisitor): include issues
mcakircali Aug 5, 2024
70768b9
feat(remote): added level to Handler
mcakircali Aug 5, 2024
d4ebfa9
fix(RemoteFDB): fix include issues
mcakircali Aug 5, 2024
7ff9f39
fix(RemoteFDB): fix ListElement
mcakircali Aug 5, 2024
dfc1204
fix(LocalFDB): cleanup include
mcakircali Aug 5, 2024
7cc6f33
test(service): fix after ListElement with levels
mcakircali Aug 5, 2024
e085f57
test(fdb-list): fix after new output format
mcakircali Aug 5, 2024
bc0d333
fix(fdb-list): update porcelain text
mcakircali Aug 6, 2024
6d3fc15
fix(c api): added depth to fdb_list
mcakircali Aug 6, 2024
713c8f3
fix(ListElement): initial size = 0
mcakircali Aug 6, 2024
f1cc638
fix(c api): guard offset/len < 0
mcakircali Aug 6, 2024
24b70de
fix(fdb-list): updated doc for depth option
mcakircali Aug 7, 2024
39b27cd
test(fdb-list): rename cf -> an
mcakircali Aug 9, 2024
d8c3ec2
test(fdb-list): moved it to its own directory
mcakircali Aug 9, 2024
38c24d3
fix(c api): revert fdb_splitkey_t API
mcakircali Aug 13, 2024
12b398f
fix(c api): make fdb_splitkey_t work
mcakircali Aug 13, 2024
8cd9711
fix(c api): removed junk find()
mcakircali Aug 13, 2024
376d511
style(c api): typo
mcakircali Aug 13, 2024
de79888
feat(ListElement): throw with a msg
mcakircali Aug 13, 2024
59fdb36
feat(ListElement): added KeyChain (aka SplitKey)
mcakircali Aug 13, 2024
8e209ea
style: preserve api
mcakircali Aug 14, 2024
bea681d
style: replace auto
mcakircali Aug 14, 2024
7e73116
fix(fdb-list): param defaults and throw for porcelain option
mcakircali Aug 14, 2024
05890a3
Merge branch 'develop' into feature/list-depth-option
mcakircali Aug 14, 2024
346a47f
fix(c api): fdb_list assert bug
mcakircali Aug 14, 2024
7f72cc3
fix(ListElement): offset/length returns 0 for non-datum elements
mcakircali Aug 14, 2024
14d0f74
test(c api): added fdb_list with depth=1,2,3
mcakircali Aug 14, 2024
cbef3e9
fix(ListElement): bug print length
mcakircali Aug 14, 2024
75bcf1c
fix(ListElement): api issues around FieldLocation shared_ptr
mcakircali Aug 15, 2024
d638c98
docs(fdb-list): corrected depth range
mcakircali Aug 15, 2024
25e03d1
test(fdb-list): rename cf -> an
mcakircali Aug 9, 2024
2b7b185
feat(fdb-inspect): parallel option
mcakircali Aug 9, 2024
adfd8fd
test(fdb-inspect): start simple test
mcakircali Aug 9, 2024
34915b3
feat(fdb-inspect): output option
mcakircali Aug 14, 2024
c15f4f0
feat(EntryVisitMechanism): added previsit
mcakircali Aug 10, 2024
d098f1a
feat(Visitor): added preVisitDatabase to List and Axes
mcakircali Aug 11, 2024
6b7430a
fix(RetrieveVisitor): private -> protected
mcakircali Aug 11, 2024
177b96a
feat(rules): cherry-picked Rule and Schema from 'tree-server'
mcakircali Aug 11, 2024
03f2990
fix(EntryVisitMechanism): pass schema to preVisitDatabase
mcakircali Aug 11, 2024
8f56bc4
fix(AxesVisitor): copy mistake
mcakircali Aug 11, 2024
59cd746
fix(Schema): missing override
mcakircali Aug 11, 2024
c33208a
fix(EntryVisitMechanism): fix loop copy
mcakircali Aug 11, 2024
8bd5231
fix(EntryVisitMechanism): includes
mcakircali Aug 11, 2024
110120c
fix(Catalogue): deferred reading indexes
mcakircali Aug 12, 2024
24c7756
fix(Catalogue): includes
mcakircali Aug 12, 2024
340b481
fix(Catalogue): memory leak
mcakircali Aug 12, 2024
ac1521f
fix(database): recursive include
mcakircali Aug 12, 2024
8f6afcb
refactor(database): convert StringSet -> DenseSet
mcakircali Aug 12, 2024
e6dd5e8
fix(Index): added mayContainPartial
mcakircali Aug 12, 2024
6bc6c38
fix(IndexAxis): added containsPartial
mcakircali Aug 12, 2024
d41e921
feat(TocCatalogueReader): added cached key-matching and fixes
mcakircali Aug 13, 2024
f014b66
feat(rules): match by value
mcakircali Aug 27, 2024
9251b93
feat(Schema): use KeyChain
mcakircali Aug 30, 2024
4922334
refactor(rules): expand cleanup
mcakircali Sep 6, 2024
786e8ea
fix(rules): Schema headers
mcakircali Sep 7, 2024
806f000
refactor(rules): Schema expandSecond -> expandIndex
mcakircali Sep 9, 2024
18733b7
feat(rules): add Key::pushFrom/popFrom other keys
mcakircali Sep 16, 2024
385badd
fix(rules): optimize range loop
mcakircali Sep 16, 2024
b912ca5
fix(rules): turn off level stuff
mcakircali Sep 16, 2024
d2060b4
fix(rules): reworked Rule::expand and Schema::expand on ReadVisitor path
mcakircali Sep 16, 2024
5787faf
fix(rules): removed level stuff
mcakircali Sep 16, 2024
8ebb67a
fix(rules): add find matching keys and cleanup
mcakircali Sep 16, 2024
dbebbac
feat(rules): add expandDatabase and matchDatabase to Schema
mcakircali Sep 16, 2024
9f5aba3
fix(rules): axes and list visitors
mcakircali Sep 16, 2024
b1114f5
fix(rules): tools -> fdb-hide fdb-overlay and fdb-root
mcakircali Sep 16, 2024
fac8a15
refactor(rules): Schema
mcakircali Sep 16, 2024
c246cdc
fix(rules): Rule and Schema
mcakircali Sep 17, 2024
e2e4599
refactor(Schema): rename matchDatabase
mcakircali Sep 19, 2024
77a12d4
fix(rules): cleanup Rule
mcakircali Sep 19, 2024
86a1422
fix(rules): use automatic storage (not dynamic)
mcakircali Sep 20, 2024
f5b4442
fix(daos): adapt tests
mcakircali Sep 23, 2024
25007ef
feat(rules): parse and expand each level individually
mcakircali Sep 23, 2024
f82255d
refactor(rules): firstlevel -> database
mcakircali Sep 23, 2024
f9e769c
Merge branch 'develop' into feature/toc-mapped-indexes
mcakircali Sep 23, 2024
24ce773
Merge branch 'develop' into feature/toc-mapped-indexes
mcakircali Sep 24, 2024
9f71b93
fix(merge): Key Schema and TypesRegistry
mcakircali Sep 24, 2024
ded516e
fix(merge): remove unnecessary temp object
mcakircali Oct 6, 2024
9a366c7
fix(merge): remove unnecessary temp object
mcakircali Oct 6, 2024
56fcee6
fix(ListIterator): ListElement::combinedKey
mcakircali Oct 8, 2024
719fdb8
fix(merge): typedkey cleanup
mcakircali Oct 8, 2024
1ce0504
refactor(AxesVisitor): cosmetic
mcakircali Oct 11, 2024
cf78f9e
fix(merge): canonicalize request on list
mcakircali Oct 11, 2024
8f45355
fix(c api): guard next metadata
mcakircali Oct 11, 2024
054f5d0
fix(daos): constness thinko
mcakircali Oct 11, 2024
99c02eb
fix(merge): Key and registry issues
mcakircali Oct 11, 2024
65d89c5
fix(merge): test
mcakircali Oct 11, 2024
d81aa3c
fix(merge): cleanup
mcakircali Oct 11, 2024
39fa4ef
fix(merge): BaseKey popFrom
mcakircali Oct 14, 2024
fb48204
fix(merge): test_toKey
mcakircali Oct 14, 2024
4523f84
Merge branch 'develop' into feature/rule-schema-key
mcakircali Nov 11, 2024
9c6ba85
fix(tools): clenaup headers
mcakircali Nov 11, 2024
bb55e9f
fix(Key): templating issue
mcakircali Nov 11, 2024
0582c82
Merge branch 'develop' into feature/rule-schema-key
mcakircali Nov 15, 2024
e29a7ec
fix: merge feature/gribjump-performance
mcakircali Nov 15, 2024
73950fd
Merge branch 'develop' into feature/rule-schema-key
mcakircali Dec 6, 2024
3fb501c
Merge branch 'remoteFDB' into feature/rule-schema-key-remote
mcakircali Dec 10, 2024
b93e4e0
fix(merge): various issues
mcakircali Dec 10, 2024
906d700
feat(depth): add level to RemoteFDB::list
mcakircali Dec 10, 2024
a363005
fix(TypesRegistry): cleanup
mcakircali Dec 10, 2024
945dda0
fixed remoteFDb merge (schema serialisation)
danovaro Dec 11, 2024
4e185be
Merge remote-tracking branch 'refs/remotes/origin/feature/rule-schema…
mcakircali Dec 11, 2024
d076ce3
Merge branch 'remoteFDB' into feature/rule-schema-key-remote
danovaro Dec 11, 2024
50df580
Merge branch 'remoteFDB' into feature/rule-schema-key-remote
danovaro Dec 11, 2024
9ee12ea
removed unused files + reverted to remoteFDB Schema/Rule serialisation
danovaro Dec 17, 2024
0ddede6
Merge branch 'remoteFDB' into feature/rule-schema-key-remote
danovaro Jan 6, 2025
cf0aadd
fdb key encoding estimate
danovaro Jan 7, 2025
355f994
Merge branch 'remoteFDB' into feature/rule-schema-key-remote
danovaro Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fdb5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ list( APPEND fdb5_srcs
api/helpers/FDBToolRequest.cc
api/helpers/FDBToolRequest.h
api/helpers/DumpIterator.h
api/helpers/ListIterator.cc
api/helpers/ListElement.cc
api/helpers/ListElement.h
api/helpers/ListIterator.h
api/helpers/LockIterator.h
api/helpers/MoveIterator.h
Expand Down Expand Up @@ -78,6 +79,8 @@ list( APPEND fdb5_srcs
database/AxisRegistry.h
database/BaseArchiveVisitor.cc
database/BaseArchiveVisitor.h
database/BaseKey.cc
database/BaseKey.h
database/Catalogue.cc
database/Catalogue.h
database/DatabaseNotFoundException.cc
Expand Down Expand Up @@ -124,6 +127,7 @@ list( APPEND fdb5_srcs
database/IndexFactory.h
database/Key.cc
database/Key.h
database/ReadVisitor.cc
database/ReadVisitor.h
database/Report.cc
database/Report.h
Expand Down Expand Up @@ -444,6 +448,7 @@ list( APPEND fdb5_tools
fdb-schema
fdb-where
fdb-info
fdb-inspect
fdb-status
fdb-lock
fdb-unlock
Expand Down
7 changes: 4 additions & 3 deletions src/fdb5/api/DistFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ auto DistFDB::queryInternal(const FDBToolRequest& request, const QueryFN& fn) ->
}


ListIterator DistFDB::list(const FDBToolRequest& request) {
ListIterator DistFDB::list(const FDBToolRequest& request, int level) {
LOG_DEBUG_LIB(LibFdb5) << "DistFDB::list() : " << request << std::endl;
return queryInternal(request,
[](FDB& fdb, const FDBToolRequest& request) {
return fdb.list(request);
[level](FDB& fdb, const FDBToolRequest& request) {
bool deduplicate = false; // never deduplicate on inner calls
return fdb.list(request, deduplicate, level);
});
}

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

ListIterator inspect(const metkit::mars::MarsRequest& request) override;

ListIterator list(const FDBToolRequest& request) override;
ListIterator list(const FDBToolRequest& request, int level) override;

AxesIterator axesIterator(const FDBToolRequest& request, int level=3) override { NOTIMP; }

Expand Down
37 changes: 22 additions & 15 deletions src/fdb5/api/FDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
* (Project ID: 671951) www.nextgenio.eu
*/

#include <cstddef>
#include <sstream>
#include <string>
#include <vector>

#include "eckit/config/Resource.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/io/DataHandle.h"
#include "eckit/io/MemoryHandle.h"
#include "eckit/log/Log.h"
#include "eckit/log/Timer.h"
#include "eckit/message/Message.h"
#include "eckit/message/Reader.h"

Expand All @@ -26,6 +33,9 @@
#include "fdb5/api/FDB.h"
#include "fdb5/api/FDBFactory.h"
#include "fdb5/api/helpers/FDBToolRequest.h"
#include "fdb5/api/helpers/ListElement.h"
#include "fdb5/api/helpers/ListIterator.h"
#include "fdb5/database/FieldLocation.h"
#include "fdb5/database/Key.h"
#include "fdb5/io/HandleGatherer.h"
#include "fdb5/message/MessageDecoder.h"
Expand Down Expand Up @@ -110,12 +120,11 @@ void FDB::archive(const Key& key, const void* data, size_t length) {
Key keyInternal(key);

// step in archival requests from the model is just an integer. We need to include the stepunit
auto stepunit = keyInternal.find("stepunits");
if (stepunit != keyInternal.end()) {
if (stepunit->second.size()>0 && static_cast<char>(tolower(stepunit->second[0])) != 'h') {
auto step = keyInternal.find("step");
if (step != keyInternal.end()) {
std::string canonicalStep = config().schema().registry().lookupType("step").toKey(step->second + static_cast<char>(tolower(stepunit->second[0])));
if (const auto [stepunit, found] = keyInternal.find("stepunits"); found) {
if (stepunit->second.size() > 0 && static_cast<char>(tolower(stepunit->second[0])) != 'h') {
if (auto [step, foundStep] = keyInternal.find("step"); foundStep) {
std::string canonicalStep = config().schema().registry().lookupType("step").toKey(
step->second + static_cast<char>(tolower(stepunit->second[0])));
keyInternal.set("step", canonicalStep);
}
}
Expand Down Expand Up @@ -180,19 +189,17 @@ eckit::DataHandle* FDB::read(ListIterator& it, bool sorted) {
if (it.next(el)) {
// build the request representing the tensor-product of all retrieved fields
metkit::mars::MarsRequest cubeRequest = el.combinedKey().request();
std::vector<ListElement> elements{el};
std::vector<ListElement> elements {el};

while (it.next(el)) {
cubeRequest.merge(el.combinedKey().request());
elements.push_back(el);
}

// checking all retrieved fields against the hypercube, to remove duplicates
ListElementDeduplicator dedup;
metkit::hypercube::HyperCubePayloaded<ListElement> cube(cubeRequest, dedup);
for(auto el: elements) {
cube.add(el.combinedKey().request(), el);
}
ListElementDeduplicator deduplicator;
metkit::hypercube::HyperCubePayloaded<ListElement> cube(cubeRequest, deduplicator);
for (const auto& elem : elements) { cube.add(elem.combinedKey().request(), el); }

if (cube.countVacant() > 0) {
std::stringstream ss;
Expand All @@ -203,7 +210,7 @@ eckit::DataHandle* FDB::read(ListIterator& it, bool sorted) {
eckit::Log::warning() << ss.str() << std::endl;
}

for (size_t i=0; i< cube.size(); i++) {
for (std::size_t i = 0; i < cube.size(); i++) {
ListElement element;
if (cube.find(i, element)) {
result.add(element.location().dataHandle());
Expand All @@ -228,8 +235,8 @@ ListIterator FDB::inspect(const metkit::mars::MarsRequest& request) {
return internal_->inspect(request);
}

ListIterator FDB::list(const FDBToolRequest& request, bool deduplicate) {
return ListIterator(internal_->list(request), deduplicate);
ListIterator FDB::list(const FDBToolRequest& request, const bool deduplicate, const int level) {
return {internal_->list(request, level), deduplicate};
}

DumpIterator FDB::dump(const FDBToolRequest& request, bool simple) {
Expand Down
3 changes: 2 additions & 1 deletion src/fdb5/api/FDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <memory>
#include <iosfwd>
#include <string>

#include "eckit/distributed/Transport.h"

Expand Down Expand Up @@ -95,7 +96,7 @@ class FDB {

ListIterator inspect(const metkit::mars::MarsRequest& request);

ListIterator list(const FDBToolRequest& request, bool deduplicate=false);
ListIterator list(const FDBToolRequest& request, bool deduplicate=false, int level=3);

DumpIterator dump(const FDBToolRequest& request, bool simple=false);

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 @@ -75,7 +75,7 @@ class FDBBase : private eckit::NonCopyable {

virtual ListIterator inspect(const metkit::mars::MarsRequest& request) = 0;

virtual ListIterator list(const FDBToolRequest& request) = 0;
virtual ListIterator list(const FDBToolRequest& request, int level) = 0;

virtual DumpIterator dump(const FDBToolRequest& request, bool simple) = 0;

Expand Down
8 changes: 3 additions & 5 deletions src/fdb5/api/LocalFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "eckit/container/Queue.h"
#include "eckit/log/Log.h"
#include "eckit/message/Message.h"

#include "fdb5/api/helpers/ListIterator.h"
#include "fdb5/api/helpers/FDBToolRequest.h"
Expand All @@ -34,7 +33,6 @@
#include "fdb5/api/local/DumpVisitor.h"
#include "fdb5/api/local/ListVisitor.h"
#include "fdb5/api/local/PurgeVisitor.h"
#include "fdb5/api/local/QueryVisitor.h"
#include "fdb5/api/local/StatsVisitor.h"
#include "fdb5/api/local/StatusVisitor.h"
#include "fdb5/api/local/WipeVisitor.h"
Expand Down Expand Up @@ -83,9 +81,9 @@ APIIterator<typename VisitorType::ValueType> LocalFDB::queryInternal(const FDBTo
return QueryIterator(new AsyncIterator(async_worker));
}

ListIterator LocalFDB::list(const FDBToolRequest& request) {
ListIterator LocalFDB::list(const FDBToolRequest& request, const int level) {
LOG_DEBUG_LIB(LibFdb5) << "LocalFDB::list() : " << request << std::endl;
return queryInternal<ListVisitor>(request);
return queryInternal<ListVisitor>(request, level);
}

DumpIterator LocalFDB::dump(const FDBToolRequest &request, bool simple) {
Expand Down Expand Up @@ -127,7 +125,7 @@ ControlIterator LocalFDB::control(const FDBToolRequest& request,

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

void LocalFDB::flush() {
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 @@ -41,7 +41,7 @@ class LocalFDB : public FDBBase {

ListIterator inspect(const metkit::mars::MarsRequest& request) override;

ListIterator list(const FDBToolRequest& request) override;
ListIterator list(const FDBToolRequest& request, int level) override;

DumpIterator dump(const FDBToolRequest& request, bool simple) override;

Expand Down
30 changes: 19 additions & 11 deletions src/fdb5/api/RemoteFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#include "eckit/serialisation/MemoryStream.h"
#include "fdb5/api/helpers/FDBToolRequest.h"

#include "fdb5/LibFdb5.h"
#include "fdb5/api/RemoteFDB.h"
#include "fdb5/api/helpers/ListElement.h"
#include "fdb5/database/Archiver.h"
#include "fdb5/database/Inspector.h"
#include "fdb5/LibFdb5.h"

#include "fdb5/remote/client/ClientConnectionRouter.h"
#include "fdb5/remote/RemoteFieldLocation.h"
Expand All @@ -36,6 +37,8 @@ using StatsHelper = BaseAPIHelper<fdb5::StatsElement, fdb5::remote::Message::Sta

struct ListHelper : BaseAPIHelper<fdb5::ListElement, fdb5::remote::Message::List> {

ListHelper(const int depth) : depth_(depth) { }

static fdb5::ListElement valueFromStream(eckit::Stream& s, fdb5::RemoteFDB* fdb) {
fdb5::ListElement elem(s);

Expand All @@ -48,11 +51,16 @@ struct ListHelper : BaseAPIHelper<fdb5::ListElement, fdb5::remote::Message::List
eckit::net::Endpoint fieldLocationEndpoint{elem.location().uri().host(), elem.location().uri().port()};

std::shared_ptr<const fdb5::FieldLocation> remoteLocation = fdb5::remote::RemoteFieldLocation(fdb->storeEndpoint(fieldLocationEndpoint), static_cast<const RemoteFieldLocation&>(elem.location())).make_shared();
return fdb5::ListElement(elem.key(), remoteLocation, elem.timestamp());
return fdb5::ListElement(elem.keys(), remoteLocation, elem.timestamp());
}
std::shared_ptr<const fdb5::FieldLocation> remoteLocation = fdb5::remote::RemoteFieldLocation(fdb->storeEndpoint(), elem.location()).make_shared();
return fdb5::ListElement(elem.key(), remoteLocation, elem.timestamp());
return fdb5::ListElement(elem.keys(), remoteLocation, elem.timestamp());
}

void encodeExtra(eckit::Stream& s) const { s << depth_; }

private:
int depth_ {3};
};

struct AxesHelper : BaseAPIHelper<fdb5::AxesElement, fdb5::remote::Message::Axes> {
Expand All @@ -78,10 +86,10 @@ struct InspectHelper : BaseAPIHelper<fdb5::ListElement, fdb5::remote::Message::I
eckit::net::Endpoint fieldLocationEndpoint{elem.location().uri().host(), elem.location().uri().port()};

std::shared_ptr<const fdb5::FieldLocation> remoteLocation = fdb5::remote::RemoteFieldLocation(fdb->storeEndpoint(fieldLocationEndpoint), static_cast<const RemoteFieldLocation&>(elem.location())).make_shared();
return fdb5::ListElement(elem.key(), remoteLocation, elem.timestamp());
return fdb5::ListElement(elem.keys(), remoteLocation, elem.timestamp());
}
std::shared_ptr<const fdb5::FieldLocation> remoteLocation = fdb5::remote::RemoteFieldLocation(fdb->storeEndpoint(), elem.location()).make_shared();
return fdb5::ListElement(elem.key(), remoteLocation, elem.timestamp());
return fdb5::ListElement(elem.keys(), remoteLocation, elem.timestamp());
}
};

Expand Down Expand Up @@ -124,7 +132,7 @@ RemoteFDB::RemoteFDB(const eckit::Configuration& config, const std::string& name

std::vector<std::string> stores;
std::vector<std::string> fieldLocationEndpoints;

for (size_t i=0; i<numStores; i++) {
std::string store;
s >> store;
Expand Down Expand Up @@ -225,12 +233,12 @@ auto RemoteFDB::forwardApiCall(const HelperClass& helper, const FDBToolRequest&
);
}

ListIterator RemoteFDB::list(const FDBToolRequest& request) {
return forwardApiCall(ListHelper(), request);
ListIterator RemoteFDB::list(const FDBToolRequest& request, const int depth) {
return forwardApiCall(ListHelper(depth), request);
}

AxesIterator RemoteFDB::axesIterator(const FDBToolRequest& request, int level) {
return forwardApiCall(AxesHelper(level), request);
AxesIterator RemoteFDB::axesIterator(const FDBToolRequest& request, const int depth) {
return forwardApiCall(AxesHelper(depth), request);
}

ListIterator RemoteFDB::inspect(const metkit::mars::MarsRequest& request) {
Expand All @@ -247,7 +255,7 @@ void RemoteFDB::print(std::ostream& s) const {

// Client
bool RemoteFDB::handle(remote::Message message, uint32_t requestID) {

switch (message) {
case fdb5::remote::Message::Complete: {

Expand Down
4 changes: 2 additions & 2 deletions src/fdb5/api/RemoteFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class RemoteFDB : public LocalFDB, public remote::Client {

ListIterator inspect(const metkit::mars::MarsRequest& request) override;

ListIterator list(const FDBToolRequest& request) override;
ListIterator list(const FDBToolRequest& request, int depth) override;

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

DumpIterator dump(const FDBToolRequest& request, bool simple) override { NOTIMP; }

Expand Down
21 changes: 6 additions & 15 deletions src/fdb5/api/SelectFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,10 @@ auto SelectFDB::queryInternal(const FDBToolRequest& request, const QueryFN& fn)
return QueryIterator(new APIAggregateIterator<ValueType>(std::move(iterQueue)));
}

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

DumpIterator SelectFDB::dump(const FDBToolRequest& request, bool simple) {
Expand Down Expand Up @@ -217,20 +215,13 @@ void SelectFDB::print(std::ostream &s) const {
}

bool SelectFDB::matches(const Key& key, const SelectMap &select, bool requireMissing) const {
for (const auto& [keyword, regex] : select) {
const auto [iter, found] = key.find(keyword);

for (const auto& kv : select) {
if (!found && requireMissing) { return false; }

const std::string& k(kv.first);
const eckit::Regex& re(kv.second);

eckit::StringDict::const_iterator i = key.find(k);
if (i == key.end()) {
if (requireMissing) return false;
} else if (!re.match(i->second)) {
return false;
}
if (!regex.match(iter->second)) { return false; }
}

return true;
}

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

ListIterator inspect(const metkit::mars::MarsRequest& request) override;

ListIterator list(const FDBToolRequest& request) override;
ListIterator list(const FDBToolRequest& request, int level) override;

DumpIterator dump(const FDBToolRequest& request, bool simple) override;

Expand Down
Loading
Loading