@@ -52,15 +52,15 @@ class TFixture : public NUnitTest::TBaseFixture {
5252 return storage;
5353 }
5454
55- NYql::NDqProto ::TComputeActorState MakeState (NYql::NUdf::TUnboxedValuePod&& value) {
55+ NYql::NDq ::TComputeActorState MakeState (NYql::NUdf::TUnboxedValuePod&& value) {
5656 TString result;
5757 NKikimr::NMiniKQL::TNodeStateHelper::AddNodeState (result, value.AsStringRef ());
58- NYql::NDqProto ::TComputeActorState state;
59- state.MutableMiniKqlProgram ()-> MutableData ()-> MutableStateData ()-> SetBlob ( result) ;
58+ NYql::NDq ::TComputeActorState state;
59+ state.MiniKqlProgram . ConstructInPlace (). Data . Blob = result;
6060 return state;
6161 }
6262
63- NYql::NDqProto ::TComputeActorState MakeStateFromBlob (size_t blobSize) {
63+ NYql::NDq ::TComputeActorState MakeStateFromBlob (size_t blobSize) {
6464 TString blob;
6565 blob.reserve (blobSize);
6666 for (size_t i = 0 ; i < blobSize; ++i) {
@@ -69,7 +69,7 @@ class TFixture : public NUnitTest::TBaseFixture {
6969 return MakeState (NKikimr::NMiniKQL::TOutputSerializer::MakeSimpleBlobState (blob, 0 ));
7070 }
7171
72- NYql::NDqProto ::TComputeActorState MakeIncrementState (size_t miniKqlPStateSize) {
72+ NYql::NDq ::TComputeActorState MakeIncrementState (size_t miniKqlPStateSize) {
7373 std::map<TString, TString> map;
7474 size_t itemCount = 4 ;
7575 for (size_t i = 0 ; i < itemCount; ++i) {
@@ -78,7 +78,7 @@ class TFixture : public NUnitTest::TBaseFixture {
7878 return MakeState (NKikimr::NMiniKQL::TOutputSerializer::MakeSnapshotState (map, 0 ));
7979 }
8080
81- NYql::NDqProto ::TComputeActorState MakeIncrementState (
81+ NYql::NDq ::TComputeActorState MakeIncrementState (
8282 const std::map<TString, TString>& snapshot,
8383 const std::map<TString, TString>& increment,
8484 const std::set<TString>& deleted)
@@ -94,13 +94,14 @@ class TFixture : public NUnitTest::TBaseFixture {
9494 ui64 taskId,
9595 const TString& graphId,
9696 const TCheckpointId& checkpointId,
97- const NYql::NDqProto ::TComputeActorState& state)
97+ const NYql::NDq ::TComputeActorState& state)
9898 {
99- auto issues = storage->SaveState (taskId, graphId, checkpointId, state).GetValueSync ();
99+ auto [size, issues] = storage->SaveState (taskId, graphId, checkpointId, state).GetValueSync ();
100100 UNIT_ASSERT_C (issues.Empty (), issues.ToString ());
101+ UNIT_ASSERT (size > 0 );
101102 }
102103
103- NYql::NDqProto ::TComputeActorState GetState (
104+ NYql::NDq ::TComputeActorState GetState (
104105 TStateStoragePtr storage,
105106 const ui64 taskId,
106107 const TString& graphId,
@@ -112,16 +113,43 @@ class TFixture : public NUnitTest::TBaseFixture {
112113 return states[0 ];
113114 }
114115
115- void ShouldSaveGetStateImpl (const char * tablePrefix, const NYql::NDqProto ::TComputeActorState& state) {
116+ void ShouldSaveGetStateImpl (const char * tablePrefix, const NYql::NDq ::TComputeActorState& state) {
116117 auto storage = GetStateStorage (tablePrefix);
117- auto issues = storage->SaveState (1 , " graph1" , CheckpointId1, state).GetValueSync ();
118+ auto [size, issues] = storage->SaveState (1 , " graph1" , CheckpointId1, state).GetValueSync ();
118119 UNIT_ASSERT_C (issues.Empty (), issues.ToString ());
120+ UNIT_ASSERT (size > 0 );
119121
120122 auto [states, getIssues] = storage->GetState ({1 }, " graph1" , CheckpointId1).GetValueSync ();
121123 UNIT_ASSERT_C (getIssues.Empty (), getIssues.ToString ());
122124 UNIT_ASSERT (!states.empty ());
123- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state, states[0 ]) );
125+ CheckEquals ( state, states[0 ]);
124126 }
127+
128+ void CheckEquals (const NYql::NDq::TComputeActorState& state1, const NYql::NDq::TComputeActorState& state2) {
129+ UNIT_ASSERT_VALUES_EQUAL (state1.MiniKqlProgram .Empty (), state2.MiniKqlProgram .Empty ());
130+ if (state1.MiniKqlProgram ) {
131+ UNIT_ASSERT_VALUES_EQUAL (state1.MiniKqlProgram ->Data .Blob , state2.MiniKqlProgram ->Data .Blob );
132+ UNIT_ASSERT_VALUES_EQUAL (state1.MiniKqlProgram ->Data .Version , state2.MiniKqlProgram ->Data .Version );
133+ UNIT_ASSERT_VALUES_EQUAL (state1.MiniKqlProgram ->RuntimeVersion , state2.MiniKqlProgram ->RuntimeVersion );
134+ }
135+ UNIT_ASSERT_VALUES_EQUAL (state1.Sources .size (), state2.Sources .size ());
136+ UNIT_ASSERT (std::equal (std::begin (state1.Sources ), std::end (state1.Sources ), std::begin (state2.Sources ), std::end (state2.Sources ),
137+ [](const NYql::NDq::TSourceState& state1, const NYql::NDq::TSourceState& state2) {
138+ UNIT_ASSERT_VALUES_EQUAL (state1.InputIndex , state2.InputIndex );
139+ UNIT_ASSERT_VALUES_EQUAL (state1.Data .size (), state2.Data .size ());
140+ return true ;
141+ }));
142+
143+ UNIT_ASSERT_VALUES_EQUAL (state1.Sinks .size (), state2.Sinks .size ());
144+ UNIT_ASSERT (std::equal (std::begin (state1.Sinks ), std::end (state1.Sinks ), std::begin (state2.Sinks ), std::end (state2.Sinks ),
145+ [](const NYql::NDq::TSinkState& state1, const NYql::NDq::TSinkState& state2) {
146+ UNIT_ASSERT_VALUES_EQUAL (state1.OutputIndex , state2.OutputIndex );
147+ UNIT_ASSERT_VALUES_EQUAL (state1.Data .Blob , state2.Data .Blob );
148+ UNIT_ASSERT_VALUES_EQUAL (state1.Data .Version , state2.Data .Version );
149+ return true ;
150+ }));
151+ }
152+
125153private:
126154 NKikimr::NMiniKQL::TScopedAlloc Alloc;
127155 NKikimr::TActorSystemStub ActorSystemStub;
@@ -147,8 +175,8 @@ Y_UNIT_TEST_SUITE(TStateStorageTest) {
147175 auto state2 = NKikimr::NMiniKQL::TOutputSerializer::MakeSimpleBlobState (TString (20 , ' b' ), 0 );
148176 NKikimr::NMiniKQL::TNodeStateHelper::AddNodeState (result, state1.AsStringRef ());
149177 NKikimr::NMiniKQL::TNodeStateHelper::AddNodeState (result, state2.AsStringRef ());
150- NYql::NDqProto ::TComputeActorState state;
151- state.MutableMiniKqlProgram ()-> MutableData ()-> MutableStateData ()-> SetBlob ( result) ;
178+ NYql::NDq ::TComputeActorState state;
179+ state.MiniKqlProgram . ConstructInPlace (). Data . Blob = result;
152180 ShouldSaveGetStateImpl (" TStateStorageTestShouldSaveGetState" , state);
153181 }
154182
@@ -300,8 +328,9 @@ Y_UNIT_TEST_SUITE(TStateStorageTest) {
300328 Y_UNIT_TEST_F (ShouldIssueErrorOnNonExistentState, TFixture) {
301329 auto storage = GetStateStorage (" TStateStorageTestShouldIssueErrorOnNonExistentState" );
302330
303- auto issues = storage->SaveState (1 , " graph1" , CheckpointId1, MakeStateFromBlob (4 )).GetValueSync ();
331+ auto [size, issues] = storage->SaveState (1 , " graph1" , CheckpointId1, MakeStateFromBlob (4 )).GetValueSync ();
304332 UNIT_ASSERT (issues.Empty ());
333+ UNIT_ASSERT (size > 0 );
305334
306335 auto getResult = storage->GetState ({1 }, " graph1" , CheckpointId1).GetValueSync ();
307336 UNIT_ASSERT (getResult.second .Empty ());
@@ -321,32 +350,33 @@ Y_UNIT_TEST_SUITE(TStateStorageTest) {
321350 auto state3 = MakeStateFromBlob (YdbRowSizeLimit * 6 );
322351 auto state4 = MakeIncrementState (YdbRowSizeLimit * 3 );
323352
324- auto issues = storage->SaveState (1 , " graph1" , CheckpointId1, state1).GetValueSync ();
353+ auto [size, issues] = storage->SaveState (1 , " graph1" , CheckpointId1, state1).GetValueSync ();
325354 UNIT_ASSERT (issues.Empty ());
326- issues = storage->SaveState (42 , " graph1" , CheckpointId1, state2).GetValueSync ();
355+ UNIT_ASSERT (size > 0 );
356+ issues = storage->SaveState (42 , " graph1" , CheckpointId1, state2).GetValueSync ().second ;
327357 UNIT_ASSERT (issues.Empty ());
328- issues = storage->SaveState (7 , " graph1" , CheckpointId1, state3).GetValueSync ();
358+ issues = storage->SaveState (7 , " graph1" , CheckpointId1, state3).GetValueSync (). second ;
329359 UNIT_ASSERT (issues.Empty ());
330- issues = storage->SaveState (13 , " graph1" , CheckpointId1, state4).GetValueSync ();
360+ issues = storage->SaveState (13 , " graph1" , CheckpointId1, state4).GetValueSync (). second ;
331361 UNIT_ASSERT (issues.Empty ());
332362
333363 auto [states, getIssues] = storage->GetState ({1 , 42 , 7 , 13 }, " graph1" , CheckpointId1).GetValueSync ();
334364 UNIT_ASSERT_C (getIssues.Empty (), getIssues.ToString ());
335365 UNIT_ASSERT_VALUES_EQUAL (states.size (), 4 );
336366
337- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state1, states[0 ]) );
338- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state2, states[1 ]) );
339- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state3, states[2 ]) );
340- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state4, states[3 ]) );
367+ CheckEquals ( state1, states[0 ]);
368+ CheckEquals ( state2, states[1 ]);
369+ CheckEquals ( state3, states[2 ]);
370+ CheckEquals ( state4, states[3 ]);
341371
342372 // in different order
343373 auto [states2, getIssues2] = storage->GetState ({42 , 1 , 13 , 7 }, " graph1" , CheckpointId1).GetValueSync ();
344374 UNIT_ASSERT (getIssues2.Empty ());
345375 UNIT_ASSERT_VALUES_EQUAL (states2.size (), 4 );
346- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state2, states2[0 ]) );
347- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state1, states2[1 ]) );
348- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state4, states2[2 ]) );
349- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state3, states2[3 ]) );
376+ CheckEquals ( state2, states2[0 ]);
377+ CheckEquals ( state1, states2[1 ]);
378+ CheckEquals ( state4, states2[2 ]);
379+ CheckEquals ( state3, states2[3 ]);
350380 }
351381
352382 Y_UNIT_TEST_F (ShouldLoadLastSnapshot, TFixture)
@@ -360,7 +390,7 @@ Y_UNIT_TEST_SUITE(TStateStorageTest) {
360390 SaveState (storage, 1 , " graph1" , CheckpointId2, state2);
361391
362392 auto state = GetState (storage, 1 , " graph1" , CheckpointId2);
363- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( state, state2) );
393+ CheckEquals ( state, state2);
364394 }
365395
366396 Y_UNIT_TEST_F (ShouldNotGetNonExistendSnaphotState, TFixture)
@@ -392,7 +422,7 @@ Y_UNIT_TEST_SUITE(TStateStorageTest) {
392422 auto expected = MakeIncrementState ({{" key1" , " value1-new" }, {" key3" , " value3" }, {" key4" , value4}}, {}, {});
393423
394424 auto actual = GetState (storage, 1 , " graph1" , CheckpointId3);
395- UNIT_ASSERT ( google::protobuf::util::MessageDifferencer::Equals ( expected, actual) );
425+ CheckEquals ( expected, actual);
396426 }
397427
398428};
0 commit comments