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

list feature: key levels #30

Closed
wants to merge 15 commits into from
Closed

Conversation

mcakircali
Copy link
Contributor

adds level var to fdb::list

new fdb-list option: --depth

cherry-picked (from Simon's other branch) and fixed some issues

@mcakircali mcakircali requested a review from simondsmart August 1, 2024 10:44
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 69.69697% with 20 lines in your changes missing coverage. Please review.

Project coverage is 63.56%. Comparing base (c2fbb55) to head (d0a30f0).

Files Patch % Lines
src/fdb5/tools/fdb-list.cc 62.96% 10 Missing ⚠️
src/fdb5/api/RemoteFDB.cc 0.00% 5 Missing ⚠️
src/fdb5/database/FieldLocation.cc 37.50% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #30      +/-   ##
===========================================
+ Coverage    63.52%   63.56%   +0.03%     
===========================================
  Files          236      236              
  Lines        13410    13426      +16     
  Branches      1291     1288       -3     
===========================================
+ Hits          8519     8534      +15     
- Misses        4891     4892       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@simondsmart simondsmart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like you to review this in two main ways:

  • Please don't refactor tests in the regressions folder. I would like to see what fails (and what the minimum possible changes are) to make FDB-240 work. That should not break with any of the changes in this PR
  • I don't like the output that tails empty {} in the list output. It isn't obvious that the ListElement should always contain 3 components when level < 3.
  • The RemoteFDB handler needs to be made to work
  • Did you look at what would be involved in removing the NullFieldLocation?

@@ -231,8 +231,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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've inserted an incorrect const before "bool deduplicate" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's correctly set as const. it's passed by value to ListIterator, where it'll live as a non-const.

try test "$exp" = "$out"

# test date depth=2
out=$(fdb-list date=20201102 --minimum-keys="" --porcelain --depth=2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have the trailing {} - these are not components with empty keys, we just haven't explored there yet.

@@ -55,6 +55,13 @@ struct ListVisitor : public QueryVisitor<ListElement> {
indexRequest_.unsetValues(kv.first);
}

if (level_ == 1) {
/// @todo fix this so that we don't need to create an empty key
const auto emptyKey = Key {currentCatalogue_->schema().registry()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary with the schema().registry() - given that there are no keys contained inside? Does anything break if we just default construct the empty keys().

Further, can we not just emplace a single part key here, rather than all 3 parts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this hacky empty keys since there's a Key hash functor using valuesToString .. which kicks in when Key used in unordered containers.. see the note, I will attempt to fix in a later PR.

@@ -298,7 +298,7 @@ std::vector<eckit::URI> Manager::visitableLocations(const metkit::mars::MarsRequ

std::set<std::string> engines = Manager::engines(rq, all);

LOG_DEBUG_LIB(LibFdb5) << "Matching engines for request " << rq << " -> " << engines << std::endl;
LOG_DEBUG_LIB(LibFdb5) << "Matching engines for request " << rq << (all ? " ALL" : "") << " -> " << engines << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure what the value of this change is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell if useful or not, it was cherry-picked from your branch.

@@ -88,7 +88,10 @@ struct BaseHelper {
};

struct ListHelper : public BaseHelper<ListElement> {
// void extraDecode(eckit::Stream& s) { s >> level_; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incomplete. As discussed, the remote side needs to work...

options_.push_back(new SimpleOption<bool>("json", "Output available fields in JSON form"));
options_.push_back(new SimpleOption<bool>("compact", "Aggregate available fields in MARS requests"));
options_.push_back(new SimpleOption<long>("depth", "Output entries up to 'depth' levels deep"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note " (default 3)" in the usage statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

for (auto k : key.keys()) {
signature += separator+k;
separator=":";
for (auto&& k : key.keys()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "const auto&". Doesn't need && - not intending either to do move(), perfect forwarding or lifetime extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated perf fix.. here, "auto&&" becomes "const auto&"

@@ -93,24 +86,20 @@ void FDBList::init(const CmdArgs& args) {
porcelain_ = args.getBool("porcelain", false);
json_ = args.getBool("json", false);
compact_ = args.getBool("compact", false);
depth_ = args.getInt("depth", 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we set the default in the class/constructor, we should default getInt("depth", depth_). That probably applies for the other arguments as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

}
if (json_) { porcelain_ = true; }

if (porcelain_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite elegant, in that it removes the need for if (porcelain_) later on.

But I would rather that we still throw a UserError if the user asks for something else, and explain what the conflict is, rather than just give them an output that they likely don't expect.

@mcakircali
Copy link
Contributor Author

I would like you to review this in two main ways:

  • Please don't refactor tests in the regressions folder. I would like to see what fails (and what the minimum possible changes are) to make FDB-240 work. That should not break with any of the changes in this PR

that's fine, I can understand it. I'm not anxious since I reviewed every line but will remove that commit.

  • I don't like the output that tails empty {} in the list output. It isn't obvious that the ListElement should always contain 3 components when level < 3.

this is already WIP. there will be a separate PR since it's a big change.

  • The RemoteFDB handler needs to be made to work

Good point, I will fix that.

  • Did you look at what would be involved in removing the NullFieldLocation?

Yes, as mentioned, in a separate PR.

@mcakircali
Copy link
Contributor Author

closing, see more involved PR #31

@mcakircali mcakircali closed this Aug 5, 2024
@mcakircali mcakircali deleted the feature/list-depth-level branch August 8, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants