diff options
| author | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
|---|---|---|
| committer | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
| commit | 3e1899838408bbad47622007aa382bc8a2b01f87 (patch) | |
| tree | 0f21c1e6add187ddb6c3ccc048a7d640ce03fb87 /yt/cpp/mapreduce/common/helpers.cpp | |
| parent | 5463eb3f5e72a86f858a3d27c886470a724ede34 (diff) | |
Revert "YT-19324: move YT provider to ydb/library/yql"
This reverts commit ca272f12fdd0e8d5c3e957fc87939148f1caaf72, reversing
changes made to 49f8acfc8b0b5c0071b804423bcf53fda26c7c12.
Diffstat (limited to 'yt/cpp/mapreduce/common/helpers.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/common/helpers.cpp | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/yt/cpp/mapreduce/common/helpers.cpp b/yt/cpp/mapreduce/common/helpers.cpp deleted file mode 100644 index 95924d812c9..00000000000 --- a/yt/cpp/mapreduce/common/helpers.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "helpers.h" - -#include <yt/cpp/mapreduce/interface/config.h> -#include <yt/cpp/mapreduce/interface/serialize.h> -#include <yt/cpp/mapreduce/interface/fluent.h> - -#include <library/cpp/yson/node/node_builder.h> -#include <library/cpp/yson/node/node_visitor.h> - -#include <library/cpp/yson/parser.h> -#include <library/cpp/yson/writer.h> - -#include <library/cpp/json/json_reader.h> -#include <library/cpp/json/json_value.h> - -#include <util/stream/input.h> -#include <util/stream/output.h> -#include <util/stream/str.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -TString NodeListToYsonString(const TNode::TListType& nodes) -{ - TStringStream stream; - ::NYson::TYsonWriter writer(&stream, NYson::EYsonFormat::Binary, ::NYson::EYsonType::ListFragment); - auto list = BuildYsonListFluently(&writer); - for (const auto& node : nodes) { - list.Item().Value(node); - } - return stream.Str(); -} - -TNode PathToNode(const TRichYPath& path) -{ - TNode result; - TNodeBuilder builder(&result); - Serialize(path, &builder); - return result; -} - -TNode PathToParamNode(const TRichYPath& path) -{ - return TNode()("path", PathToNode(path)); -} - -TString AttributesToYsonString(const TNode& node) -{ - return BuildYsonStringFluently().BeginMap() - .Item("attributes").Value(node) - .EndMap(); -} - -TString AttributeFilterToYsonString(const TAttributeFilter& filter) -{ - return BuildYsonStringFluently().BeginMap() - .Item("attributes").Value(filter) - .EndMap(); -} - -TNode NodeFromTableSchema(const TTableSchema& schema) -{ - TNode result; - TNodeBuilder builder(&result); - Serialize(schema, &builder); - return result; -} - -void MergeNodes(TNode& dst, const TNode& src) -{ - if (dst.IsMap() && src.IsMap()) { - auto& dstMap = dst.AsMap(); - const auto& srcMap = src.AsMap(); - for (const auto& srcItem : srcMap) { - const auto& key = srcItem.first; - auto dstItem = dstMap.find(key); - if (dstItem != dstMap.end()) { - MergeNodes(dstItem->second, srcItem.second); - } else { - dstMap[key] = srcItem.second; - } - } - } else { - if (dst.GetType() == src.GetType() && src.HasAttributes()) { - auto attributes = dst.GetAttributes(); - MergeNodes(attributes, src.GetAttributes()); - dst = src; - dst.Attributes() = attributes; - } else { - dst = src; - } - } -} - -TYPath AddPathPrefix(const TYPath& path, const TString& pathPrefix) -{ - if (path.StartsWith("//") || path.StartsWith("#")) { - return path; - } - return pathPrefix + path; -} - -TString GetWriteTableCommand(const TString& apiVersion) -{ - return apiVersion == "v2" ? "write" : "write_table"; -} - -TString GetReadTableCommand(const TString& apiVersion) -{ - return apiVersion == "v2" ? "read" : "read_table"; -} - -TString GetWriteFileCommand(const TString& apiVersion) -{ - return apiVersion == "v2" ? "upload" : "write_file"; -} - -TString GetReadFileCommand(const TString& apiVersion) -{ - return apiVersion == "v2" ? "download" : "read_file"; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT |
