@@ -21,24 +21,30 @@ using namespace NActors;
2121
2222Y_UNIT_TEST_SUITE (GenericProviderLookupActor) {
2323
24+ NYql::NUdf::TUnboxedValue CreateStructValue (NKikimr::NMiniKQL::THolderFactory& holderFactory, std::initializer_list<ui64> members) {
25+ NYql::NUdf::TUnboxedValue* items;
26+ NYql::NUdf::TUnboxedValue result = holderFactory.CreateDirectArrayHolder (members.size (), items);
27+ for (size_t i = 0 ; i != members.size (); ++i) {
28+ items[i] = NYql::NUdf::TUnboxedValuePod{*(members.begin () + i)};
29+ }
30+ return result;
31+ }
32+
2433 // Simple actor to call IDqAsyncLookupSource::AsyncLookup from an actor system's thread
2534 class TCallLookupActor : public TActorBootstrapped <TCallLookupActor> {
2635 public:
2736 TCallLookupActor (
2837 std::shared_ptr<NKikimr::NMiniKQL::TScopedAlloc> alloc,
2938 NYql::NDq::IDqAsyncLookupSource* lookupSource,
30- NKikimr::NMiniKQL::TUnboxedValueVector && keysToLookUp )
39+ NYql::NDq::IDqAsyncLookupSource::TUnboxedValueMap && request )
3140 : Alloc(alloc)
3241 , LookupSource(lookupSource)
33- , KeysToLookUp (std::move(keysToLookUp ))
42+ , Request (std::move(request ))
3443 {
3544 }
3645
3746 void Bootstrap () {
38- LookupSource->AsyncLookup (std::move (KeysToLookUp));
39- auto guard = Guard (*Alloc);
40- KeysToLookUp.clear ();
41- KeysToLookUp.shrink_to_fit ();
47+ LookupSource->AsyncLookup (std::move (Request));
4248 }
4349
4450 private:
@@ -47,7 +53,7 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
4753 private:
4854 std::shared_ptr<NKikimr::NMiniKQL::TScopedAlloc> Alloc;
4955 NYql::NDq::IDqAsyncLookupSource* LookupSource;
50- NKikimr::NMiniKQL::TUnboxedValueVector KeysToLookUp ;
56+ NYql::NDq::IDqAsyncLookupSource::TUnboxedValueMap Request ;
5157 };
5258
5359 Y_UNIT_TEST (Lookup) {
@@ -94,8 +100,8 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
94100 .Disjunction ()
95101 .Operand ()
96102 .Conjunction ()
97- .Operand ().Equal ().Column (" id" ).Value <ui64>(0 ).Done ().Done ()
98- .Operand ().Equal ().Column (" optional_id" ).OptionalValue <ui64>(100 ).Done ().Done ()
103+ .Operand ().Equal ().Column (" id" ).Value <ui64>(2 ).Done ().Done ()
104+ .Operand ().Equal ().Column (" optional_id" ).OptionalValue <ui64>(102 ).Done ().Done ()
99105 .Done ()
100106 .Done ()
101107 .Operand ()
@@ -106,8 +112,8 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
106112 .Done ()
107113 .Operand ()
108114 .Conjunction ()
109- .Operand ().Equal ().Column (" id" ).Value <ui64>(2 ).Done ().Done ()
110- .Operand ().Equal ().Column (" optional_id" ).OptionalValue <ui64>(102 ).Done ().Done ()
115+ .Operand ().Equal ().Column (" id" ).Value <ui64>(0 ).Done ().Done ()
116+ .Operand ().Equal ().Column (" optional_id" ).OptionalValue <ui64>(100 ).Done ().Done ()
111117 .Done ()
112118 .Done ()
113119 .Done ()
@@ -153,12 +159,14 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
153159 outputypeBuilder.Add (" string_value" , typeBuilder.NewDataType (NYql::NUdf::EDataSlot::String, true ));
154160
155161 auto guard = Guard (*alloc.get ());
162+ auto keyTypeHelper = std::make_shared<NYql::NDq::IDqAsyncLookupSource::TKeyTypeHelper>(keyTypeBuilder.Build ());
156163
157164 auto [lookupSource, actor] = NYql::NDq::CreateGenericLookupActor (
158165 connectorMock,
159166 std::make_shared<NYql::NTestCreds::TSecuredServiceAccountCredentialsFactory>(),
160167 edge,
161168 alloc,
169+ keyTypeHelper,
162170 std::move (lookupSourceSettings),
163171 keyTypeBuilder.Build (),
164172 outputypeBuilder.Build (),
@@ -167,45 +175,41 @@ Y_UNIT_TEST_SUITE(GenericProviderLookupActor) {
167175 1'000'000 );
168176 runtime.Register (actor);
169177
170- NKikimr::NMiniKQL::TUnboxedValueVector keys ;
178+ NYql::NDq::IDqAsyncLookupSource::TUnboxedValueMap request ( 3 , keyTypeHelper-> GetValueHash (), keyTypeHelper-> GetValueEqual ()) ;
171179 for (size_t i = 0 ; i != 3 ; ++i) {
172180 NYql::NUdf::TUnboxedValue* keyItems;
173181 auto key = holderFactory.CreateDirectArrayHolder (2 , keyItems);
174182 keyItems[0 ] = NYql::NUdf::TUnboxedValuePod (ui64 (i));
175183 keyItems[1 ] = NYql::NUdf::TUnboxedValuePod (ui64 (100 + i));
176- keys. push_back (std::move (key));
184+ request. emplace (std::move (key), NYql::NUdf::TUnboxedValue{} );
177185 }
178186
179187 guard.Release (); // let actors use alloc
180188
181- auto callLookupActor = new TCallLookupActor (alloc, lookupSource, std::move (keys ));
189+ auto callLookupActor = new TCallLookupActor (alloc, lookupSource, std::move (request ));
182190 runtime.Register (callLookupActor);
183191
184192 auto ev = runtime.GrabEdgeEventRethrow <NYql::NDq::IDqAsyncLookupSource::TEvLookupResult>(edge);
185193 auto guard2 = Guard (*alloc.get ());
186- NKikimr::NMiniKQL::TKeyPayloadPairVector lookupResult = std::move (ev->Get ()->Data );
194+ auto lookupResult = std::move (ev->Get ()->Result );
187195
188196 UNIT_ASSERT_EQUAL (3 , lookupResult.size ());
189197 {
190- auto & [k, v] = lookupResult[0 ];
191- UNIT_ASSERT_EQUAL (0 , k.GetElement (0 ).Get <ui64>());
192- UNIT_ASSERT_EQUAL (100 , k.GetElement (1 ).Get <ui64>());
193- NYql::NUdf::TUnboxedValue val = v.GetElement (0 );
198+ const auto * v = lookupResult.FindPtr (CreateStructValue (holderFactory, {0 , 100 }));
199+ UNIT_ASSERT (v);
200+ NYql::NUdf::TUnboxedValue val = v->GetElement (0 );
194201 UNIT_ASSERT (val.AsStringRef () == TStringBuf (" a" ));
195202 }
196203 {
197- auto & [k, v] = lookupResult[1 ];
198- UNIT_ASSERT_EQUAL (1 , k.GetElement (0 ).Get <ui64>());
199- UNIT_ASSERT_EQUAL (101 , k.GetElement (1 ).Get <ui64>());
200- NYql::NUdf::TUnboxedValue val = v.GetElement (0 );
204+ const auto * v = lookupResult.FindPtr (CreateStructValue (holderFactory, {1 , 101 }));
205+ UNIT_ASSERT (v);
206+ NYql::NUdf::TUnboxedValue val = v->GetElement (0 );
201207 UNIT_ASSERT (val.AsStringRef () == TStringBuf (" b" ));
202208 }
203209 {
204- auto & [k, v] = lookupResult[2 ];
205- UNIT_ASSERT_EQUAL (2 , k.GetElement (0 ).Get <ui64>());
206- UNIT_ASSERT_EQUAL (102 , k.GetElement (1 ).Get <ui64>());
207- // this key was not found and reported as empty
208- UNIT_ASSERT (!v);
210+ const auto * v = lookupResult.FindPtr (CreateStructValue (holderFactory, {2 , 102 }));
211+ UNIT_ASSERT (v);
212+ UNIT_ASSERT (!*v);
209213 }
210214 }
211215
0 commit comments