Skip to content

Commit 8fe9394

Browse files
committed
BlockMapJoinCore refactor
* Split storage and index parts from BlockMapJoinCore computation node into separate BlockStorage and BlockIndex nodes in order to allow multiple join nodes to reuse the same block data and index for the right table where possible * Corresponding s-expressions changes commit_hash:40e39fb0b22c2f929c184963b5bd901006122c14
1 parent 3af8bdc commit 8fe9394

File tree

18 files changed

+975
-303
lines changed

18 files changed

+975
-303
lines changed

yql/essentials/ast/yql_type_string.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ enum EToken
9191
TOKEN_TZDATE32 = -56,
9292
TOKEN_TZDATETIME64 = -57,
9393
TOKEN_TZTIMESTAMP64 = -58,
94+
TOKEN_MULTI = -59,
9495

9596
// identifiers
9697
TOKEN_IDENTIFIER = -100,
@@ -121,6 +122,7 @@ EToken TokenTypeFromStr(TStringBuf str)
121122
{ TStringBuf("Dict"), TOKEN_DICT },
122123
{ TStringBuf("Tuple"), TOKEN_TUPLE },
123124
{ TStringBuf("Struct"), TOKEN_STRUCT },
125+
{ TStringBuf("Multi"), TOKEN_MULTI },
124126
{ TStringBuf("Resource"), TOKEN_RESOURCE },
125127
{ TStringBuf("Void"), TOKEN_VOID },
126128
{ TStringBuf("Callable"), TOKEN_CALLABLE },
@@ -267,6 +269,10 @@ class TTypeParser
267269
type = ParseStructType();
268270
break;
269271

272+
case TOKEN_MULTI:
273+
type = ParseMultiType();
274+
break;
275+
270276
case TOKEN_RESOURCE:
271277
type = ParseResourceType();
272278
break;
@@ -752,9 +758,9 @@ class TTypeParser
752758
return MakeDictType(keyType, MakeVoidType());
753759
}
754760

