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

Enhance/optional message args #106

Merged
merged 6 commits into from
May 3, 2022
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
try out optional arg in KDTreeClient::kNearest
  • Loading branch information
weefuzzy committed Feb 24, 2022
commit f6fda8a79d6b36241de9c15c11c255e09d45b6c3
7 changes: 5 additions & 2 deletions include/clients/nrt/KDTreeClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ class KDTreeClient : public FluidBaseClient,
return OK();
}

MessageResult<StringVector> kNearest(BufferPtr data) const
MessageResult<StringVector> kNearest(BufferPtr data, Optional<index> nNeighbours) const
{
index k = get<kNumNeighbors>();
//we can deprecate ancillary parameters in favour of optional args by falling back to using parameters when arg not present
index k = nNeighbours ? nNeighbours.value() : get<kNumNeighbors>();
//alternatively we could just be hardcore and ignore parameters and have message handlers fallback to a default when arg missing (which would be eventual behaviour, I guess)
//index k = nNeighbours.value_or(1);
if (k > mAlgorithm.size()) return Error<StringVector>(SmallDataSet);
// if (k <= 0 && get<kRadius>() <= 0) return Error<StringVector>(SmallK);
if (!mAlgorithm.initialized()) return Error<StringVector>(NoDataFitted);
Expand Down