summaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'yql/essentials/udfs/common/python/python_udf/python_udf.cpp')
-rw-r--r--yql/essentials/udfs/common/python/python_udf/python_udf.cpp65
1 files changed, 33 insertions, 32 deletions
diff --git a/yql/essentials/udfs/common/python/python_udf/python_udf.cpp b/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
index a14d9d81c32..fd0743962ba 100644
--- a/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
+++ b/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
@@ -10,9 +10,9 @@
namespace {
#if PY_MAJOR_VERSION >= 3
-#define PYTHON_PROGRAMM_NAME L"YQL::Python3"
+ #define PYTHON_PROGRAMM_NAME L"YQL::Python3"
#else
-#define PYTHON_PROGRAMM_NAME "YQL::Python2"
+ #define PYTHON_PROGRAMM_NAME "YQL::Python2"
#endif
int AddToPythonPath(const TVector<TStringBuf>& pathVals)
@@ -20,9 +20,11 @@ int AddToPythonPath(const TVector<TStringBuf>& pathVals)
char pathVar[] = "path"; // PySys_{Get,Set}Object take a non-const char* arg
TPyObjectPtr sysPath(PySys_GetObject(pathVar), TPyObjectPtr::ADD_REF);
- if (!sysPath) return -1;
+ if (!sysPath) {
+ return -1;
+ }
- for (const auto& val: pathVals) {
+ for (const auto& val : pathVals) {
TPyObjectPtr pyStr = PyRepr(val.data());
int rc = PyList_Append(sysPath.Get(), pyStr.Get());
if (rc != 0) {
@@ -45,11 +47,11 @@ void InitArcadiaPythonRuntime()
//////////////////////////////////////////////////////////////////////////////
// TPythonModule
//////////////////////////////////////////////////////////////////////////////
-class TPythonModule: public IUdfModule
-{
+class TPythonModule: public IUdfModule {
public:
TPythonModule(const TString& resourceName, EPythonFlavor pythonFlavor, bool standalone = true)
- : ResourceName_(resourceName), Standalone_(standalone)
+ : ResourceName_(resourceName)
+ , Standalone_(standalone)
{
if (Standalone_) {
Py_SetProgramName(PYTHON_PROGRAMM_NAME);
@@ -99,15 +101,15 @@ public:
PyCleanup();
}
- void GetAllFunctions(IFunctionsSink&) const final {}
+ void GetAllFunctions(IFunctionsSink&) const final {
+ }
void BuildFunctionTypeInfo(
- const TStringRef& name,
- TType* userType,
- const TStringRef& typeConfig,
- ui32 flags,
- IFunctionTypeInfoBuilder& builder) const final
- {
+ const TStringRef& name,
+ TType* userType,
+ const TStringRef& typeConfig,
+ ui32 flags,
+ IFunctionTypeInfoBuilder& builder) const final {
Y_UNUSED(typeConfig);
if (flags & TFlags::TypesOnly) {
@@ -137,44 +139,43 @@ private:
// TStubModule
//////////////////////////////////////////////////////////////////////////////
class TStubModule: public IUdfModule {
- void GetAllFunctions(IFunctionsSink&) const final {}
+ void GetAllFunctions(IFunctionsSink&) const final {
+ }
void BuildFunctionTypeInfo(
- const TStringRef& /*name*/,
- TType* /*userType*/,
- const TStringRef& /*typeConfig*/,
- ui32 flags,
- IFunctionTypeInfoBuilder& /*builder*/) const final
- {
+ const TStringRef& /*name*/,
+ TType* /*userType*/,
+ const TStringRef& /*typeConfig*/,
+ ui32 flags,
+ IFunctionTypeInfoBuilder& /*builder*/) const final {
Y_DEBUG_ABORT_UNLESS(flags & TFlags::TypesOnly,
- "in stub module this function can be called only for types loading");
+ "in stub module this function can be called only for types loading");
}
- void CleanupOnTerminate() const final {}
+ void CleanupOnTerminate() const final {
+ }
};
} // namespace
void NKikimr::NUdf::RegisterYqlPythonUdf(
- IRegistrator& registrator,
- ui32 flags,
- TStringBuf moduleName,
- TStringBuf resourceName,
- EPythonFlavor pythonFlavor)
+ IRegistrator& registrator,
+ ui32 flags,
+ TStringBuf moduleName,
+ TStringBuf resourceName,
+ EPythonFlavor pythonFlavor)
{
if (flags & IRegistrator::TFlags::TypesOnly) {
registrator.AddModule(moduleName, new TStubModule);
} else {
registrator.AddModule(
moduleName,
- NKikimr::NUdf::GetYqlPythonUdfModule(resourceName, pythonFlavor, true)
- );
+ NKikimr::NUdf::GetYqlPythonUdfModule(resourceName, pythonFlavor, true));
}
}
TUniquePtr<NKikimr::NUdf::IUdfModule> NKikimr::NUdf::GetYqlPythonUdfModule(
TStringBuf resourceName, NKikimr::NUdf::EPythonFlavor pythonFlavor,
- bool standalone
-) {
+ bool standalone) {
return new TPythonModule(TString(resourceName), pythonFlavor, standalone);
}