@@ -2580,38 +2580,22 @@ class TYtNativeGateway : public IYtGateway {
2580
2580
TTableInfoResult& result)
2581
2581
{
2582
2582
TVector<NYT::TNode> attributes (tables.size ());
2583
+ TVector<TMaybe<NYT::TNode>> linkAttributes (tables.size ());
2584
+ std::atomic<bool > linksPresent = false ;
2583
2585
{
2584
2586
auto batchGet = tx->CreateBatchRequest ();
2585
2587
TVector<TFuture<void >> batchRes (Reserve (idxs.size ()));
2586
2588
for (auto & idx: idxs) {
2587
- batchRes.push_back (batchGet->Get (idx.second + " /@" ).Apply ([&attributes, idx] (const TFuture<NYT::TNode>& res) {
2588
- attributes[idx.first ] = res.GetValue ();
2589
- }));
2590
- }
2591
- batchGet->ExecuteBatch ();
2592
- WaitExceptionOrAll (batchRes).GetValue ();
2593
- }
2594
- {
2595
- auto batchGet = tx->CreateBatchRequest ();
2596
- TVector<TFuture<void >> batchRes;
2597
- auto getOpts = TGetOptions ()
2598
- .AttributeFilter (TAttributeFilter ()
2599
- .AddAttribute (" type" )
2600
- .AddAttribute (TString{QB2Premapper})
2601
- .AddAttribute (TString{YqlRowSpecAttribute})
2602
- );
2603
- for (auto & idx: idxs) {
2604
- batchRes.push_back (batchGet->Get (tables[idx.first ].Table () + " &/@" , getOpts).Apply ([idx, &attributes](const TFuture<NYT::TNode>& f) {
2589
+ batchRes.push_back (batchGet->Get (tables[idx.first ].Table () + " &/@" ).Apply (
2590
+ [&attributes, &linkAttributes, &linksPresent, idx] (const TFuture<NYT::TNode>& res) {
2605
2591
try {
2606
- NYT::TNode attrs = f.GetValue ();
2607
- if (GetTypeFromAttributes (attrs, false ) == " link" ) {
2608
- // override some attributes by the link ones
2609
- if (attrs.HasKey (QB2Premapper)) {
2610
- attributes[idx.first ][QB2Premapper] = attrs[QB2Premapper];
2611
- }
2612
- if (attrs.HasKey (YqlRowSpecAttribute)) {
2613
- attributes[idx.first ][YqlRowSpecAttribute] = attrs[YqlRowSpecAttribute];
2614
- }
2592
+ NYT::TNode attrs = res.GetValue ();
2593
+ auto type = GetTypeFromAttributes (attrs, false );
2594
+ if (type == " link" ) {
2595
+ linkAttributes[idx.first ] = attrs;
2596
+ linksPresent.store (true );
2597
+ } else {
2598
+ attributes[idx.first ] = attrs;
2615
2599
}
2616
2600
} catch (const TErrorResponse& e) {
2617
2601
// Yt returns NoSuchTransaction as inner issue for ResolveError
@@ -2625,7 +2609,30 @@ class TYtNativeGateway : public IYtGateway {
2625
2609
batchGet->ExecuteBatch ();
2626
2610
WaitExceptionOrAll (batchRes).GetValue ();
2627
2611
}
2628
-
2612
+ if (linksPresent.load ()) {
2613
+ auto batchGet = tx->CreateBatchRequest ();
2614
+ TVector<TFuture<void >> batchRes;
2615
+ for (auto & idx : idxs) {
2616
+ if (!linkAttributes[idx.first ]) {
2617
+ continue ;
2618
+ }
2619
+ const auto & linkAttr = *linkAttributes[idx.first ];
2620
+ batchRes.push_back (batchGet->Get (idx.second + " /@" ).Apply (
2621
+ [idx, &linkAttr, &attributes](const TFuture<NYT::TNode>& f) {
2622
+ NYT::TNode attrs = f.GetValue ();
2623
+ attributes[idx.first ] = attrs;
2624
+ // override some attributes by the link ones
2625
+ if (linkAttr.HasKey (QB2Premapper)) {
2626
+ attributes[idx.first ][QB2Premapper] = linkAttr[QB2Premapper];
2627
+ }
2628
+ if (linkAttr.HasKey (YqlRowSpecAttribute)) {
2629
+ attributes[idx.first ][YqlRowSpecAttribute] = linkAttr[YqlRowSpecAttribute];
2630
+ }
2631
+ }));
2632
+ }
2633
+ batchGet->ExecuteBatch ();
2634
+ WaitExceptionOrAll (batchRes).GetValue ();
2635
+ }
2629
2636
auto batchGet = tx->CreateBatchRequest ();
2630
2637
TVector<TFuture<void >> batchRes;
2631
2638
0 commit comments