@@ -21,14 +21,15 @@ TConclusionStatus TScanHead::Start() {
21
21
22
22
TScanHead::TScanHead (std::unique_ptr<NCommon::ISourcesConstructor>&& sourcesConstructor, const std::shared_ptr<TSpecialReadContext>& context)
23
23
: Context(context) {
24
+ auto readMetadataContext = context->GetReadMetadata ();
24
25
if (auto script = Context->GetSourcesAggregationScript ()) {
25
26
SourcesCollection =
26
- std::make_shared<TNotSortedCollection>(Context, std::move (sourcesConstructor), Context-> GetReadMetadata () ->GetLimitRobustOptional ());
27
+ std::make_shared<TNotSortedCollection>(Context, std::move (sourcesConstructor), readMetadataContext ->GetLimitRobustOptional ());
27
28
SyncPoints.emplace_back (std::make_shared<TSyncPointResult>(SyncPoints.size (), context, SourcesCollection));
28
29
SyncPoints.emplace_back (std::make_shared<TSyncPointResultsAggregationControl>(
29
30
SourcesCollection, Context->GetSourcesAggregationScript (), Context->GetRestoreResultScript (), SyncPoints.size (), context));
30
- } else if (Context-> GetReadMetadata () ->IsSorted ()) {
31
- if (Context-> GetReadMetadata ()-> HasLimit ()) {
31
+ } else if (readMetadataContext ->IsSorted ()) {
32
+ if (readMetadataContext-> HasLimit () && !readMetadataContext-> GetFakeSort ()) {
32
33
auto collection = std::make_shared<TScanWithLimitCollection>(Context, std::move (sourcesConstructor));
33
34
SourcesCollection = collection;
34
35
SyncPoints.emplace_back (std::make_shared<TSyncPointLimitControl>(
@@ -39,7 +40,7 @@ TScanHead::TScanHead(std::unique_ptr<NCommon::ISourcesConstructor>&& sourcesCons
39
40
SyncPoints.emplace_back (std::make_shared<TSyncPointResult>(SyncPoints.size (), context, SourcesCollection));
40
41
} else {
41
42
SourcesCollection =
42
- std::make_shared<TNotSortedCollection>(Context, std::move (sourcesConstructor), Context-> GetReadMetadata () ->GetLimitRobustOptional ());
43
+ std::make_shared<TNotSortedCollection>(Context, std::move (sourcesConstructor), readMetadataContext ->GetLimitRobustOptional ());
43
44
SyncPoints.emplace_back (std::make_shared<TSyncPointResult>(SyncPoints.size (), context, SourcesCollection));
44
45
}
45
46
for (ui32 i = 0 ; i + 1 < SyncPoints.size (); ++i) {
0 commit comments