@@ -37,8 +37,7 @@ TKqpScanFetcherActor::TKqpScanFetcherActor(const NKikimrKqp::TKqpSnapshot& snaps
3737 , ShardsScanningPolicy(shardsScanningPolicy)
3838 , Counters(counters)
3939 , InFlightShards(ScanId, *this )
40- , InFlightComputes(ComputeActorIds)
41- {
40+ , InFlightComputes(ComputeActorIds) {
4241 Y_UNUSED (traceId);
4342 AFL_ENSURE (!Meta.GetReads ().empty ());
4443 AFL_ENSURE (Meta.GetTable ().GetTableKind () != (ui32)ETableKind::SysView);
@@ -47,7 +46,7 @@ TKqpScanFetcherActor::TKqpScanFetcherActor(const NKikimrKqp::TKqpSnapshot& snaps
4746 for (size_t i = 0 ; i < Meta.KeyColumnTypesSize (); i++) {
4847 NScheme::TTypeId typeId = Meta.GetKeyColumnTypes ().at (i);
4948 NScheme::TTypeInfo typeInfo = NScheme::NTypeIds::IsParametrizedType (typeId) ?
50- NScheme::TypeInfoFromProto (typeId,Meta.GetKeyColumnTypeInfos().at(i)) :
49+ NScheme::TypeInfoFromProto (typeId, Meta.GetKeyColumnTypeInfos().at(i)) :
5150 NScheme::TTypeInfo(typeId);
5251 KeyColumnTypes.push_back (typeInfo);
5352 }
@@ -127,19 +126,19 @@ void TKqpScanFetcherActor::HandleExecute(TEvKqpCompute::TEvScanData::TPtr& ev) {
127126 (" ScanId" , ev->Get ()->ScanId )
128127 (" Finished" , ev->Get ()->Finished )
129128 (" Lock" , [&]() {
130- TStringBuilder builder;
131- for (const auto & lock : ev->Get ()->LocksInfo .Locks ) {
132- builder << lock.ShortDebugString ();
133- }
134- return builder;
135- }())
129+ TStringBuilder builder;
130+ for (const auto & lock : ev->Get ()->LocksInfo .Locks ) {
131+ builder << lock.ShortDebugString ();
132+ }
133+ return builder;
134+ }())
136135 (" BrokenLocks" , [&]() {
137- TStringBuilder builder;
138- for (const auto & lock : ev->Get ()->LocksInfo .BrokenLocks ) {
139- builder << lock.ShortDebugString ();
140- }
141- return builder;
142- }());
136+ TStringBuilder builder;
137+ for (const auto & lock : ev->Get ()->LocksInfo .BrokenLocks ) {
138+ builder << lock.ShortDebugString ();
139+ }
140+ return builder;
141+ }());
143142
144143 TInstant startTime = TActivationContext::Now ();
145144 if (ev->Get ()->Finished ) {
@@ -347,11 +346,12 @@ void TKqpScanFetcherActor::HandleExecute(TEvTxProxySchemeCache::TEvResolveKeySet
347346
348347 if (!state.LastKey .empty ()) {
349348 PendingShards.front ().LastKey = std::move (state.LastKey );
350- while (!PendingShards.empty () && PendingShards.front ().GetScanRanges (KeyColumnTypes).empty ()) {
349+ while (!PendingShards.empty () && PendingShards.front ().GetScanRanges (KeyColumnTypes).empty ()) {
351350 CA_LOG_D (" Nothing to read " << PendingShards.front ().ToString (KeyColumnTypes));
352351 auto readShard = std::move (PendingShards.front ());
353352 PendingShards.pop_front ();
354353 PendingShards.front ().LastKey = std::move (readShard.LastKey );
354+ PendingShards.front ().LastCursorProto = std::move (readShard.LastCursorProto );
355355 }
356356
357357 AFL_ENSURE (!PendingShards.empty ());
@@ -409,7 +409,8 @@ bool TKqpScanFetcherActor::SendScanFinished() {
409409 return true ;
410410}
411411
412- std::unique_ptr<NKikimr::TEvDataShard::TEvKqpScan> TKqpScanFetcherActor::BuildEvKqpScan (const ui32 scanId, const ui32 gen, const TSmallVec<TSerializedTableRange>& ranges) const {
412+ std::unique_ptr<NKikimr::TEvDataShard::TEvKqpScan> TKqpScanFetcherActor::BuildEvKqpScan (const ui32 scanId, const ui32 gen,
413+ const TSmallVec<TSerializedTableRange>& ranges, const std::optional<NKikimrKqp::TEvKqpScanCursor>& cursor) const {
413414 auto ev = std::make_unique<TEvDataShard::TEvKqpScan>();
414415 ev->Record .SetLocalPathId (ScanDataMeta.TableId .PathId .LocalPathId );
415416 for (auto & column : ScanDataMeta.GetColumns ()) {
@@ -423,6 +424,9 @@ std::unique_ptr<NKikimr::TEvDataShard::TEvKqpScan> TKqpScanFetcherActor::BuildEv
423424 }
424425 }
425426 ev->Record .MutableSkipNullKeys ()->CopyFrom (Meta.GetSkipNullKeys ());
427+ if (cursor) {
428+ *ev->Record .MutableScanCursor () = *cursor;
429+ }
426430
427431 auto protoRanges = ev->Record .MutableRanges ();
428432 protoRanges->Reserve (ranges.size ());
@@ -489,10 +493,11 @@ void TKqpScanFetcherActor::ProcessPendingScanDataItem(TEvKqpCompute::TEvScanData
489493 AFL_ENSURE (state->ActorId == ev->Sender )(" expected" , state->ActorId )(" got" , ev->Sender );
490494
491495 state->LastKey = std::move (msg.LastKey );
496+ state->LastCursorProto = std::move (msg.LastCursorProto );
492497 const ui64 rowsCount = msg.GetRowsCount ();
493498 AFL_ENSURE (!LockTxId || !msg.LocksInfo .Locks .empty () || !msg.LocksInfo .BrokenLocks .empty ());
494499 AFL_ENSURE (LockTxId || (msg.LocksInfo .Locks .empty () && msg.LocksInfo .BrokenLocks .empty ()));
495- AFL_DEBUG (NKikimrServices::KQP_COMPUTE)(" action" ," got EvScanData" )(" rows" , rowsCount)(" finished" , msg.Finished )(" exceeded" , msg.RequestedBytesLimitReached )
500+ AFL_DEBUG (NKikimrServices::KQP_COMPUTE)(" action" , " got EvScanData" )(" rows" , rowsCount)(" finished" , msg.Finished )(" exceeded" , msg.RequestedBytesLimitReached )
496501 (" scan" , ScanId)(" packs_to_send" , InFlightComputes.GetPacksToSendCount ())
497502 (" from" , ev->Sender )(" shards remain" , PendingShards.size ())
498503 (" in flight scans" , InFlightShards.GetScansCount ())
0 commit comments