@@ -41,10 +41,12 @@ class TDqChannelStorageActor : public TActorBootstrapped<TDqChannelStorageActor>
41
41
using TBase = TActorBootstrapped<TDqChannelStorageActor>;
42
42
43
43
public:
44
- TDqChannelStorageActor (TTxId txId, ui64 channelId, IDqChannelStorage::TWakeUpCallback&& wakeUp)
44
+ TDqChannelStorageActor (TTxId txId, ui64 channelId, IDqChannelStorage::TWakeUpCallback&& wakeUp, TActorSystem* actorSystem )
45
45
: TxId_(txId)
46
46
, ChannelId_(channelId)
47
- , WakeUp_(std::move(wakeUp)) {}
47
+ , WakeUp_(std::move(wakeUp))
48
+ , ActorSystem_(actorSystem)
49
+ {}
48
50
49
51
void Bootstrap () {
50
52
auto spillingActor = CreateDqLocalFileSpillingActor (TxId_, TStringBuilder () << " ChannelId: " << ChannelId_,
@@ -135,21 +137,21 @@ class TDqChannelStorageActor : public TActorBootstrapped<TDqChannelStorageActor>
135
137
return WritingBlobs_.size () > MAX_INFLIGHT_BLOBS_COUNT || WritingBlobsSize_ > MAX_INFLIGHT_BLOBS_SIZE;
136
138
}
137
139
138
- void Put (ui64 blobId, TRope&& blob) {
140
+ void Put (ui64 blobId, TRope&& blob, ui64 cookie ) {
139
141
FailOnError ();
140
142
141
143
// TODO: timeout
142
144
// TODO: limit inflight events
143
145
144
146
ui64 size = blob.size ();
145
147
146
- Send (SpillingActorId_, new TEvDqSpilling::TEvWrite (blobId, std::move (blob)));
148
+ SendEvent ( new TEvDqSpilling::TEvWrite (blobId, std::move (blob)), cookie );
147
149
148
150
WritingBlobs_.emplace (blobId, size);
149
151
WritingBlobsSize_ += size;
150
152
}
151
153
152
- bool Get (ui64 blobId, TBuffer& blob) {
154
+ bool Get (ui64 blobId, TBuffer& blob, ui64 cookie ) {
153
155
FailOnError ();
154
156
155
157
auto loadedIt = LoadedBlobs_.find (blobId);
@@ -162,7 +164,7 @@ class TDqChannelStorageActor : public TActorBootstrapped<TDqChannelStorageActor>
162
164
163
165
auto result = LoadingBlobs_.emplace (blobId);
164
166
if (result.second ) {
165
- Send (SpillingActorId_, new TEvDqSpilling::TEvRead (blobId, true ));
167
+ SendEvent ( new TEvDqSpilling::TEvRead (blobId, true ), cookie );
166
168
}
167
169
168
170
return false ;
@@ -181,6 +183,23 @@ class TDqChannelStorageActor : public TActorBootstrapped<TDqChannelStorageActor>
181
183
}
182
184
}
183
185
186
+ template <typename T>
187
+ void SendEvent (T* event, ui64 cookie) {
188
+ if (ActorSystem_) {
189
+ ActorSystem_->Send (
190
+ new IEventHandle (
191
+ SpillingActorId_,
192
+ SelfId (),
193
+ event,
194
+ /* flags=*/ 0 ,
195
+ cookie
196
+ )
197
+ );
198
+ } else {
199
+ Send (SpillingActorId_, event);
200
+ }
201
+ }
202
+
184
203
private:
185
204
const TTxId TxId_;
186
205
const ui64 ChannelId_;
@@ -197,13 +216,15 @@ class TDqChannelStorageActor : public TActorBootstrapped<TDqChannelStorageActor>
197
216
TMap<ui64, TBuffer> LoadedBlobs_;
198
217
199
218
TMaybe<TString> Error_;
219
+
220
+ TActorSystem* ActorSystem_;
200
221
};
201
222
202
223
203
224
class TDqChannelStorage : public IDqChannelStorage {
204
225
public:
205
- TDqChannelStorage (TTxId txId, ui64 channelId, TWakeUpCallback&& wakeUp) {
206
- SelfActor_ = new TDqChannelStorageActor (txId, channelId, std::move (wakeUp));
226
+ TDqChannelStorage (TTxId txId, ui64 channelId, TWakeUpCallback&& wakeUp, TActorSystem* actorSystem ) {
227
+ SelfActor_ = new TDqChannelStorageActor (txId, channelId, std::move (wakeUp), actorSystem );
207
228
TlsActivationContext->AsActorContext ().RegisterWithSameMailbox (SelfActor_);
208
229
}
209
230
@@ -219,12 +240,12 @@ class TDqChannelStorage : public IDqChannelStorage {
219
240
return SelfActor_->IsFull ();
220
241
}
221
242
222
- void Put (ui64 blobId, TRope&& blob) override {
223
- SelfActor_->Put (blobId, std::move (blob));
243
+ void Put (ui64 blobId, TRope&& blob, ui64 cookie = 0 ) override {
244
+ SelfActor_->Put (blobId, std::move (blob), cookie );
224
245
}
225
246
226
- bool Get (ui64 blobId, TBuffer& blob) override {
227
- return SelfActor_->Get (blobId, blob);
247
+ bool Get (ui64 blobId, TBuffer& blob, ui64 cookie = 0 ) override {
248
+ return SelfActor_->Get (blobId, blob, cookie );
228
249
}
229
250
230
251
private:
@@ -233,9 +254,9 @@ class TDqChannelStorage : public IDqChannelStorage {
233
254
234
255
} // anonymous namespace
235
256
236
- IDqChannelStorage::TPtr CreateDqChannelStorage (TTxId txId, ui64 channelId, IDqChannelStorage::TWakeUpCallback wakeUp)
257
+ IDqChannelStorage::TPtr CreateDqChannelStorage (TTxId txId, ui64 channelId, IDqChannelStorage::TWakeUpCallback wakeUp, TActorSystem* actorSystem )
237
258
{
238
- return new TDqChannelStorage (txId, channelId, std::move (wakeUp));
259
+ return new TDqChannelStorage (txId, channelId, std::move (wakeUp), actorSystem );
239
260
}
240
261
241
262
} // namespace NYql::NDq
0 commit comments