-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
from Simon branch
Codecov ReportAttention: Patch coverage is
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. |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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_; } |
There was a problem hiding this comment.
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")); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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_) { |
There was a problem hiding this comment.
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.
that's fine, I can understand it. I'm not anxious since I reviewed every line but will remove that commit.
this is already WIP. there will be a separate PR since it's a big change.
Good point, I will fix that.
Yes, as mentioned, in a separate PR. |
closing, see more involved PR #31 |
adds level var to fdb::list
new fdb-list option: --depth
cherry-picked (from Simon's other branch) and fixed some issues