Skip to content

Commit

Permalink
optimise remote client
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Abraham committed Feb 11, 2025
1 parent c31b29c commit 3cc198d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions velox/functions/remote/client/Remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ class RemoteFunction : public exec::VectorFunction {
: functionName_(functionName),
metadata_(metadata),
serdeFormat_(metadata.serdeFormat),
serde_(getSerde(serdeFormat_)),
location_(metadata.location) {
boost::apply_visitor(*this, location_);
serde_(getSerde(serdeFormat_)) {
boost::apply_visitor(*this, metadata_.location);

std::vector<TypePtr> types;
types.reserve(inputArgs.size());
Expand Down Expand Up @@ -111,7 +110,7 @@ class RemoteFunction : public exec::VectorFunction {
remoteRowVector, rows.end(), *context.pool(), &serde));

std::unique_ptr<folly::IOBuf> responseBody = restClient_->invokeFunction(
boost::get<std::string>(location_), std::move(requestBody));
boost::get<std::string>(metadata_.location), std::move(requestBody));

auto outputRowVector = IOBufToRowVector(
*responseBody, ROW({outputType}), *context.pool(), &serde);
Expand Down Expand Up @@ -163,7 +162,7 @@ class RemoteFunction : public exec::VectorFunction {
VELOX_FAIL(
"Error while executing remote function '{}' at '{}': {}",
functionName_,
boost::get<folly::SocketAddress>(location_).describe(),
boost::get<folly::SocketAddress>(metadata_.location).describe(),
e.what());
}

Expand Down Expand Up @@ -197,17 +196,16 @@ class RemoteFunction : public exec::VectorFunction {

const std::string functionName_;
const RemoteVectorFunctionMetadata metadata_;
remote::PageFormat serdeFormat_;
std::unique_ptr<VectorSerde> serde_;

boost::variant<folly::SocketAddress, std::string> location_;
folly::EventBase eventBase_;

// Depending on the location, one of these is initialized by the visitor.
std::unique_ptr<RemoteFunctionClient> thriftClient_{nullptr};
std::unique_ptr<HttpClient> restClient_{nullptr};

folly::EventBase eventBase_;
remote::PageFormat serdeFormat_;
std::unique_ptr<VectorSerde> serde_;

// Structures we construct once to cache:
RowTypePtr remoteInputType_;
std::vector<std::string> serializedInputTypes_;
};
Expand Down

0 comments on commit 3cc198d

Please sign in to comment.