755-
TAstNode* ParseTupleTypeImpl() {
761+
TAstNode* ParseTupleTypeImpl(TAstNode* (TTypeParser::*typeCreator)(TSmallVec<TAstNode*>&)) {
756762
TSmallVec<TAstNode*> items;
757-
items.push_back(nullptr); // reserve for TupleType
763+
items.push_back(nullptr); // reserve for type callable
758764

759765
if (Token != '>') {
760766
for (;;) {
@@ -773,13 +779,13 @@ class TTypeParser
773779
}
774780
}
775781

776-
return MakeTupleType(items);
782+
return (this->*typeCreator)(items);
777783
}
778784

779785
TAstNode* ParseTupleType() {
780786
GetNextToken(); // eat keyword
781787
EXPECT_AND_SKIP_TOKEN('<', nullptr);
782-
TAstNode* tupleType = ParseTupleTypeImpl();
788+
TAstNode* tupleType = ParseTupleTypeImpl(&TTypeParser::MakeTupleType);
783789
if (tupleType) {
784790
EXPECT_AND_SKIP_TOKEN('>', nullptr);
785791
}
@@ -836,6 +842,16 @@ class TTypeParser
836842
return structType;
837843
}
838844

845+
TAstNode* ParseMultiType() {
846+
GetNextToken(); // eat keyword
847+
EXPECT_AND_SKIP_TOKEN('<', nullptr);
848+
TAstNode* tupleType = ParseTupleTypeImpl(&TTypeParser::MakeMultiType);
849+
if (tupleType) {
850+
EXPECT_AND_SKIP_TOKEN('>', nullptr);
851+
}
852+
return tupleType;
853+
}
854+
839855
TAstNode* ParseVariantType() {
840856
GetNextToken(); // eat keyword
841857
EXPECT_AND_SKIP_TOKEN('<', nullptr);
@@ -844,7 +860,7 @@ class TTypeParser
844860
if (Token == TOKEN_IDENTIFIER || Token == TOKEN_ESCAPED_IDENTIFIER) {
845861
underlyingType = ParseStructTypeImpl();
846862
} else if (IsTypeKeyword(Token) || Token == '(') {
847-
underlyingType = ParseTupleTypeImpl();
863+
underlyingType = ParseTupleTypeImpl(&TTypeParser::MakeTupleType);
848864
} else {
849865
return AddError("Expected type");
850866
}
@@ -995,6 +1011,11 @@ class TTypeParser
9951011
return MakeList(items.data(), items.size());
9961012
}
9971013

1014+
TAstNode* MakeMultiType(TSmallVec<TAstNode*>& items) {
1015+
items[0] = MakeLiteralAtom(TStringBuf("MultiType"));
1016+
return MakeList(items.data(), items.size());
1017+
}
1018+
9981019
TAstNode* ParseResourceType() {
9991020
GetNextToken(); // eat keyword
10001021
EXPECT_AND_SKIP_TOKEN('<', nullptr);

yql/essentials/core/expr_nodes/yql_expr_nodes.json

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,19 +1612,38 @@
16121612
{"Index": 8, "Name": "RightKeysColumnNames", "Type": "TCoAtomList"}
16131613
]
16141614
},
1615+
{
1616+
"Name": "TCoBlockStorage",
1617+
"Base": "TCallable",
1618+
"Match": {"Type": "Callable", "Name": "BlockStorage"},
1619+
"Children": [
1620+
{"Index": 0, "Name": "Input", "Type": "TExprBase"}
1621+
]
1622+
},
1623+
{
1624+
"Name": "TCoBlockMapJoinIndex",
1625+
"Base": "TCallable",
1626+
"Match": {"Type": "Callable", "Name": "BlockMapJoinIndex"},
1627+
"Children": [
1628+
{"Index": 0, "Name": "BlockStorage", "Type": "TExprBase"},
1629+
{"Index": 1, "Name": "InputType", "Type": "TExprBase"},
1630+
{"Index": 2, "Name": "KeyColumns", "Type": "TCoAtomList"},
1631+
{"Index": 3, "Name": "Options", "Type": "TExprList"}
1632+
]
1633+
},
16151634
{
16161635
"Name": "TCoBlockMapJoinCore",
16171636
"Base": "TCallable",
16181637
"Match": {"Type": "Callable", "Name": "BlockMapJoinCore"},
16191638
"Children": [
16201639
{"Index": 0, "Name": "LeftInput", "Type": "TExprBase"},
16211640
{"Index": 1, "Name": "RightInput", "Type": "TExprBase"},
1622-
{"Index": 2, "Name": "JoinKind", "Type": "TCoAtom"},
1623-
{"Index": 3, "Name": "LeftKeyColumns", "Type": "TCoAtomList"},
1624-
{"Index": 4, "Name": "LeftKeyDrops", "Type": "TCoAtomList"},
1625-
{"Index": 5, "Name": "RightKeyColumns", "Type": "TCoAtomList"},
1626-
{"Index": 6, "Name": "RightKeyDrops", "Type": "TCoAtomList"},
1627-
{"Index": 7, "Name": "Options", "Type": "TExprList"}
1641+
{"Index": 2, "Name": "RightInputType", "Type": "TExprBase"},
1642+
{"Index": 3, "Name": "JoinKind", "Type": "TCoAtom"},
1643+
{"Index": 4, "Name": "LeftKeyColumns", "Type": "TCoAtomList"},
1644+
{"Index": 5, "Name": "LeftKeyDrops", "Type": "TCoAtomList"},
1645+
{"Index": 6, "Name": "RightKeyColumns", "Type": "TCoAtomList"},
1646+
{"Index": 7, "Name": "RightKeyDrops", "Type": "TCoAtomList"}
16281647
]
16291648
},
16301649
{

yql/essentials/core/type_ann/type_ann_core.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12987,17 +12987,18 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
1298712987
Functions["BlockDecimalMul"] = &BlockDecimalBinaryWrapper;
1298812988
Functions["BlockDecimalMod"] = &BlockDecimalBinaryWrapper;
1298912989
Functions["BlockDecimalDiv"] = &BlockDecimalBinaryWrapper;
12990+
Functions["BlockStorage"] = &BlockStorageWrapper;
1299012991

1299112992
ExtFunctions["BlockFunc"] = &BlockFuncWrapper;
1299212993

12993-
Functions["BlockMapJoinCore"] = &BlockMapJoinCoreWrapper;
12994-
1299512994
ExtFunctions["AsScalar"] = &AsScalarWrapper;
1299612995
ExtFunctions["WideToBlocks"] = &WideToBlocksWrapper;
1299712996
ExtFunctions["BlockCombineAll"] = &BlockCombineAllWrapper;
1299812997
ExtFunctions["BlockCombineHashed"] = &BlockCombineHashedWrapper;
1299912998
ExtFunctions["BlockMergeFinalizeHashed"] = &BlockMergeFinalizeHashedWrapper;
1300012999
ExtFunctions["BlockMergeManyFinalizeHashed"] = &BlockMergeFinalizeHashedWrapper;
13000+
ExtFunctions["BlockMapJoinIndex"] = &BlockMapJoinIndexWrapper;
13001+
ExtFunctions["BlockMapJoinCore"] = &BlockMapJoinCoreWrapper;
1300113002

1300213003
ExtFunctions["SqlRename"] = &SqlRenameWrapper;
1300313004
ExtFunctions["OrderedSqlRename"] = &SqlRenameWrapper;

yql/essentials/core/type_ann/type_ann_impl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace NTypeAnnImpl {
3535
IGraphTransformer::TStatus CombineCoreWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx);
3636
IGraphTransformer::TStatus GroupingCoreWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx);
3737
IGraphTransformer::TStatus DecimalBinaryWrapperBase(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx, bool blocks);
38-
IGraphTransformer::TStatus BlockMapJoinCoreWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx);
38+
IGraphTransformer::TStatus BlockStorageWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TContext& ctx);
39+
IGraphTransformer::TStatus BlockMapJoinIndexWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExtContext& ctx);
40+
IGraphTransformer::TStatus BlockMapJoinCoreWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExtContext& ctx);
3941

4042
TMaybe<ui32> FindOrReportMissingMember(TStringBuf memberName, TPositionHandle pos, const TStructExprType& structType, TExprContext& ctx);
4143

0 commit comments

Comments
 (0)