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

Feature list depth option #34

Open
wants to merge 63 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
63 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
d82131f
test(fdb-list): add marsflow tests
mcakircali Sep 12, 2024
13eeff9
test(fdb-list): fix macos grep issue
mcakircali Sep 13, 2024
bf03921
test(fdb-list): cleanup after success
mcakircali Sep 13, 2024
5aca515
Merge branch 'develop' into feature/list-depth-option
mcakircali Sep 19, 2024
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
3 changes: 2 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
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;

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

Expand Down
34 changes: 20 additions & 14 deletions src/fdb5/api/FDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@
* (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/message/Message.h"
#include "eckit/message/Reader.h"

#include "eckit/system/Plugin.h"
#include "eckit/system/LibraryManager.h"

#include "metkit/hypercube/HyperCube.h"
#include "metkit/hypercube/HyperCubePayloaded.h"

#include "fdb5/LibFdb5.h"
#include "fdb5/api/FDB.h"
#include "fdb5/api/FDBFactory.h"
#include "fdb5/api/helpers/FDBToolRequest.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 @@ -149,7 +157,7 @@ bool FDB::sorted(const metkit::mars::MarsRequest &request) {
class ListElementDeduplicator : public metkit::hypercube::Deduplicator<ListElement> {
public:
bool toReplace(const ListElement& existing, const ListElement& replacement) const override {
return existing.timestamp() < replacement.timestamp();
return existing.attributes().timestamp < replacement.attributes().timestamp;
mcakircali marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand All @@ -168,7 +176,7 @@ eckit::DataHandle* FDB::read(const std::vector<eckit::URI>& uris, bool sorted) {
}
return result.dataHandle();
}


eckit::DataHandle* FDB::read(ListIterator& it, bool sorted) {
eckit::Timer timer;
Expand All @@ -181,20 +189,18 @@ eckit::DataHandle* FDB::read(ListIterator& it, bool sorted) {
if (dedup) {
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};
metkit::mars::MarsRequest cubeRequest = el.key().request();
std::vector<ListElement> elements {el};

while (it.next(el)) {
cubeRequest.merge(el.combinedKey().request());
cubeRequest.merge(el.key().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.key().request(), el); }

if (cube.countVacant() > 0) {
std::stringstream ss;
Expand All @@ -205,7 +211,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 @@ -230,8 +236,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 @@ -94,7 +95,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 @@ -71,7 +71,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
6 changes: 2 additions & 4 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
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
34 changes: 23 additions & 11 deletions src/fdb5/api/RemoteFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,33 @@
* (Project ID: 671951) www.nextgenio.eu
*/

#include <functional>
#include <unistd.h>
#include <cstdint>
#include <mutex>
#include <sstream>
#include <string>

#include "fdb5/api/RemoteFDB.h"
#include "fdb5/LibFdb5.h"
#include "fdb5/api/helpers/ListElement.h"
#include "fdb5/io/HandleGatherer.h"
#include "fdb5/remote/Messages.h"
#include "fdb5/remote/RemoteFieldLocation.h"
#include "fdb5/api/helpers/FDBToolRequest.h"
#include "fdb5/database/Key.h"

#include "eckit/config/Configuration.h"
#include "eckit/config/LocalConfiguration.h"
#include "eckit/config/Resource.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/io/Buffer.h"
#include "eckit/log/Bytes.h"
#include "eckit/log/Log.h"
#include "eckit/message/Message.h"
#include "eckit/distributed/Transport.h"
#include "eckit/config/Resource.h"
#include "eckit/os/BackTrace.h"
#include "eckit/runtime/Main.h"
#include "eckit/serialisation/MemoryStream.h"
#include "eckit/utils/Translator.h"
#include "eckit/runtime/Main.h"
#include "eckit/os/BackTrace.h"

#include "metkit/mars/MarsRequest.h"

Expand Down Expand Up @@ -62,7 +67,7 @@ class ConnectionError : public eckit::Exception {
ConnectionError(const int);
ConnectionError(const int, const eckit::net::Endpoint&);

bool retryOnClient() const override { return true; }
bool retryOnClient() const override { return true; }
};

ConnectionError::ConnectionError(const int retries) {
Expand Down Expand Up @@ -549,13 +554,20 @@ struct BaseAPIHelper {
static ValueType valueFromStream(eckit::Stream& s, RemoteFDB* fdb) { return ValueType(s); }
};

using ListHelper = BaseAPIHelper<ListElement, fdb5::remote::Message::List>;
struct ListHelper : public BaseAPIHelper<ListElement, fdb5::remote::Message::List> {

ListHelper(int level) : level_(level) {}
void encodeExtra(eckit::Stream& s) const { s << level_; }

private:
int level_;
};

struct InspectHelper : BaseAPIHelper<ListElement, fdb5::remote::Message::Inspect> {

static ListElement valueFromStream(eckit::Stream& s, RemoteFDB* fdb) {
ListElement elem(s);
return ListElement(elem.key(), RemoteFieldLocation(fdb, elem.location()).make_shared(), elem.timestamp());
return {elem.keys(), RemoteFieldLocation(fdb, elem.location()), elem.attributes().timestamp};
}
};

Expand Down Expand Up @@ -625,7 +637,7 @@ struct WipeHelper : BaseAPIHelper<WipeElement, fdb5::remote::Message::Wipe> {

struct MoveHelper : BaseAPIHelper<MoveElement, fdb5::remote::Message::Move> {


MoveHelper(const eckit::URI& dest) :
dest_(dest) {}

Expand Down Expand Up @@ -715,8 +727,8 @@ 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 level) {
return forwardApiCall(ListHelper(level), request);
}

ListIterator RemoteFDB::inspect(const metkit::mars::MarsRequest& request) {
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/RemoteFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RemoteFDB : 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
6 changes: 2 additions & 4 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
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