From ad749a9f3df73bba7eceb6747f31e5168c478c1a Mon Sep 17 00:00:00 2001 From: AlexSm Date: Tue, 19 Dec 2023 14:10:33 +0100 Subject: [PATCH] Mote YT plugin to ydb/library/yql (#573) --- ydb/library/yql/ya.make | 1 + ydb/library/yql/yt/README.md | 15 ++ .../library/yql/yt}/bridge/interface.h | 0 .../yt}/dynamic/CMakeLists.darwin-arm64.txt | 0 .../yt}/dynamic/CMakeLists.darwin-x86_64.txt | 0 .../yt}/dynamic/CMakeLists.linux-aarch64.txt | 0 .../yt}/dynamic/CMakeLists.linux-x86_64.txt | 0 .../library/yql/yt/dynamic}/CMakeLists.txt | 0 .../yt}/dynamic/CMakeLists.windows-x86_64.txt | 0 .../library/yql/yt}/dynamic/dylib.exports | 0 .../library/yql/yt}/dynamic/impl.cpp | 4 +- .../library/yql/yt}/dynamic/ya.make | 2 +- .../yt}/native/CMakeLists.darwin-arm64.txt | 0 .../yt}/native/CMakeLists.darwin-x86_64.txt | 0 .../yt}/native/CMakeLists.linux-aarch64.txt | 0 .../yt}/native/CMakeLists.linux-x86_64.txt | 0 .../library/yql/yt/native}/CMakeLists.txt | 0 .../yt}/native/CMakeLists.windows-x86_64.txt | 0 .../library/yql/yt}/native/error_helpers.cpp | 0 .../library/yql/yt}/native/error_helpers.h | 0 .../library/yql/yt}/native/plugin.cpp | 0 .../library/yql/yt}/native/plugin.h | 2 +- .../yql/yt}/native/progress_merger.cpp | 1 - .../library/yql/yt}/native/progress_merger.h | 0 .../library/yql/yt}/native/ya.make | 2 +- .../plugin => ydb/library/yql/yt}/plugin.cpp | 0 .../plugin => ydb/library/yql/yt}/plugin.h | 2 +- ydb/library/yql/yt/ya.make | 13 + yt/yql/plugin/CMakeLists.darwin-arm64.txt | 19 -- yt/yql/plugin/CMakeLists.darwin-x86_64.txt | 19 -- yt/yql/plugin/CMakeLists.linux-aarch64.txt | 20 -- yt/yql/plugin/CMakeLists.linux-x86_64.txt | 20 -- yt/yql/plugin/CMakeLists.windows-x86_64.txt | 19 -- yt/yql/plugin/bridge/plugin.cpp | 240 ------------------ yt/yql/plugin/bridge/plugin.h | 13 - yt/yql/plugin/bridge/ya.make | 12 - yt/yql/plugin/native/CMakeLists.txt | 19 -- yt/yql/plugin/ya.make | 19 -- 38 files changed, 35 insertions(+), 407 deletions(-) create mode 100644 ydb/library/yql/yt/README.md rename {yt/yql/plugin => ydb/library/yql/yt}/bridge/interface.h (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/CMakeLists.darwin-arm64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/CMakeLists.darwin-x86_64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/CMakeLists.linux-aarch64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/CMakeLists.linux-x86_64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt/dynamic}/CMakeLists.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/CMakeLists.windows-x86_64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/dylib.exports (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/impl.cpp (98%) rename {yt/yql/plugin => ydb/library/yql/yt}/dynamic/ya.make (81%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/CMakeLists.darwin-arm64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/CMakeLists.darwin-x86_64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/CMakeLists.linux-aarch64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/CMakeLists.linux-x86_64.txt (100%) rename {yt/yql/plugin/dynamic => ydb/library/yql/yt/native}/CMakeLists.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/CMakeLists.windows-x86_64.txt (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/error_helpers.cpp (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/error_helpers.h (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/plugin.cpp (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/plugin.h (89%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/progress_merger.cpp (99%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/progress_merger.h (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/native/ya.make (98%) rename {yt/yql/plugin => ydb/library/yql/yt}/plugin.cpp (100%) rename {yt/yql/plugin => ydb/library/yql/yt}/plugin.h (97%) create mode 100644 ydb/library/yql/yt/ya.make delete mode 100644 yt/yql/plugin/CMakeLists.darwin-arm64.txt delete mode 100644 yt/yql/plugin/CMakeLists.darwin-x86_64.txt delete mode 100644 yt/yql/plugin/CMakeLists.linux-aarch64.txt delete mode 100644 yt/yql/plugin/CMakeLists.linux-x86_64.txt delete mode 100644 yt/yql/plugin/CMakeLists.windows-x86_64.txt delete mode 100644 yt/yql/plugin/bridge/plugin.cpp delete mode 100644 yt/yql/plugin/bridge/plugin.h delete mode 100644 yt/yql/plugin/bridge/ya.make delete mode 100644 yt/yql/plugin/native/CMakeLists.txt delete mode 100644 yt/yql/plugin/ya.make diff --git a/ydb/library/yql/ya.make b/ydb/library/yql/ya.make index 3aafe2834a04..12523fc69f1e 100644 --- a/ydb/library/yql/ya.make +++ b/ydb/library/yql/ya.make @@ -12,4 +12,5 @@ RECURSE( tools udfs utils + yt ) diff --git a/ydb/library/yql/yt/README.md b/ydb/library/yql/yt/README.md new file mode 100644 index 000000000000..1e59e4515c5e --- /dev/null +++ b/ydb/library/yql/yt/README.md @@ -0,0 +1,15 @@ +### What is this? + +This directory contains targets related to YTsaurus YQL plugin. [YTsaurus](https://github.com/ytsaurus/ytsaurus) +is an open-source big data storage system which employs YQL engine as one of its primary computation engines. +YT relies on a so-called YQL plugin shared library, which is built from target located in dynamic/ directory. + +Changes of interfaces in this directory must be done very carefuly. In general, bridge/interface.h must be a +superset of +[ytsaurus:yt/yql/plugin/bridge/interface.h](https://github.com/ytsaurus/ytsaurus/blob/main/yt/yql/plugin/bridge/interface.h). +If a backwards incompatible change in interface is required, do not forget to promote the YQL plugin version +in this repository, and change the min/max supported YQL plugin +[versions](https://github.com/ytsaurus/ytsaurus/blob/main/yt/yql/plugin/bridge/plugin.cpp#L32-L41) in YTsaurus repository. + +If you are not 100% sure about what you are doing, contact vvvv@ydb.tech and mpereskokova@ytsaurus.tech for help. + diff --git a/yt/yql/plugin/bridge/interface.h b/ydb/library/yql/yt/bridge/interface.h similarity index 100% rename from yt/yql/plugin/bridge/interface.h rename to ydb/library/yql/yt/bridge/interface.h diff --git a/yt/yql/plugin/dynamic/CMakeLists.darwin-arm64.txt b/ydb/library/yql/yt/dynamic/CMakeLists.darwin-arm64.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.darwin-arm64.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.darwin-arm64.txt diff --git a/yt/yql/plugin/dynamic/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/yt/dynamic/CMakeLists.darwin-x86_64.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.darwin-x86_64.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.darwin-x86_64.txt diff --git a/yt/yql/plugin/dynamic/CMakeLists.linux-aarch64.txt b/ydb/library/yql/yt/dynamic/CMakeLists.linux-aarch64.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.linux-aarch64.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.linux-aarch64.txt diff --git a/yt/yql/plugin/dynamic/CMakeLists.linux-x86_64.txt b/ydb/library/yql/yt/dynamic/CMakeLists.linux-x86_64.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.linux-x86_64.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.linux-x86_64.txt diff --git a/yt/yql/plugin/CMakeLists.txt b/ydb/library/yql/yt/dynamic/CMakeLists.txt similarity index 100% rename from yt/yql/plugin/CMakeLists.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.txt diff --git a/yt/yql/plugin/dynamic/CMakeLists.windows-x86_64.txt b/ydb/library/yql/yt/dynamic/CMakeLists.windows-x86_64.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.windows-x86_64.txt rename to ydb/library/yql/yt/dynamic/CMakeLists.windows-x86_64.txt diff --git a/yt/yql/plugin/dynamic/dylib.exports b/ydb/library/yql/yt/dynamic/dylib.exports similarity index 100% rename from yt/yql/plugin/dynamic/dylib.exports rename to ydb/library/yql/yt/dynamic/dylib.exports diff --git a/yt/yql/plugin/dynamic/impl.cpp b/ydb/library/yql/yt/dynamic/impl.cpp similarity index 98% rename from yt/yql/plugin/dynamic/impl.cpp rename to ydb/library/yql/yt/dynamic/impl.cpp index c63f9fb0358f..818575745a6e 100644 --- a/yt/yql/plugin/dynamic/impl.cpp +++ b/ydb/library/yql/yt/dynamic/impl.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include diff --git a/yt/yql/plugin/dynamic/ya.make b/ydb/library/yql/yt/dynamic/ya.make similarity index 81% rename from yt/yql/plugin/dynamic/ya.make rename to ydb/library/yql/yt/dynamic/ya.make index c91996acece0..e401537d5488 100644 --- a/yt/yql/plugin/dynamic/ya.make +++ b/ydb/library/yql/yt/dynamic/ya.make @@ -9,7 +9,7 @@ SRCS( ) PEERDIR( - yt/yql/plugin/native + ydb/library/yql/yt/native ) END() diff --git a/yt/yql/plugin/native/CMakeLists.darwin-arm64.txt b/ydb/library/yql/yt/native/CMakeLists.darwin-arm64.txt similarity index 100% rename from yt/yql/plugin/native/CMakeLists.darwin-arm64.txt rename to ydb/library/yql/yt/native/CMakeLists.darwin-arm64.txt diff --git a/yt/yql/plugin/native/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/yt/native/CMakeLists.darwin-x86_64.txt similarity index 100% rename from yt/yql/plugin/native/CMakeLists.darwin-x86_64.txt rename to ydb/library/yql/yt/native/CMakeLists.darwin-x86_64.txt diff --git a/yt/yql/plugin/native/CMakeLists.linux-aarch64.txt b/ydb/library/yql/yt/native/CMakeLists.linux-aarch64.txt similarity index 100% rename from yt/yql/plugin/native/CMakeLists.linux-aarch64.txt rename to ydb/library/yql/yt/native/CMakeLists.linux-aarch64.txt diff --git a/yt/yql/plugin/native/CMakeLists.linux-x86_64.txt b/ydb/library/yql/yt/native/CMakeLists.linux-x86_64.txt similarity index 100% rename from yt/yql/plugin/native/CMakeLists.linux-x86_64.txt rename to ydb/library/yql/yt/native/CMakeLists.linux-x86_64.txt diff --git a/yt/yql/plugin/dynamic/CMakeLists.txt b/ydb/library/yql/yt/native/CMakeLists.txt similarity index 100% rename from yt/yql/plugin/dynamic/CMakeLists.txt rename to ydb/library/yql/yt/native/CMakeLists.txt diff --git a/yt/yql/plugin/native/CMakeLists.windows-x86_64.txt b/ydb/library/yql/yt/native/CMakeLists.windows-x86_64.txt similarity index 100% rename from yt/yql/plugin/native/CMakeLists.windows-x86_64.txt rename to ydb/library/yql/yt/native/CMakeLists.windows-x86_64.txt diff --git a/yt/yql/plugin/native/error_helpers.cpp b/ydb/library/yql/yt/native/error_helpers.cpp similarity index 100% rename from yt/yql/plugin/native/error_helpers.cpp rename to ydb/library/yql/yt/native/error_helpers.cpp diff --git a/yt/yql/plugin/native/error_helpers.h b/ydb/library/yql/yt/native/error_helpers.h similarity index 100% rename from yt/yql/plugin/native/error_helpers.h rename to ydb/library/yql/yt/native/error_helpers.h diff --git a/yt/yql/plugin/native/plugin.cpp b/ydb/library/yql/yt/native/plugin.cpp similarity index 100% rename from yt/yql/plugin/native/plugin.cpp rename to ydb/library/yql/yt/native/plugin.cpp diff --git a/yt/yql/plugin/native/plugin.h b/ydb/library/yql/yt/native/plugin.h similarity index 89% rename from yt/yql/plugin/native/plugin.h rename to ydb/library/yql/yt/native/plugin.h index c930e56ba1f8..20df9a91c617 100644 --- a/yt/yql/plugin/native/plugin.h +++ b/ydb/library/yql/yt/native/plugin.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace NYT::NYqlPlugin { diff --git a/yt/yql/plugin/native/progress_merger.cpp b/ydb/library/yql/yt/native/progress_merger.cpp similarity index 99% rename from yt/yql/plugin/native/progress_merger.cpp rename to ydb/library/yql/yt/native/progress_merger.cpp index 3a0a02604ee6..8bd614516995 100644 --- a/yt/yql/plugin/native/progress_merger.cpp +++ b/ydb/library/yql/yt/native/progress_merger.cpp @@ -1,6 +1,5 @@ #include "progress_merger.h" - namespace NYT::NYqlPlugin { ////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yql/plugin/native/progress_merger.h b/ydb/library/yql/yt/native/progress_merger.h similarity index 100% rename from yt/yql/plugin/native/progress_merger.h rename to ydb/library/yql/yt/native/progress_merger.h diff --git a/yt/yql/plugin/native/ya.make b/ydb/library/yql/yt/native/ya.make similarity index 98% rename from yt/yql/plugin/native/ya.make rename to ydb/library/yql/yt/native/ya.make index fe1a657c699d..270f74d8cb3b 100644 --- a/yt/yql/plugin/native/ya.make +++ b/ydb/library/yql/yt/native/ya.make @@ -40,7 +40,7 @@ PEERDIR( ydb/library/yql/providers/yt/lib/yt_download ydb/library/yql/providers/yt/provider - yt/yql/plugin + ydb/library/yql/yt ) YQL_LAST_ABI_VERSION() diff --git a/yt/yql/plugin/plugin.cpp b/ydb/library/yql/yt/plugin.cpp similarity index 100% rename from yt/yql/plugin/plugin.cpp rename to ydb/library/yql/yt/plugin.cpp diff --git a/yt/yql/plugin/plugin.h b/ydb/library/yql/yt/plugin.h similarity index 97% rename from yt/yql/plugin/plugin.h rename to ydb/library/yql/yt/plugin.h index 3fcc8e3e1648..520a9fe2358e 100644 --- a/yt/yql/plugin/plugin.h +++ b/ydb/library/yql/yt/plugin.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/ydb/library/yql/yt/ya.make b/ydb/library/yql/yt/ya.make new file mode 100644 index 000000000000..4aeb5b9bc60c --- /dev/null +++ b/ydb/library/yql/yt/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +SRCS( + plugin.cpp +) + +END() + +RECURSE( + dynamic + native +) + diff --git a/yt/yql/plugin/CMakeLists.darwin-arm64.txt b/yt/yql/plugin/CMakeLists.darwin-arm64.txt deleted file mode 100644 index e4e42a538988..000000000000 --- a/yt/yql/plugin/CMakeLists.darwin-arm64.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -add_subdirectory(dynamic) -add_subdirectory(native) - -add_library(yt-yql-plugin) -target_link_libraries(yt-yql-plugin PUBLIC - contrib-libs-cxxsupp - yutil -) -target_sources(yt-yql-plugin PRIVATE - ${CMAKE_SOURCE_DIR}/yt/yql/plugin/plugin.cpp -) diff --git a/yt/yql/plugin/CMakeLists.darwin-x86_64.txt b/yt/yql/plugin/CMakeLists.darwin-x86_64.txt deleted file mode 100644 index e4e42a538988..000000000000 --- a/yt/yql/plugin/CMakeLists.darwin-x86_64.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -add_subdirectory(dynamic) -add_subdirectory(native) - -add_library(yt-yql-plugin) -target_link_libraries(yt-yql-plugin PUBLIC - contrib-libs-cxxsupp - yutil -) -target_sources(yt-yql-plugin PRIVATE - ${CMAKE_SOURCE_DIR}/yt/yql/plugin/plugin.cpp -) diff --git a/yt/yql/plugin/CMakeLists.linux-aarch64.txt b/yt/yql/plugin/CMakeLists.linux-aarch64.txt deleted file mode 100644 index 3fb7f34a9485..000000000000 --- a/yt/yql/plugin/CMakeLists.linux-aarch64.txt +++ /dev/null @@ -1,20 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -add_subdirectory(dynamic) -add_subdirectory(native) - -add_library(yt-yql-plugin) -target_link_libraries(yt-yql-plugin PUBLIC - contrib-libs-linux-headers - contrib-libs-cxxsupp - yutil -) -target_sources(yt-yql-plugin PRIVATE - ${CMAKE_SOURCE_DIR}/yt/yql/plugin/plugin.cpp -) diff --git a/yt/yql/plugin/CMakeLists.linux-x86_64.txt b/yt/yql/plugin/CMakeLists.linux-x86_64.txt deleted file mode 100644 index 3fb7f34a9485..000000000000 --- a/yt/yql/plugin/CMakeLists.linux-x86_64.txt +++ /dev/null @@ -1,20 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -add_subdirectory(dynamic) -add_subdirectory(native) - -add_library(yt-yql-plugin) -target_link_libraries(yt-yql-plugin PUBLIC - contrib-libs-linux-headers - contrib-libs-cxxsupp - yutil -) -target_sources(yt-yql-plugin PRIVATE - ${CMAKE_SOURCE_DIR}/yt/yql/plugin/plugin.cpp -) diff --git a/yt/yql/plugin/CMakeLists.windows-x86_64.txt b/yt/yql/plugin/CMakeLists.windows-x86_64.txt deleted file mode 100644 index e4e42a538988..000000000000 --- a/yt/yql/plugin/CMakeLists.windows-x86_64.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -add_subdirectory(dynamic) -add_subdirectory(native) - -add_library(yt-yql-plugin) -target_link_libraries(yt-yql-plugin PUBLIC - contrib-libs-cxxsupp - yutil -) -target_sources(yt-yql-plugin PRIVATE - ${CMAKE_SOURCE_DIR}/yt/yql/plugin/plugin.cpp -) diff --git a/yt/yql/plugin/bridge/plugin.cpp b/yt/yql/plugin/bridge/plugin.cpp deleted file mode 100644 index 95f7de7a7662..000000000000 --- a/yt/yql/plugin/bridge/plugin.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include "plugin.h" - -#include "interface.h" - -#include - -#include - -#include - -#include - -namespace NYT::NYqlPlugin { -namespace NBridge { - -//////////////////////////////////////////////////////////////////////////////// - -namespace { - -std::optional ToString(const char* str, size_t strLength) -{ - if (!str) { - return std::nullopt; - } - return TString(str, strLength); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - -// Each YQL plugin ABI change should be listed here. Either a compat should be added -// or MinSupportedYqlPluginAbiVersion should be promoted. -DEFINE_ENUM(EYqlPluginAbiVersion, - ((Invalid) (-1)) - ((TheBigBang) (0)) - ((AbortQuery) (1)) // gritukan: Added BridgeAbort; no breaking changes. -); - -constexpr auto MinSupportedYqlPluginAbiVersion = EYqlPluginAbiVersion::TheBigBang; -constexpr auto MaxSupportedYqlPluginAbiVersion = EYqlPluginAbiVersion::AbortQuery; - -//////////////////////////////////////////////////////////////////////////////// - -class TDynamicYqlPlugin -{ -public: - TDynamicYqlPlugin(std::optional yqlPluginSharedLibrary) - { - static const TString DefaultYqlPluginLibraryName = "./libyqlplugin.so"; - auto sharedLibraryPath = yqlPluginSharedLibrary.value_or(DefaultYqlPluginLibraryName); - Library_.Open(sharedLibraryPath.data()); - #define XX(function) \ - { \ - if constexpr(#function == TStringBuf("BridgeAbort")) { \ - if (AbiVersion_ < EYqlPluginAbiVersion::AbortQuery) { \ - function = reinterpret_cast(AbortQueryStub); \ - } else { \ - function = reinterpret_cast(Library_.Sym(#function)); \ - } \ - } else if constexpr(#function == TStringBuf("BridgeFreeAbortResult")) { \ - if (AbiVersion_ < EYqlPluginAbiVersion::AbortQuery) { \ - function = reinterpret_cast(FreeAbortResultStub); \ - } else { \ - function = reinterpret_cast(Library_.Sym(#function)); \ - } \ - } else { \ - function = reinterpret_cast(Library_.Sym(#function)); \ - } \ - } \ - - // Firstly we need to get ABI version of the plugin to make it possible to - // add compats for other functions. - XX(BridgeGetAbiVersion); - GetYqlPluginAbiVersion(); - - FOR_EACH_BRIDGE_INTERFACE_FUNCTION(XX); - #undef XX - } - -protected: - TDynamicLibrary Library_; - - EYqlPluginAbiVersion AbiVersion_ = EYqlPluginAbiVersion::Invalid; - - #define XX(function) TFunc ## function* function; - FOR_EACH_BRIDGE_INTERFACE_FUNCTION(XX) - #undef XX - - // COMPAT(gritukan): AbortQuery - static TBridgeAbortResult* AbortQueryStub(TBridgeYqlPlugin* /*plugin*/, const char* /*queryId*/) - { - // Just do nothing. It is not worse than in used to be before. - return nullptr; - } - - static void FreeAbortResultStub(TBridgeAbortResult* /*result*/) - { - YT_ABORT(); - } - - void GetYqlPluginAbiVersion() - { - if (!TryEnumCast(BridgeGetAbiVersion(), &AbiVersion_)) { - THROW_ERROR_EXCEPTION( - "YQL plugin ABI version %v is not supported", - BridgeGetAbiVersion()); - } - - if (AbiVersion_ < MinSupportedYqlPluginAbiVersion || - AbiVersion_ > MaxSupportedYqlPluginAbiVersion) - { - THROW_ERROR_EXCEPTION( - "YQL plugin ABI version %Qv is not supported", - AbiVersion_); - } - } -}; - -//////////////////////////////////////////////////////////////////////////////// - -class TYqlPlugin - : public TDynamicYqlPlugin - , public IYqlPlugin -{ -public: - explicit TYqlPlugin(TYqlPluginOptions options) - : TDynamicYqlPlugin(options.YqlPluginSharedLibrary) - { - TString singletonsConfig = options.SingletonsConfig ? options.SingletonsConfig.ToString() : "{}"; - - TBridgeYqlPluginOptions bridgeOptions { - .SingletonsConfig = singletonsConfig.data(), - .SingletonsConfigLength = static_cast(singletonsConfig.size()), - .GatewayConfig = options.GatewayConfig.AsStringBuf().Data(), - .GatewayConfigLength = options.GatewayConfig.AsStringBuf().Size(), - .FileStorageConfig = options.FileStorageConfig.AsStringBuf().Data(), - .FileStorageConfigLength = options.FileStorageConfig.AsStringBuf().Size(), - .OperationAttributes = options.OperationAttributes.AsStringBuf().Data(), - .OperationAttributesLength = options.OperationAttributes.AsStringBuf().Size(), - .YTTokenPath = options.YTTokenPath.data(), - .LogBackend = &options.LogBackend, - }; - - BridgePlugin_ = BridgeCreateYqlPlugin(&bridgeOptions); - } - - TQueryResult Run( - TQueryId queryId, - TString impersonationUser, - TString queryText, - NYson::TYsonString settings, - std::vector files) noexcept override - { - auto settingsString = settings ? settings.ToString() : "{}"; - auto queryIdStr = ToString(queryId); - - std::vector filesData; - filesData.reserve(files.size()); - for (const auto& file : files) { - filesData.push_back(TBridgeQueryFile{ - .Name = file.Name.data(), - .NameLength = file.Name.size(), - .Content = file.Content.data(), - .ContentLength = file.Content.size(), - .Type = file.Type, - }); - } - - auto* bridgeQueryResult = BridgeRun( - BridgePlugin_, - queryIdStr.data(), - impersonationUser.data(), - queryText.data(), - settingsString.data(), - filesData.data(), - filesData.size()); - TQueryResult queryResult{ - .YsonResult = ToString(bridgeQueryResult->YsonResult, bridgeQueryResult->YsonResultLength), - .Plan = ToString(bridgeQueryResult->Plan, bridgeQueryResult->PlanLength), - .Statistics = ToString(bridgeQueryResult->Statistics, bridgeQueryResult->StatisticsLength), - .Progress = ToString(bridgeQueryResult->Progress, bridgeQueryResult->ProgressLength), - .TaskInfo = ToString(bridgeQueryResult->TaskInfo, bridgeQueryResult->TaskInfoLength), - .YsonError = ToString(bridgeQueryResult->YsonError, bridgeQueryResult->YsonErrorLength), - }; - BridgeFreeQueryResult(bridgeQueryResult); - return queryResult; - } - - TQueryResult GetProgress(TQueryId queryId) noexcept override - { - auto queryIdStr = ToString(queryId); - auto* bridgeQueryResult = BridgeGetProgress(BridgePlugin_, queryIdStr.data()); - TQueryResult queryResult{ - .Plan = ToString(bridgeQueryResult->Plan, bridgeQueryResult->PlanLength), - .Progress = ToString(bridgeQueryResult->Progress, bridgeQueryResult->ProgressLength), - }; - BridgeFreeQueryResult(bridgeQueryResult); - return queryResult; - } - - TAbortResult Abort(TQueryId queryId) noexcept override - { - auto queryIdStr = ToString(queryId); - auto* bridgeAbortResult = BridgeAbort(BridgePlugin_, queryIdStr.data()); - // COMPAT(gritukan): AbortQuery - if (!bridgeAbortResult) { - return {}; - } - - TAbortResult abortResult{ - .YsonError = ToString(bridgeAbortResult->YsonError, bridgeAbortResult->YsonErrorLength), - }; - BridgeFreeAbortResult(bridgeAbortResult); - return abortResult; - } - - ~TYqlPlugin() override - { - BridgeFreeYqlPlugin(BridgePlugin_); - } - -private: - TBridgeYqlPlugin* BridgePlugin_; -}; - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NBridge - -//////////////////////////////////////////////////////////////////////////////// - -std::unique_ptr CreateYqlPlugin(TYqlPluginOptions options) noexcept -{ - return std::make_unique(std::move(options)); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NYqlPlugin diff --git a/yt/yql/plugin/bridge/plugin.h b/yt/yql/plugin/bridge/plugin.h deleted file mode 100644 index c930e56ba1f8..000000000000 --- a/yt/yql/plugin/bridge/plugin.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -namespace NYT::NYqlPlugin { - -//////////////////////////////////////////////////////////////////////////////// - -std::unique_ptr CreateYqlPlugin(TYqlPluginOptions options) noexcept; - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NYqlPlugin diff --git a/yt/yql/plugin/bridge/ya.make b/yt/yql/plugin/bridge/ya.make deleted file mode 100644 index 3f2bc1fe0489..000000000000 --- a/yt/yql/plugin/bridge/ya.make +++ /dev/null @@ -1,12 +0,0 @@ -LIBRARY() - -SRCS( - GLOBAL plugin.cpp -) - -PEERDIR( - yt/yql/plugin - yt/yt/core -) - -END() diff --git a/yt/yql/plugin/native/CMakeLists.txt b/yt/yql/plugin/native/CMakeLists.txt deleted file mode 100644 index d863ebd18067..000000000000 --- a/yt/yql/plugin/native/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) - include(CMakeLists.linux-x86_64.txt) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) - include(CMakeLists.linux-aarch64.txt) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - include(CMakeLists.darwin-x86_64.txt) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") - include(CMakeLists.darwin-arm64.txt) -elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) - include(CMakeLists.windows-x86_64.txt) -endif() diff --git a/yt/yql/plugin/ya.make b/yt/yql/plugin/ya.make deleted file mode 100644 index 7046752106eb..000000000000 --- a/yt/yql/plugin/ya.make +++ /dev/null @@ -1,19 +0,0 @@ -LIBRARY() - -SRCS( - plugin.cpp -) - -END() - -RECURSE( - bridge -) - -IF (NOT OPENSOURCE) - # We do not bring YQL with us into open source. - RECURSE( - dynamic - native - ) -ENDIF()