summaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/json2/serialize.h
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-10-06 13:26:25 +0300
committervvvv <[email protected]>2025-10-06 14:06:25 +0300
commiteca8ce9cb1613d5c983185c4e43c20651a9638aa (patch)
tree61ee5ae779948e61af9a7691d19eaa2c09869121 /yql/essentials/udfs/common/json2/serialize.h
parent4adf7eecae16a9b228b28cc5f64c27ef69ad5ec2 (diff)
YQL-20086 udfs
init commit_hash:f9684778bf1ea956965f2360b80b91edb7d4ffbe
Diffstat (limited to 'yql/essentials/udfs/common/json2/serialize.h')
-rw-r--r--yql/essentials/udfs/common/json2/serialize.h127
1 files changed, 63 insertions, 64 deletions
diff --git a/yql/essentials/udfs/common/json2/serialize.h b/yql/essentials/udfs/common/json2/serialize.h
index cda95e77f5a..2443259fbee 100644
--- a/yql/essentials/udfs/common/json2/serialize.h
+++ b/yql/essentials/udfs/common/json2/serialize.h
@@ -9,81 +9,80 @@
#include <yql/essentials/types/binary_json/write.h>
namespace NJson2Udf {
- using namespace NKikimr;
- using namespace NUdf;
- using namespace NYql;
- using namespace NDom;
- using namespace NBinaryJson;
-
- template <EDataSlot ResultType>
- class TSerialize : public TBoxedValue {
- public:
- TSerialize(TSourcePosition pos)
- : Pos_(pos)
- {
- }
+using namespace NKikimr;
+using namespace NUdf;
+using namespace NYql;
+using namespace NDom;
+using namespace NBinaryJson;
+
+template <EDataSlot ResultType>
+class TSerialize: public TBoxedValue {
+public:
+ TSerialize(TSourcePosition pos)
+ : Pos_(pos)
+ {
+ }
- static const TStringRef& Name();
+ static const TStringRef& Name();
- static bool DeclareSignature(
- const TStringRef& name,
- TType* userType,
- IFunctionTypeInfoBuilder& builder,
- bool typesOnly) {
- Y_UNUSED(userType);
- if (name != Name()) {
- return false;
- }
+ static bool DeclareSignature(
+ const TStringRef& name,
+ TType* userType,
+ IFunctionTypeInfoBuilder& builder,
+ bool typesOnly) {
+ Y_UNUSED(userType);
+ if (name != Name()) {
+ return false;
+ }
- TType* resultType = nullptr;
- if constexpr (ResultType == EDataSlot::Json) {
- resultType = builder.SimpleType<TJson>();
- } else {
- resultType = builder.SimpleType<TJsonDocument>();
- }
+ TType* resultType = nullptr;
+ if constexpr (ResultType == EDataSlot::Json) {
+ resultType = builder.SimpleType<TJson>();
+ } else {
+ resultType = builder.SimpleType<TJsonDocument>();
+ }
- builder.Args()
- ->Add<TAutoMap<TJsonNodeResource>>()
- .Done()
- .Returns(resultType);
+ builder.Args()
+ ->Add<TAutoMap<TJsonNodeResource>>()
+ .Done()
+ .Returns(resultType);
- if (!typesOnly) {
- builder.Implementation(new TSerialize(builder.GetSourcePosition()));
- }
- return true;
+ if (!typesOnly) {
+ builder.Implementation(new TSerialize(builder.GetSourcePosition()));
}
+ return true;
+ }
- private:
- TUnboxedValue Run(
- const IValueBuilder* valueBuilder,
- const TUnboxedValuePod* args) const final {
- try {
- const TUnboxedValue& jsonDom = args[0];
+private:
+ TUnboxedValue Run(
+ const IValueBuilder* valueBuilder,
+ const TUnboxedValuePod* args) const final {
+ try {
+ const TUnboxedValue& jsonDom = args[0];
- if constexpr (ResultType == EDataSlot::Json) {
- return valueBuilder->NewString(SerializeJsonDom(jsonDom));
- } else {
- const auto binaryJson = SerializeToBinaryJson(jsonDom);
- return valueBuilder->NewString(TStringBuf(binaryJson.Data(), binaryJson.Size()));
- }
- } catch (const std::exception& e) {
- UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str());
+ if constexpr (ResultType == EDataSlot::Json) {
+ return valueBuilder->NewString(SerializeJsonDom(jsonDom));
+ } else {
+ const auto binaryJson = SerializeToBinaryJson(jsonDom);
+ return valueBuilder->NewString(TStringBuf(binaryJson.Data(), binaryJson.Size()));
}
+ } catch (const std::exception& e) {
+ UdfTerminate((TStringBuilder() << Pos_ << " " << e.what()).c_str());
}
-
- TSourcePosition Pos_;
- };
-
- template <>
- const TStringRef& TSerialize<EDataSlot::Json>::Name() {
- static auto name = TStringRef::Of("Serialize");
- return name;
}
- template <>
- const TStringRef& TSerialize<EDataSlot::JsonDocument>::Name() {
- static auto name = TStringRef::Of("SerializeToJsonDocument");
- return name;
- }
+ TSourcePosition Pos_;
+};
+
+template <>
+const TStringRef& TSerialize<EDataSlot::Json>::Name() {
+ static auto name = TStringRef::Of("Serialize");
+ return name;
}
+template <>
+const TStringRef& TSerialize<EDataSlot::JsonDocument>::Name() {
+ static auto name = TStringRef::Of("SerializeToJsonDocument");
+ return name;
+}
+} // namespace NJson2Udf