aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yql/plugin/bridge/interface.h
diff options
context:
space:
mode:
authormax42 <max42@yandex-team.com>2023-07-29 00:02:16 +0300
committermax42 <max42@yandex-team.com>2023-07-29 00:02:16 +0300
commit73b89de71748a21e102d27b9f3ed1bf658766cb5 (patch)
tree188bbd2d622fa91cdcbb1b6d6d77fbc84a0646f5 /yt/yql/plugin/bridge/interface.h
parent528e321bcc2a2b67b53aeba58c3bd88305a141ee (diff)
downloadydb-73b89de71748a21e102d27b9f3ed1bf658766cb5.tar.gz
YT-19210: expose YQL shared library for YT.
After this, a new target libyqlplugin.so appears. in open-source cmake build. Diff in open-source YDB repo looks like the following: https://paste.yandex-team.ru/f302bdb4-7ef2-4362-91c7-6ca45f329264
Diffstat (limited to 'yt/yql/plugin/bridge/interface.h')
-rw-r--r--yt/yql/plugin/bridge/interface.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/yt/yql/plugin/bridge/interface.h b/yt/yql/plugin/bridge/interface.h
new file mode 100644
index 00000000000..062adb7ea51
--- /dev/null
+++ b/yt/yql/plugin/bridge/interface.h
@@ -0,0 +1,74 @@
+#pragma once
+
+#include <unistd.h>
+
+////////////////////////////////////////////////////////////////////////////////
+
+// This is a plain C version of an interface described in yt/yql/plugin/plugin.h.
+// All strings without separate length field are assumed to be null-terminated.
+
+////////////////////////////////////////////////////////////////////////////////
+
+struct TBridgeYqlPluginOptions
+{
+ const char* MRJobBinary;
+ const char* UdfDirectory;
+
+ struct TBridgeCluster
+ {
+ const char* Cluster;
+ const char* Proxy;
+ };
+ ssize_t ClusterCount;
+ TBridgeCluster* Clusters;
+ const char* DefaultCluster;
+
+ const char* OperationAttributes;
+
+ const char* YTTokenPath;
+
+ // TODO(max42): passing C++ objects across shared libraries is incredibly
+ // fragile. This is a temporary mean until we come up with something more
+ // convenient; get rid of this ASAP.
+ using TLogBackendHolder = void;
+ TLogBackendHolder* LogBackend;
+};
+
+// Opaque type representing a YQL plugin.
+using TBridgeYqlPlugin = void;
+
+using TFuncBridgeCreateYqlPlugin = TBridgeYqlPlugin*(const TBridgeYqlPluginOptions* options);
+using TFuncBridgeFreeYqlPlugin = void(TBridgeYqlPlugin* plugin);
+
+////////////////////////////////////////////////////////////////////////////////
+
+// TODO(max42): consider making structure an opaque type with accessors a-la
+// const char* BridgeGetYsonResult(const TBridgeQueryResult*). This would remove the need
+// to manually free string data.
+struct TBridgeQueryResult
+{
+ const char* YsonResult = nullptr;
+ ssize_t YsonResultLength = 0;
+ const char* Plan = nullptr;
+ ssize_t PlanLength = 0;
+ const char* Statistics = nullptr;
+ ssize_t StatisticsLength = 0;
+ const char* TaskInfo = nullptr;
+ ssize_t TaskInfoLength = 0;
+
+ const char* YsonError = nullptr;
+ ssize_t YsonErrorLength = 0;
+};
+
+using TFuncBridgeFreeQueryResult = void(TBridgeQueryResult* result);
+using TFuncBridgeRun = TBridgeQueryResult*(TBridgeYqlPlugin* plugin, const char* impersonationUser, const char* queryText, const char* settings);
+
+////////////////////////////////////////////////////////////////////////////////
+
+#define FOR_EACH_BRIDGE_INTERFACE_FUNCTION(XX) \
+ XX(BridgeCreateYqlPlugin) \
+ XX(BridgeFreeYqlPlugin) \
+ XX(BridgeFreeQueryResult) \
+ XX(BridgeRun)
+
+////////////////////////////////////////////////////////////////////////////////