-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(functions): Add support for REST based remote functions #10911
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
b88d136
to
b85e0e6
Compare
0cd4510
to
74023dc
Compare
Pretty cool! I see the PR is still as draft, but I can help review when it's ready. Would also be nice to add some documentation on how to use it, the configs parameters, etc. |
abe87e1
to
6c1606e
Compare
05115f4
to
2ffec26
Compare
a541614
to
8609347
Compare
4e0627d
to
b589f78
Compare
@Joe-Abraham There are build errors. Can you please take a look? |
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.
Initial review.
@@ -16,11 +16,23 @@ velox_add_library(velox_functions_remote_thrift_client ThriftClient.cpp) | |||
velox_link_libraries(velox_functions_remote_thrift_client | |||
PUBLIC remote_function_thrift FBThrift::thriftcpp2) | |||
|
|||
find_package(CURL REQUIRED) |
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.
Curl is a dependency that comes in from a sepaarte dependency but you can re-use this
set(curl_SOURCE BUNDLED)
velox_resolve_dependency(curl)
This should set up Curl to be used as a dependency for use in velox_link_libraries.
You can look at other dependencies that are introduced like this in the main CMake.
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.
Updated the code.
#include "velox/vector/VectorStream.h" | ||
|
||
#include <fmt/format.h> |
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.
System includes need to go before velox dependencies in alphabetical order (except for the header on line 17 that is for this cpp file).
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.
Updated the code.
#include <sstream> | ||
#include <string> | ||
|
||
#include "RestClient.h" |
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 needs to be a relative path with the root in the velox main dir and then get into the alphabetical list for the velox includes.
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.
Updated the code.
@@ -24,3 +24,18 @@ add_executable(velox_functions_remote_server_main RemoteFunctionServiceMain.cpp) | |||
target_link_libraries( | |||
velox_functions_remote_server_main velox_functions_remote_server | |||
velox_functions_prestosql) | |||
|
|||
add_library(velox_functions_remote_server_rest RemoteFunctionRestService.cpp) |
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.
Ok, so the idea is that a user can implement Velox functions and add them to this REST server and serve them up for execution though a remote velox engine?
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.
Yes, that's the idea. And it also used by test file. Similar to the ThriftServer.
@aditi-pandit Can you please review the changes? |
/// (non-remote) function registered with the same name. The `overwrite` flag | ||
/// controls whether to overwrite in these cases. | ||
/// (non-remote) function registered with the same name. The `overwrite` | ||
/// flagwrite controls whether to overwrite in these cases. |
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.
Nit : wording... maybe write is not needed here.
#include <folly/io/async/EventBase.h> | ||
#include <sstream> | ||
#include <string> | ||
#include "velox/common/memory/ByteStream.h" |
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.
Add empty line between the system and velox includes.
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.
Added new line
#include "velox/vector/VectorStream.h" | ||
|
||
#include "velox/functions/remote/client/RestClient.h" |
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.
Move this include to the correct alphabetical order in the previous velox includes.
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.
corrected the inclusion list
/// Network address of the servr to communicate with. Note that this can hold | ||
/// a network location (ip/port pair) or a unix domain socket path (see | ||
/// URL of the HTTP/REST server for remote function. | ||
/// Or Network address of the servr to communicate with. Note that this can |
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.
Nit : spelling "server"
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.
Corrected it
} | ||
size_t writeCallback(char* ptr, size_t size, size_t nmemb, void* userdata) { | ||
auto* outputBuf = static_cast<IOBufQueue*>(userdata); | ||
size_t total_size = size * nmemb; |
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.
nit : Use camelCase naming -> totalSize
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.
Corrected it
return totalCopied; | ||
} | ||
size_t writeCallback(char* ptr, size_t size, size_t nmemb, void* userdata) { | ||
auto* outputBuf = static_cast<IOBufQueue*>(userdata); |
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.
Use camel case "userData"
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.
Corrected it
using namespace folly; | ||
namespace facebook::velox::functions { | ||
namespace { | ||
size_t readCallback(char* dest, size_t size, size_t nmemb, void* userp) { |
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.
Please write comments explaining the signature and the parameters.
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.
Added the documentation
|
||
class RestClient : public HttpClient { | ||
public: | ||
std::unique_ptr<folly::IOBuf> performCurlRequest( |
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.
Please write the documentation for this API. What is it for ? What do the parameters mean ?
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.
Added the documentation
memory::memoryManager()->addLeafPool()}; | ||
}; | ||
|
||
class listener : public std::enable_shared_from_this<listener> { |
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.
Can you add some documentation about these classes and what are they for ?
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.
Added documentation
// called to use the functions mentioned in this map | ||
}; | ||
|
||
TypePtr deserializeType(const std::string& input) { |
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.
There is a lot of repetition between this code and https://github.com/facebookincubator/velox/blob/main/velox/functions/remote/server/RemoteFunctionService.cpp. Please can you refactor.
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.
introduced the RemoteFunctionHelper.h and moved the duplicate code.
Co-authored-by: Wills Feng <[email protected]>
Fixes - #11036