From 3cc198d4791d08b55d92b88255d2730aa6803536 Mon Sep 17 00:00:00 2001 From: Joe Abraham Date: Tue, 11 Feb 2025 14:39:35 +0530 Subject: [PATCH] optimise remote client --- velox/functions/remote/client/Remote.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/velox/functions/remote/client/Remote.cpp b/velox/functions/remote/client/Remote.cpp index c20a8c82e959..40c89debd5de 100644 --- a/velox/functions/remote/client/Remote.cpp +++ b/velox/functions/remote/client/Remote.cpp @@ -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 types; types.reserve(inputArgs.size()); @@ -111,7 +110,7 @@ class RemoteFunction : public exec::VectorFunction { remoteRowVector, rows.end(), *context.pool(), &serde)); std::unique_ptr responseBody = restClient_->invokeFunction( - boost::get(location_), std::move(requestBody)); + boost::get(metadata_.location), std::move(requestBody)); auto outputRowVector = IOBufToRowVector( *responseBody, ROW({outputType}), *context.pool(), &serde); @@ -163,7 +162,7 @@ class RemoteFunction : public exec::VectorFunction { VELOX_FAIL( "Error while executing remote function '{}' at '{}': {}", functionName_, - boost::get(location_).describe(), + boost::get(metadata_.location).describe(), e.what()); } @@ -197,17 +196,16 @@ class RemoteFunction : public exec::VectorFunction { const std::string functionName_; const RemoteVectorFunctionMetadata metadata_; - remote::PageFormat serdeFormat_; - std::unique_ptr serde_; - - boost::variant location_; + folly::EventBase eventBase_; // Depending on the location, one of these is initialized by the visitor. std::unique_ptr thriftClient_{nullptr}; std::unique_ptr restClient_{nullptr}; - folly::EventBase eventBase_; + remote::PageFormat serdeFormat_; + std::unique_ptr serde_; + // Structures we construct once to cache: RowTypePtr remoteInputType_; std::vector serializedInputTypes_; };