diff options
author | mskorokhod <mskorokhod@yandex-team.ru> | 2022-02-10 16:52:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:52:10 +0300 |
commit | dc5972f19ddb40b225e93b0fec8e3f8b858c1913 (patch) | |
tree | ab7fbbf3253d4c0e2793218f09378908beb025fb | |
parent | e7adae184c30da49fd2aeb27144845235abc52d0 (diff) | |
download | ydb-dc5972f19ddb40b225e93b0fec8e3f8b858c1913.tar.gz |
Restoring authorship annotation for <mskorokhod@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | util/random/random.cpp | 20 | ||||
-rw-r--r-- | util/random/random.h | 10 | ||||
-rw-r--r-- | util/random/random_ut.cpp | 14 | ||||
-rw-r--r-- | ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp | 28 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node.cpp | 134 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node.h | 132 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_cast.cpp | 4 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_printer.cpp | 38 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_printer_ut.cpp | 10 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_serialization.cpp | 104 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_ut.cpp | 48 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_visitor.cpp | 18 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_node_visitor.h | 16 | ||||
-rw-r--r-- | ydb/library/yql/minikql/mkql_program_builder.cpp | 40 | ||||
-rw-r--r-- | ydb/library/yql/providers/common/codec/yql_codec.cpp | 4 | ||||
-rw-r--r-- | ydb/library/yql/providers/common/mkql/yql_type_mkql.cpp | 6 | ||||
-rw-r--r-- | ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp | 4 |
17 files changed, 315 insertions, 315 deletions
diff --git a/util/random/random.cpp b/util/random/random.cpp index 34e7037d31..71f9323856 100644 --- a/util/random/random.cpp +++ b/util/random/random.cpp @@ -40,11 +40,11 @@ namespace { : TMersenne<T>(TProcStream().S()) { } - - inline TRndGen(T seed) - : TMersenne<T>(seed) - { - } + + inline TRndGen(T seed) + : TMersenne<T>(seed) + { + } }; template <class T> @@ -118,8 +118,8 @@ void ResetRandomState() { *GetRndGen<ui32>() = TRndGen<ui32>(); *GetRndGen<ui64>() = TRndGen<ui64>(); } - -void SetRandomSeed(int seed) { - *GetRndGen<ui32>() = TRndGen<ui32>(seed); - *GetRndGen<ui64>() = TRndGen<ui64>(seed); -} + +void SetRandomSeed(int seed) { + *GetRndGen<ui32>() = TRndGen<ui32>(seed); + *GetRndGen<ui64>() = TRndGen<ui64>(seed); +} diff --git a/util/random/random.h b/util/random/random.h index abdd190d68..16b52d3995 100644 --- a/util/random/random.h +++ b/util/random/random.h @@ -23,8 +23,8 @@ T RandomNumber(T max); * Re-initialize random state - useful after forking in multi-process programs. */ void ResetRandomState(); - -/* - * Set random SEED - */ -void SetRandomSeed(int seed); + +/* + * Set random SEED + */ +void SetRandomSeed(int seed); diff --git a/util/random/random_ut.cpp b/util/random/random_ut.cpp index 5543daa06a..30427676f3 100644 --- a/util/random/random_ut.cpp +++ b/util/random/random_ut.cpp @@ -80,10 +80,10 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) { while (!RandomNumber<bool>()) { } } - - Y_UNIT_TEST(TestResetSeed) { - SetRandomSeed(42); - for (const ui32 el : { + + Y_UNIT_TEST(TestResetSeed) { + SetRandomSeed(42); + for (const ui32 el : { 102, 179, 92, @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) { 20, 72, }) { - UNIT_ASSERT_EQUAL(RandomNumber<ui32>(1 << 8), el); - } - } + UNIT_ASSERT_EQUAL(RandomNumber<ui32>(1 << 8), el); + } + } } diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp index b771ea81b3..f2b188ae47 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_graph.cpp @@ -106,12 +106,12 @@ private: } } - void Visit(TAny& node) override { - if (node.HasItem()) { - AddNode(node.GetItem().GetNode()); - } - } - + void Visit(TAny& node) override { + if (node.HasItem()) { + AddNode(node.GetItem().GetNode()); + } + } + void Visit(TTupleLiteral& node) override { for (ui32 i = 0; i < node.GetValuesCount(); ++i) { AddNode(node.GetValue(i).GetNode()); @@ -306,8 +306,8 @@ private: VisitType<TCallableType>(node); } - void Visit(TAnyType& node) override { - VisitType<TAnyType>(node); + void Visit(TAnyType& node) override { + VisitType<TAnyType>(node); } void Visit(TTupleType& node) override { @@ -443,12 +443,12 @@ private: AddNode(node, computationNode); } - void Visit(TAny& node) override { - if (!node.HasItem()) { - AddNode(node, NodeFactory->CreateImmutableNode(NUdf::TUnboxedValue::Void())); - } else { - AddNode(node, GetComputationNode(node.GetItem().GetNode())); - } + void Visit(TAny& node) override { + if (!node.HasItem()) { + AddNode(node, NodeFactory->CreateImmutableNode(NUdf::TUnboxedValue::Void())); + } else { + AddNode(node, GetComputationNode(node.GetItem().GetNode())); + } } void Visit(TTupleLiteral& node) override { diff --git a/ydb/library/yql/minikql/mkql_node.cpp b/ydb/library/yql/minikql/mkql_node.cpp index 763b5a922f..4c6f3e45ad 100644 --- a/ydb/library/yql/minikql/mkql_node.cpp +++ b/ydb/library/yql/minikql/mkql_node.cpp @@ -32,9 +32,9 @@ TTypeEnvironment::TTypeEnvironment(TScopedAlloc& alloc) EmptyList = TEmptyList::Create(*this); TypeOfEmptyDict = TEmptyDictType::Create(TypeOfType, *this); EmptyDict = TEmptyDict::Create(*this); - Ui32 = TDataType::Create(NUdf::TDataType<ui32>::Id, *this); + Ui32 = TDataType::Create(NUdf::TDataType<ui32>::Id, *this); Ui64 = TDataType::Create(NUdf::TDataType<ui64>::Id, *this); - AnyType = TAnyType::Create(TypeOfType, *this); + AnyType = TAnyType::Create(TypeOfType, *this); EmptyStruct = TStructLiteral::Create(0, nullptr, TStructType::Create(0, nullptr, *this), *this); EmptyTuple = TTupleLiteral::Create(0, nullptr, TTupleType::Create(0, nullptr, *this), *this); ListOfVoid = TListLiteral::Create(nullptr, 0, TListType::Create(Void->GetGenericType(), *this), *this); @@ -55,7 +55,7 @@ void TTypeEnvironment::ClearCookies() const { EmptyDict->SetCookie(0); EmptyStruct->SetCookie(0); ListOfVoid->SetCookie(0); - AnyType->SetCookie(0); + AnyType->SetCookie(0); EmptyTuple->SetCookie(0); } @@ -70,7 +70,7 @@ void TTypeEnvironment::ClearCookies() const { xx(Optional, TOptionalLiteral) \ xx(Dict, TDictLiteral) \ xx(Callable, TCallable) \ - xx(Any, TAny) \ + xx(Any, TAny) \ xx(Tuple, TTupleLiteral) \ xx(Variant, TVariantLiteral) @@ -200,7 +200,7 @@ TStringBuf TType::GetKindAsStr() const { xx(Optional, TOptionalType) \ xx(Dict, TDictType) \ xx(Callable, TCallableType) \ - xx(Any, TAnyType) \ + xx(Any, TAnyType) \ xx(Tuple, TTupleType) \ xx(Resource, TResourceType) \ xx(Variant, TVariantType) \ @@ -1714,7 +1714,7 @@ void TRuntimeNode::Freeze() { } } -bool TAnyType::IsSameType(const TAnyType& typeToCompare) const { +bool TAnyType::IsSameType(const TAnyType& typeToCompare) const { Y_UNUSED(typeToCompare); return true; } @@ -1724,76 +1724,76 @@ bool TAnyType::IsConvertableTo(const TAnyType& typeToCompare, bool ignoreTagged) return IsSameType(typeToCompare); } -void TAnyType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { +void TAnyType::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { Y_UNUSED(links); } -TNode* TAnyType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { +TNode* TAnyType::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { Y_UNUSED(env); - return const_cast<TAnyType*>(this); + return const_cast<TAnyType*>(this); } -void TAnyType::DoFreeze(const TTypeEnvironment& env) { +void TAnyType::DoFreeze(const TTypeEnvironment& env) { Y_UNUSED(env); } -TAnyType* TAnyType::Create(TTypeType* type, const TTypeEnvironment& env) { - return ::new(env.Allocate<TAnyType>()) TAnyType(type); -} - -TAny* TAny::Create(const TTypeEnvironment& env) { - return ::new(env.Allocate<TAny>()) TAny(env.GetAnyType()); -} - -void TAny::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { - if (Item.GetNode()) { - auto itemIt = links.find(Item.GetNode()); - if (itemIt != links.end()) { - TNode* newNode = itemIt->second; - Y_VERIFY_DEBUG(Item.GetNode()->Equals(*newNode)); - Item = TRuntimeNode(newNode, Item.IsImmediate()); - } - } -} - -TNode* TAny::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { - if (!Item.GetNode()) - return const_cast<TAny*>(this); - - auto newItemNode = (TNode*)Item.GetNode()->GetCookie(); - if (!newItemNode) { - return const_cast<TAny*>(this); - } - - auto any = TAny::Create(env); - any->SetItem(TRuntimeNode(newItemNode, Item.IsImmediate())); - return any; -} - -void TAny::DoFreeze(const TTypeEnvironment& env) { - Y_UNUSED(env); - if (Item.GetNode()) { - Item.Freeze(); - } -} - -void TAny::SetItem(TRuntimeNode newItem) { - MKQL_ENSURE(!Item.GetNode(), "item is already set"); - - Item = newItem; - Item.Freeze(); -} - -bool TAny::Equals(const TAny& nodeToCompare) const { - if (!Item.GetNode() || !nodeToCompare.Item.GetNode()) - return false; - - if (!Item.IsImmediate() != !nodeToCompare.Item.IsImmediate()) - return false; - - return Item.GetNode()->Equals(*nodeToCompare.Item.GetNode()); -} - +TAnyType* TAnyType::Create(TTypeType* type, const TTypeEnvironment& env) { + return ::new(env.Allocate<TAnyType>()) TAnyType(type); +} + +TAny* TAny::Create(const TTypeEnvironment& env) { + return ::new(env.Allocate<TAny>()) TAny(env.GetAnyType()); +} + +void TAny::DoUpdateLinks(const THashMap<TNode*, TNode*>& links) { + if (Item.GetNode()) { + auto itemIt = links.find(Item.GetNode()); + if (itemIt != links.end()) { + TNode* newNode = itemIt->second; + Y_VERIFY_DEBUG(Item.GetNode()->Equals(*newNode)); + Item = TRuntimeNode(newNode, Item.IsImmediate()); + } + } +} + +TNode* TAny::DoCloneOnCallableWrite(const TTypeEnvironment& env) const { + if (!Item.GetNode()) + return const_cast<TAny*>(this); + + auto newItemNode = (TNode*)Item.GetNode()->GetCookie(); + if (!newItemNode) { + return const_cast<TAny*>(this); + } + + auto any = TAny::Create(env); + any->SetItem(TRuntimeNode(newItemNode, Item.IsImmediate())); + return any; +} + +void TAny::DoFreeze(const TTypeEnvironment& env) { + Y_UNUSED(env); + if (Item.GetNode()) { + Item.Freeze(); + } +} + +void TAny::SetItem(TRuntimeNode newItem) { + MKQL_ENSURE(!Item.GetNode(), "item is already set"); + + Item = newItem; + Item.Freeze(); +} + +bool TAny::Equals(const TAny& nodeToCompare) const { + if (!Item.GetNode() || !nodeToCompare.Item.GetNode()) + return false; + + if (!Item.IsImmediate() != !nodeToCompare.Item.IsImmediate()) + return false; + + return Item.GetNode()->Equals(*nodeToCompare.Item.GetNode()); +} + TTupleType::TTupleType(ui32 elementsCount, TType** elements, const TTypeEnvironment& env, bool validate) : TType(EKind::Tuple, env.GetTypeOfType()) , ElementsCount(elementsCount) diff --git a/ydb/library/yql/minikql/mkql_node.h b/ydb/library/yql/minikql/mkql_node.h index 1525b003de..ee74455ea6 100644 --- a/ydb/library/yql/minikql/mkql_node.h +++ b/ydb/library/yql/minikql/mkql_node.h @@ -139,7 +139,7 @@ class TTypeEnvironment; XX(Optional, 7) \ XX(Dict, 8) \ XX(Callable, 9) \ - XX(Any, 10) \ + XX(Any, 10) \ XX(Tuple, 11) \ XX(Resource, 12) \ XX(Flow, 13) \ @@ -425,23 +425,23 @@ public: return ListOfVoid; } - TAnyType* GetAnyType() const { - return AnyType; - } - + TAnyType* GetAnyType() const { + return AnyType; + } + TTupleLiteral* GetEmptyTuple() const { return EmptyTuple; } - TDataType* GetUi32() const { - return Ui32; - } - + TDataType* GetUi32() const { + return Ui32; + } + TDataType* GetUi64() const { return Ui64; } - + std::vector<TNode*>& GetNodeStack() const { return Stack; } @@ -485,9 +485,9 @@ private: TEmptyList* EmptyList; TEmptyDictType* TypeOfEmptyDict; TEmptyDict* EmptyDict; - TDataType* Ui32; + TDataType* Ui32; TDataType* Ui64; - TAnyType* AnyType; + TAnyType* AnyType; TStructLiteral* EmptyStruct; TTupleLiteral* EmptyTuple; TListLiteral* ListOfVoid; @@ -1061,61 +1061,61 @@ inline TType* TRuntimeNode::GetStaticType() const { } } -class TAnyType : public TType { -friend class TTypeEnvironment; -friend class TType; -public: - using TType::IsSameType; - bool IsSameType(const TAnyType& typeToCompare) const; - - using TType::IsConvertableTo; +class TAnyType : public TType { +friend class TTypeEnvironment; +friend class TType; +public: + using TType::IsSameType; + bool IsSameType(const TAnyType& typeToCompare) const; + + using TType::IsConvertableTo; bool IsConvertableTo(const TAnyType& typeToCompare, bool ignoreTagged = false) const; - -private: - TAnyType(TTypeType* type) - : TType(EKind::Any, type) - {} - - static TAnyType* Create(TTypeType* type, const TTypeEnvironment& env); - - void DoUpdateLinks(const THashMap<TNode*, TNode*>& links); - TNode* DoCloneOnCallableWrite(const TTypeEnvironment& env) const; - void DoFreeze(const TTypeEnvironment& env); -}; - -class TAny : public TNode { -friend class TNode; -public: - static TAny* Create(const TTypeEnvironment& env); - TAnyType* GetType() const { - return static_cast<TAnyType*>(GetGenericType()); - } - - bool HasItem() const { - return !!Item.GetNode(); - } - - TRuntimeNode GetItem() const { - Y_VERIFY_DEBUG(Item.GetNode()); - return Item; - } - - void SetItem(TRuntimeNode newItem); -private: - TAny(TAnyType* type) - : TNode(type) - {} - - using TNode::Equals; - bool Equals(const TAny& nodeToCompare) const; - - void DoUpdateLinks(const THashMap<TNode*, TNode*>& links); - TNode* DoCloneOnCallableWrite(const TTypeEnvironment& env) const; - void DoFreeze(const TTypeEnvironment& env); -private: - TRuntimeNode Item; -}; - + +private: + TAnyType(TTypeType* type) + : TType(EKind::Any, type) + {} + + static TAnyType* Create(TTypeType* type, const TTypeEnvironment& env); + + void DoUpdateLinks(const THashMap<TNode*, TNode*>& links); + TNode* DoCloneOnCallableWrite(const TTypeEnvironment& env) const; + void DoFreeze(const TTypeEnvironment& env); +}; + +class TAny : public TNode { +friend class TNode; +public: + static TAny* Create(const TTypeEnvironment& env); + TAnyType* GetType() const { + return static_cast<TAnyType*>(GetGenericType()); + } + + bool HasItem() const { + return !!Item.GetNode(); + } + + TRuntimeNode GetItem() const { + Y_VERIFY_DEBUG(Item.GetNode()); + return Item; + } + + void SetItem(TRuntimeNode newItem); +private: + TAny(TAnyType* type) + : TNode(type) + {} + + using TNode::Equals; + bool Equals(const TAny& nodeToCompare) const; + + void DoUpdateLinks(const THashMap<TNode*, TNode*>& links); + TNode* DoCloneOnCallableWrite(const TTypeEnvironment& env) const; + void DoFreeze(const TTypeEnvironment& env); +private: + TRuntimeNode Item; +}; + class TTupleType : public TType { friend class TType; public: diff --git a/ydb/library/yql/minikql/mkql_node_cast.cpp b/ydb/library/yql/minikql/mkql_node_cast.cpp index fc9ff9a434..0a62a7d615 100644 --- a/ydb/library/yql/minikql/mkql_node_cast.cpp +++ b/ydb/library/yql/minikql/mkql_node_cast.cpp @@ -37,7 +37,7 @@ namespace NKikimr { namespace NMiniKQL { -MKQL_AS_TYPE(Any) +MKQL_AS_TYPE(Any) MKQL_AS_TYPE(Callable) MKQL_AS_TYPE(Data) MKQL_AS_TYPE(Dict) @@ -54,7 +54,7 @@ MKQL_AS_TYPE(Flow) MKQL_AS_TYPE(Tagged) MKQL_AS_TYPE(Block) -MKQL_AS_VALUE(Any, Type) +MKQL_AS_VALUE(Any, Type) MKQL_AS_VALUE(Callable, Type) MKQL_AS_VALUE(Data, Type) MKQL_AS_VALUE(Dict, Type) diff --git a/ydb/library/yql/minikql/mkql_node_printer.cpp b/ydb/library/yql/minikql/mkql_node_printer.cpp index ca90149d3f..f7515a3005 100644 --- a/ydb/library/yql/minikql/mkql_node_printer.cpp +++ b/ydb/library/yql/minikql/mkql_node_printer.cpp @@ -345,10 +345,10 @@ namespace { WriteNewline(); } - void Visit(TAnyType& node) override { + void Visit(TAnyType& node) override { Y_UNUSED(node); WriteIndentation(); - Out << "Type (Any) "; + Out << "Type (Any) "; WriteNewline(); } @@ -680,29 +680,29 @@ namespace { WriteNewline(); } - void Visit(TAny& node) override { + void Visit(TAny& node) override { WriteIndentation(); - Out << "Any " << (node.HasItem() ? "with data" : "empty") << " {"; + Out << "Any " << (node.HasItem() ? "with data" : "empty") << " {"; WriteNewline(); { TIndentScope scope(this); node.GetType()->Accept(*this); - if (node.HasItem()) { - WriteIndentation(); - const auto& item = node.GetItem(); - Out << "Item " << (item.IsImmediate() ? "immediate" : "not immediate") << " {"; - WriteNewline(); - - { - TIndentScope scope2(this); - item.GetNode()->Accept(*this); - } - - WriteIndentation(); - Out << "}"; - WriteNewline(); - } + if (node.HasItem()) { + WriteIndentation(); + const auto& item = node.GetItem(); + Out << "Item " << (item.IsImmediate() ? "immediate" : "not immediate") << " {"; + WriteNewline(); + + { + TIndentScope scope2(this); + item.GetNode()->Accept(*this); + } + + WriteIndentation(); + Out << "}"; + WriteNewline(); + } } WriteIndentation(); diff --git a/ydb/library/yql/minikql/mkql_node_printer_ut.cpp b/ydb/library/yql/minikql/mkql_node_printer_ut.cpp index 0dc6d19f46..ec8c5d1afe 100644 --- a/ydb/library/yql/minikql/mkql_node_printer_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_printer_ut.cpp @@ -55,11 +55,11 @@ namespace { TCallable* callable = TCallable::Create(callableArgs.size(), callableArgs.data(), ctype1, env); callable->SetResult(TRuntimeNode(TDataLiteral::Create(NUdf::TUnboxedValuePod(u), dtype1, env), true), env); structBuilder.Add("31", TRuntimeNode(callable, true)); - structBuilder.Add("32", TRuntimeNode(env.GetAnyType(), true)); - structBuilder.Add("33", TRuntimeNode(TAny::Create(env), true)); - auto anyWithData = TAny::Create(env); - anyWithData->SetItem(TRuntimeNode(env.GetVoid(), true)); - structBuilder.Add("34", TRuntimeNode(anyWithData, true)); + structBuilder.Add("32", TRuntimeNode(env.GetAnyType(), true)); + structBuilder.Add("33", TRuntimeNode(TAny::Create(env), true)); + auto anyWithData = TAny::Create(env); + anyWithData->SetItem(TRuntimeNode(env.GetVoid(), true)); + structBuilder.Add("34", TRuntimeNode(anyWithData, true)); structBuilder.Add("35", TRuntimeNode(TCallableType::Create("My callable 2", dtype2, callableArgs.size(), smallTypes.data(), env.GetVoid(), env), true)); diff --git a/ydb/library/yql/minikql/mkql_node_serialization.cpp b/ydb/library/yql/minikql/mkql_node_serialization.cpp index c82f287710..e314f38cd6 100644 --- a/ydb/library/yql/minikql/mkql_node_serialization.cpp +++ b/ydb/library/yql/minikql/mkql_node_serialization.cpp @@ -290,7 +290,7 @@ namespace { void Visit(TAnyType& node) override { Y_UNUSED(node); - Owner.Write(TypeMarker | (char)TType::EKind::Any); + Owner.Write(TypeMarker | (char)TType::EKind::Any); IsProcessed0 = true; } @@ -481,22 +481,22 @@ namespace { } void Visit(TAny& node) override { - if (node.GetCookie() != 0) { - Owner.WriteReference(node); - IsProcessed0 = true; - return; - } - - TRuntimeNode item; - if (node.HasItem()) - item = node.GetItem(); - - Owner.Write((char)TType::EKind::Any | (item.GetNode() ? UserMarker1 : 0) | (item.IsImmediate() ? UserMarker2 : 0)); - if (item.GetNode()) { - Owner.AddChildNode(*item.GetNode()); - } - - IsProcessed0 = false; + if (node.GetCookie() != 0) { + Owner.WriteReference(node); + IsProcessed0 = true; + return; + } + + TRuntimeNode item; + if (node.HasItem()) + item = node.GetItem(); + + Owner.Write((char)TType::EKind::Any | (item.GetNode() ? UserMarker1 : 0) | (item.IsImmediate() ? UserMarker2 : 0)); + if (item.GetNode()) { + Owner.AddChildNode(*item.GetNode()); + } + + IsProcessed0 = false; } void Visit(TTupleLiteral& node) override { @@ -622,7 +622,7 @@ namespace { Owner.RegisterReference(node); } - void Visit(TAnyType& node) override { + void Visit(TAnyType& node) override { Y_UNUSED(node); } @@ -814,9 +814,9 @@ namespace { Owner.RegisterReference(node); } - void Visit(TAny& node) override { - Owner.RegisterReference(node); - } + void Visit(TAny& node) override { + Owner.RegisterReference(node); + } void Visit(TTupleLiteral& node) override { auto type = node.GetType(); @@ -1150,7 +1150,7 @@ namespace { return 2; case TType::EKind::Callable: return TryReadCallableType(code); - case TType::EKind::Any: + case TType::EKind::Any: return 0; case TType::EKind::Tuple: return TryReadTupleType(); @@ -1187,8 +1187,8 @@ namespace { return ReadDictType(); case TType::EKind::Callable: return ReadCallableType(code); - case TType::EKind::Any: - return ReadAnyType(); + case TType::EKind::Any: + return ReadAnyType(); case TType::EKind::Tuple: return ReadTupleType(); case TType::EKind::Resource: @@ -1443,9 +1443,9 @@ namespace { return node; } - TNode* ReadAnyType() { - auto node = Env.GetAnyType(); - return node; + TNode* ReadAnyType() { + auto node = Env.GetAnyType(); + return node; } TNode* ReadResourceType() { @@ -1485,8 +1485,8 @@ namespace { return TryReadDictLiteral(); case TType::EKind::Callable: return TryReadCallable(code, pass); - case TType::EKind::Any: - return TryReadAny(code); + case TType::EKind::Any: + return TryReadAny(code); case TType::EKind::Tuple: return TryReadTupleLiteral(pass); case TType::EKind::Variant: @@ -1517,8 +1517,8 @@ namespace { return ReadDictLiteral(); case TType::EKind::Callable: return ReadCallable(code); - case TType::EKind::Any: - return ReadAny(code); + case TType::EKind::Any: + return ReadAny(code); case TType::EKind::Tuple: return ReadTupleLiteral(); case TType::EKind::Variant: @@ -1542,9 +1542,9 @@ namespace { TNode* ReadNull() { auto node = Env.GetNull(); - return node; - } - + return node; + } + TNode* ReadDataLiteral() { auto type = PopNode(); if (type->GetType()->GetKind() != TType::EKind::Type) @@ -1935,24 +1935,24 @@ namespace { return node; } - ui32 TryReadAny(char code) { - const bool hasItem = (code & UserMarker1) != 0; - return hasItem ? 1 : 0; - } - - TNode* ReadAny(char code) { - const bool hasItem = (code & UserMarker1) != 0; - const bool isItemImmediate = (code & UserMarker2) != 0; - TAny* node = TAny::Create(Env); - if (hasItem) { - auto item = PopNode(); - node->SetItem(TRuntimeNode(item, isItemImmediate)); - } - - Nodes.push_back(node); - return node; - } - + ui32 TryReadAny(char code) { + const bool hasItem = (code & UserMarker1) != 0; + return hasItem ? 1 : 0; + } + + TNode* ReadAny(char code) { + const bool hasItem = (code & UserMarker1) != 0; + const bool isItemImmediate = (code & UserMarker2) != 0; + TAny* node = TAny::Create(Env); + if (hasItem) { + auto item = PopNode(); + node->SetItem(TRuntimeNode(item, isItemImmediate)); + } + + Nodes.push_back(node); + return node; + } + TNode* ReadVariantLiteral(char code) { const bool isItemImmediate = (code & UserMarker1) != 0; auto type = PopNode(); diff --git a/ydb/library/yql/minikql/mkql_node_ut.cpp b/ydb/library/yql/minikql/mkql_node_ut.cpp index d6724d8679..1612627246 100644 --- a/ydb/library/yql/minikql/mkql_node_ut.cpp +++ b/ydb/library/yql/minikql/mkql_node_ut.cpp @@ -405,37 +405,37 @@ Y_UNIT_TEST_SUITE(TMiniKQLNodeTest) { visitor.Visit(*env.GetTypeOfType()); } - Y_UNIT_TEST(TesAnyType) { + Y_UNIT_TEST(TesAnyType) { TScopedAlloc alloc; TTypeEnvironment env(alloc); - UNIT_ASSERT(env.GetAnyType()->IsSameType(*env.GetAnyType())); + UNIT_ASSERT(env.GetAnyType()->IsSameType(*env.GetAnyType())); } - Y_UNIT_TEST(TestAny) { + Y_UNIT_TEST(TestAny) { TScopedAlloc alloc; TTypeEnvironment env(alloc); - TAny* emptyAny = TAny::Create(env); - UNIT_ASSERT(!emptyAny->HasItem()); - TAny* emptyAny2 = TAny::Create(env); - UNIT_ASSERT(!emptyAny->TNode::Equals(*emptyAny2)); - - TDataType* dtype1 = TDataType::Create(NUdf::TDataType<char*>::Id, env); - TString u = "34567"; - auto item1 = TRuntimeNode(TDataLiteral::Create( - NUdf::TUnboxedValuePod::Embedded(u), dtype1, env), true); - - TAny* any1 = TAny::Create(env); - any1->SetItem(item1); - UNIT_ASSERT(any1->HasItem()); - UNIT_ASSERT_EQUAL(any1->GetItem().GetNode()->GetType()->GetKind(), TType::EKind::Data); + TAny* emptyAny = TAny::Create(env); + UNIT_ASSERT(!emptyAny->HasItem()); + TAny* emptyAny2 = TAny::Create(env); + UNIT_ASSERT(!emptyAny->TNode::Equals(*emptyAny2)); + + TDataType* dtype1 = TDataType::Create(NUdf::TDataType<char*>::Id, env); + TString u = "34567"; + auto item1 = TRuntimeNode(TDataLiteral::Create( + NUdf::TUnboxedValuePod::Embedded(u), dtype1, env), true); + + TAny* any1 = TAny::Create(env); + any1->SetItem(item1); + UNIT_ASSERT(any1->HasItem()); + UNIT_ASSERT_EQUAL(any1->GetItem().GetNode()->GetType()->GetKind(), TType::EKind::Data); UNIT_ASSERT_EQUAL(static_cast<const TDataLiteral&>(*any1->GetItem().GetNode()).AsValue().AsStringRef(), NUdf::TStringRef::Of("34567")); - - auto item2 = TRuntimeNode(TDataLiteral::Create( - NUdf::TUnboxedValuePod::Embedded(u), dtype1, env), true); - TAny* any2 = TAny::Create(env); - any2->SetItem(item2); - - UNIT_ASSERT(any1->TNode::Equals(*any2)); + + auto item2 = TRuntimeNode(TDataLiteral::Create( + NUdf::TUnboxedValuePod::Embedded(u), dtype1, env), true); + TAny* any2 = TAny::Create(env); + any2->SetItem(item2); + + UNIT_ASSERT(any1->TNode::Equals(*any2)); } Y_UNIT_TEST(TestTupleType) { diff --git a/ydb/library/yql/minikql/mkql_node_visitor.cpp b/ydb/library/yql/minikql/mkql_node_visitor.cpp index 0ba4d1c7f2..5a4ac8e479 100644 --- a/ydb/library/yql/minikql/mkql_node_visitor.cpp +++ b/ydb/library/yql/minikql/mkql_node_visitor.cpp @@ -66,7 +66,7 @@ void TThrowingNodeVisitor::Visit(TCallableType& node) { ThrowUnexpectedNodeType(); } -void TThrowingNodeVisitor::Visit(TAnyType& node) { +void TThrowingNodeVisitor::Visit(TAnyType& node) { Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -136,7 +136,7 @@ void TThrowingNodeVisitor::Visit(TCallable& node) { ThrowUnexpectedNodeType(); } -void TThrowingNodeVisitor::Visit(TAny& node) { +void TThrowingNodeVisitor::Visit(TAny& node) { Y_UNUSED(node); ThrowUnexpectedNodeType(); } @@ -219,7 +219,7 @@ void TEmptyNodeVisitor::Visit(TCallableType& node) { Y_UNUSED(node); } -void TEmptyNodeVisitor::Visit(TAnyType& node) { +void TEmptyNodeVisitor::Visit(TAnyType& node) { Y_UNUSED(node); } @@ -275,7 +275,7 @@ void TEmptyNodeVisitor::Visit(TCallable& node) { Y_UNUSED(node); } -void TEmptyNodeVisitor::Visit(TAny& node) { +void TEmptyNodeVisitor::Visit(TAny& node) { Y_UNUSED(node); } @@ -362,7 +362,7 @@ void TExploringNodeVisitor::Visit(TCallableType& node) { } } -void TExploringNodeVisitor::Visit(TAnyType& node) { +void TExploringNodeVisitor::Visit(TAnyType& node) { AddChildNode(&node, *node.GetType()); } @@ -442,11 +442,11 @@ void TExploringNodeVisitor::Visit(TCallable& node) { AddChildNode(&node, *node.GetResult().GetNode()); } -void TExploringNodeVisitor::Visit(TAny& node) { +void TExploringNodeVisitor::Visit(TAny& node) { AddChildNode(&node, *node.GetType()); - if (node.HasItem()) { - AddChildNode(&node, *node.GetItem().GetNode()); - } + if (node.HasItem()) { + AddChildNode(&node, *node.GetItem().GetNode()); + } } void TExploringNodeVisitor::Visit(TTupleLiteral& node) { diff --git a/ydb/library/yql/minikql/mkql_node_visitor.h b/ydb/library/yql/minikql/mkql_node_visitor.h index baf52b5e9f..f5bf76d520 100644 --- a/ydb/library/yql/minikql/mkql_node_visitor.h +++ b/ydb/library/yql/minikql/mkql_node_visitor.h @@ -25,7 +25,7 @@ public: virtual void Visit(TOptionalType& node) = 0; virtual void Visit(TDictType& node) = 0; virtual void Visit(TCallableType& node) = 0; - virtual void Visit(TAnyType& node) = 0; + virtual void Visit(TAnyType& node) = 0; virtual void Visit(TTupleType& node) = 0; virtual void Visit(TResourceType& node) = 0; virtual void Visit(TVariantType& node) = 0; @@ -39,7 +39,7 @@ public: virtual void Visit(TOptionalLiteral& node) = 0; virtual void Visit(TDictLiteral& node) = 0; virtual void Visit(TCallable& node) = 0; - virtual void Visit(TAny& node) = 0; + virtual void Visit(TAny& node) = 0; virtual void Visit(TTupleLiteral& node) = 0; virtual void Visit(TVariantLiteral& node) = 0; virtual void Visit(TStreamType& node) = 0; @@ -61,7 +61,7 @@ public: void Visit(TOptionalType& node) override; void Visit(TDictType& node) override; void Visit(TCallableType& node) override; - void Visit(TAnyType& node) override; + void Visit(TAnyType& node) override; void Visit(TTupleType& node) override; void Visit(TResourceType& node) override; void Visit(TVariantType& node) override; @@ -75,7 +75,7 @@ public: void Visit(TOptionalLiteral& node) override; void Visit(TDictLiteral& node) override; void Visit(TCallable& node) override; - void Visit(TAny& node) override; + void Visit(TAny& node) override; void Visit(TTupleLiteral& node) override; void Visit(TVariantLiteral& node) override; void Visit(TStreamType& node) override; @@ -100,7 +100,7 @@ public: void Visit(TOptionalType& node) override; void Visit(TDictType& node) override; void Visit(TCallableType& node) override; - void Visit(TAnyType& node) override; + void Visit(TAnyType& node) override; void Visit(TTupleType& node) override; void Visit(TResourceType& node) override; void Visit(TVariantType& node) override; @@ -114,7 +114,7 @@ public: void Visit(TOptionalLiteral& node) override; void Visit(TDictLiteral& node) override; void Visit(TCallable& node) override; - void Visit(TAny& node) override; + void Visit(TAny& node) override; void Visit(TTupleLiteral& node) override; void Visit(TVariantLiteral& node) override; void Visit(TStreamType& node) override; @@ -138,7 +138,7 @@ public: void Visit(TOptionalType& node) override; void Visit(TDictType& node) override; void Visit(TCallableType& node) override; - void Visit(TAnyType& node) override; + void Visit(TAnyType& node) override; void Visit(TTupleType& node) override; void Visit(TResourceType& node) override; void Visit(TVariantType& node) override; @@ -152,7 +152,7 @@ public: void Visit(TOptionalLiteral& node) override; void Visit(TDictLiteral& node) override; void Visit(TCallable& node) override; - void Visit(TAny& node) override; + void Visit(TAny& node) override; void Visit(TTupleLiteral& node) override; void Visit(TVariantLiteral& node) override; void Visit(TStreamType& node) override; diff --git a/ydb/library/yql/minikql/mkql_program_builder.cpp b/ydb/library/yql/minikql/mkql_program_builder.cpp index c8504c8560..47ae6e4c8f 100644 --- a/ydb/library/yql/minikql/mkql_program_builder.cpp +++ b/ydb/library/yql/minikql/mkql_program_builder.cpp @@ -31,7 +31,7 @@ struct TDataFunctionFlags { RequiresStringArgs = 0x80, RequiresHash = 0x100, RequiresEquals = 0x200, - AllowNull = 0x400, + AllowNull = 0x400, CommonOptionalResult = 0x800, SupportsTuple = 0x1000, SameOptionalArgs = 0x2000, @@ -45,22 +45,22 @@ struct TDataFunctionFlags { MKQL_ENSURE(false, "Can't convert " #NodeType " to " ScriptName " object"); \ } -class TPythonTypeChecker : public TExploringNodeVisitor { - using TExploringNodeVisitor::Visit; - MKQL_BAD_TYPE_VISIT(TAnyType, "Python"); -}; +class TPythonTypeChecker : public TExploringNodeVisitor { + using TExploringNodeVisitor::Visit; + MKQL_BAD_TYPE_VISIT(TAnyType, "Python"); +}; class TLuaTypeChecker : public TExploringNodeVisitor { using TExploringNodeVisitor::Visit; MKQL_BAD_TYPE_VISIT(TVoidType, "Lua"); - MKQL_BAD_TYPE_VISIT(TAnyType, "Lua"); + MKQL_BAD_TYPE_VISIT(TAnyType, "Lua"); MKQL_BAD_TYPE_VISIT(TVariantType, "Lua"); }; -class TJavascriptTypeChecker : public TExploringNodeVisitor { - using TExploringNodeVisitor::Visit; - MKQL_BAD_TYPE_VISIT(TAnyType, "Javascript"); -}; +class TJavascriptTypeChecker : public TExploringNodeVisitor { + using TExploringNodeVisitor::Visit; + MKQL_BAD_TYPE_VISIT(TAnyType, "Javascript"); +}; #undef MKQL_BAD_TYPE_VISIT @@ -3047,10 +3047,10 @@ TRuntimeNode TProgramBuilder::UnaryDataFunction(TRuntimeNode data, const std::st MKQL_ENSURE(schemeType == NUdf::TDataType<char*>::Id, "String data is required"); } - if (!schemeType) { - MKQL_ENSURE((flags & TDataFunctionFlags::AllowNull) != 0, "Null is not allowed"); - } - + if (!schemeType) { + MKQL_ENSURE((flags & TDataFunctionFlags::AllowNull) != 0, "Null is not allowed"); + } + TType* resultType; if (flags & TDataFunctionFlags::HasBooleanResult) { resultType = TDataType::Create(NUdf::TDataType<bool>::Id, Env); @@ -3864,15 +3864,15 @@ TRuntimeNode TProgramBuilder::Callable(TType* callableType, const TArrayLambda& return TRuntimeNode(callableBuilder.Build(), false); } -TRuntimeNode TProgramBuilder::NewNull() { +TRuntimeNode TProgramBuilder::NewNull() { if (!UseNullType || RuntimeVersion < 11) { TCallableBuilder callableBuilder(Env, "Null", NewOptionalType(Env.GetVoid()->GetType())); return TRuntimeNode(callableBuilder.Build(), false); } else { return TRuntimeNode(Env.GetNull(), true); } -} - +} + TRuntimeNode TProgramBuilder::Concat(TRuntimeNode data1, TRuntimeNode data2) { bool isOpt1, isOpt2; const auto type1 = UnpackOptionalData(data1, isOpt1)->GetSchemeType(); @@ -3924,7 +3924,7 @@ TRuntimeNode TProgramBuilder::ByteAt(TRuntimeNode data, TRuntimeNode index) { } TRuntimeNode TProgramBuilder::Size(TRuntimeNode data) { - return UnaryDataFunction(data, __func__, TDataFunctionFlags::HasUi32Result | TDataFunctionFlags::AllowNull | TDataFunctionFlags::AllowOptionalArgs | TDataFunctionFlags::CommonOptionalResult); + return UnaryDataFunction(data, __func__, TDataFunctionFlags::HasUi32Result | TDataFunctionFlags::AllowNull | TDataFunctionFlags::AllowOptionalArgs | TDataFunctionFlags::CommonOptionalResult); } template <bool Utf8> @@ -3943,7 +3943,7 @@ TRuntimeNode TProgramBuilder::FromString(TRuntimeNode data, TType* type) { const auto sourceType = UnpackOptionalData(data, isOptional); const auto targetType = UnpackOptionalData(type, isOptional); MKQL_ENSURE(sourceType->GetSchemeType() == NUdf::TDataType<char*>::Id || sourceType->GetSchemeType() == NUdf::TDataType<NUdf::TUtf8>::Id, "Expected String"); - MKQL_ENSURE(targetType->GetSchemeType() != 0, "Null is not allowed"); + MKQL_ENSURE(targetType->GetSchemeType() != 0, "Null is not allowed"); TCallableBuilder callableBuilder(Env, __func__, type); callableBuilder.Add(data); callableBuilder.Add(NewDataLiteral(static_cast<ui32>(targetType->GetSchemeType()))); @@ -3960,7 +3960,7 @@ TRuntimeNode TProgramBuilder::StrictFromString(TRuntimeNode data, TType* type) { const auto sourceType = UnpackOptionalData(data, isOptional); const auto targetType = UnpackOptionalData(type, isOptional); MKQL_ENSURE(sourceType->GetSchemeType() == NUdf::TDataType<char*>::Id || sourceType->GetSchemeType() == NUdf::TDataType<NUdf::TUtf8>::Id, "Expected String"); - MKQL_ENSURE(targetType->GetSchemeType() != 0, "Null is not allowed"); + MKQL_ENSURE(targetType->GetSchemeType() != 0, "Null is not allowed"); TCallableBuilder callableBuilder(Env, __func__, type); callableBuilder.Add(data); callableBuilder.Add(NewDataLiteral(static_cast<ui32>(targetType->GetSchemeType()))); diff --git a/ydb/library/yql/providers/common/codec/yql_codec.cpp b/ydb/library/yql/providers/common/codec/yql_codec.cpp index 6f1207a3e7..7587e188fa 100644 --- a/ydb/library/yql/providers/common/codec/yql_codec.cpp +++ b/ydb/library/yql/providers/common/codec/yql_codec.cpp @@ -35,8 +35,8 @@ void WriteYsonValueImpl(TYsonResultWriter& writer, const NUdf::TUnboxedValuePod& // Result format switch (type->GetKind()) { case TType::EKind::Void: - writer.OnVoid(); - return; + writer.OnVoid(); + return; case TType::EKind::Null: writer.OnNull(); return; diff --git a/ydb/library/yql/providers/common/mkql/yql_type_mkql.cpp b/ydb/library/yql/providers/common/mkql/yql_type_mkql.cpp index 572ac50cbf..4ba0e6d740 100644 --- a/ydb/library/yql/providers/common/mkql/yql_type_mkql.cpp +++ b/ydb/library/yql/providers/common/mkql/yql_type_mkql.cpp @@ -307,9 +307,9 @@ const TTypeAnnotationNode* ConvertMiniKQLType(TPosition position, NKikimr::NMini return ctx.MakeType<TCallableExprType>(retType, arguments, callableType->GetOptionalArgumentsCount(), payload); } - case TType::EKind::Any: - YQL_ENSURE(false, "Not supported"); - break; + case TType::EKind::Any: + YQL_ENSURE(false, "Not supported"); + break; case TType::EKind::Tuple: { diff --git a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp index 9c307e66dd..0a34105714 100644 --- a/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp +++ b/ydb/library/yql/providers/common/schema/mkql/yql_mkql_schema.cpp @@ -174,13 +174,13 @@ struct TRuntimeTypeLoader { { } TMaybe<TType> LoadVoidType(ui32 /*level*/) { - return Builder.NewVoid().GetStaticType(); + return Builder.NewVoid().GetStaticType(); } TMaybe<TType> LoadNullType(ui32 /*level*/) { return Builder.NewNull().GetStaticType(); } TMaybe<TType> LoadUnitType(ui32 /*level*/) { - return Builder.NewVoid().GetStaticType(); + return Builder.NewVoid().GetStaticType(); } TMaybe<TType> LoadGenericType(ui32 /*level*/) { return Builder.GetTypeEnvironment().GetTypeOfType(); |