Skip to content

Commit

Permalink
[native] Add proxygen endpoint for expression evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsatya committed Oct 7, 2024
1 parent 88c03ab commit e19ae51
Show file tree
Hide file tree
Showing 14 changed files with 1,432 additions and 34 deletions.
2 changes: 2 additions & 0 deletions presto-native-execution/presto_cpp/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_subdirectory(operators)
add_subdirectory(types)
add_subdirectory(http)
add_subdirectory(common)
add_subdirectory(expression)
add_subdirectory(thrift)

add_library(
Expand Down Expand Up @@ -49,6 +50,7 @@ target_link_libraries(
presto_exception
presto_http
presto_operators
presto_expr_eval
velox_aggregates
velox_caching
velox_common_base
Expand Down
35 changes: 25 additions & 10 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,7 @@ void PrestoServer::run() {
driverExecutor_.get(), httpSrvCpuExecutor_.get(), spillerExecutor_.get());

if (systemConfig->prestoNativeSidecar()) {
httpServer_->registerGet(
"/v1/properties/session",
[this](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
auto sessionProperties =
taskManager_->getQueryContextManager()->getSessionProperties();
http::sendOkResponse(downstream, sessionProperties.serialize());
});
registerSidecarEndpoints(httpServer_);
}

std::string taskUri;
Expand Down Expand Up @@ -1432,4 +1423,28 @@ protocol::NodeStatus PrestoServer::fetchNodeStatus() {
return nodeStatus;
}

void PrestoServer::registerSidecarEndpoints(
std::unique_ptr<http::HttpServer>& server) {
server->registerGet(
"/v1/properties/session",
[this](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
auto sessionProperties =
taskManager_->getQueryContextManager()->getSessionProperties();
http::sendOkResponse(downstream, sessionProperties.serialize());
});

rowExpressionEvaluator_ =
std::make_unique<expression::RowExpressionEvaluator>();
server->registerPost(
"/v1/expressions",
[&](proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& body,
proxygen::ResponseHandler* downstream) {
return rowExpressionEvaluator_->evaluate(body, downstream);
});
}

} // namespace facebook::presto
4 changes: 4 additions & 0 deletions presto-native-execution/presto_cpp/main/PrestoServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "presto_cpp/main/PeriodicHeartbeatManager.h"
#include "presto_cpp/main/PrestoExchangeSource.h"
#include "presto_cpp/main/PrestoServerOperations.h"
#include "presto_cpp/main/expression/RowExpressionEvaluator.h"
#include "presto_cpp/main/types/VeloxPlanValidator.h"
#include "velox/common/caching/AsyncDataCache.h"
#include "velox/common/memory/MemoryAllocator.h"
Expand Down Expand Up @@ -216,6 +217,8 @@ class PrestoServer {

void registerSystemConnector();

void registerSidecarEndpoints(std::unique_ptr<http::HttpServer>& server);

std::unique_ptr<velox::cache::SsdCache> setupSsdCache();

const std::string configDirectoryPath_;
Expand Down Expand Up @@ -277,6 +280,7 @@ class PrestoServer {
std::string address_;
std::string nodeLocation_;
folly::SSLContextPtr sslContext_;
std::unique_ptr<expression::RowExpressionEvaluator> rowExpressionEvaluator_;
};

} // namespace facebook::presto
32 changes: 32 additions & 0 deletions presto-native-execution/presto_cpp/main/expression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_library(presto_expr_eval RowExpressionEvaluator.cpp)

target_link_libraries(
presto_expr_eval
presto_type_converter
presto_types
presto_protocol
presto_http
velox_coverage_util
velox_parse_expression
velox_parse_parser
velox_presto_serializer
velox_serialization
velox_type_parser
${FOLLY_WITH_DEPENDENCIES})

if(PRESTO_ENABLE_TESTING)
add_subdirectory(tests)
endif()
Loading

0 comments on commit e19ae51

Please sign in to comment.