diff options
| author | aneporada <[email protected]> | 2024-11-07 22:39:23 +0300 |
|---|---|---|
| committer | aneporada <[email protected]> | 2024-11-07 22:51:13 +0300 |
| commit | 77acc99aab41efa1d6cf64879057312292355860 (patch) | |
| tree | 7ddc3f2d6cf290872de90947fe275609b3783c88 /yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp | |
| parent | 4b6cbdc40a3c0b3cee2bf7af07482f02334ef62c (diff) | |
Minimize dependency on YDB's TRope
commit_hash:e3b74d6e744bd014dc1fa0f41053fe886f7f4a49
Diffstat (limited to 'yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp')
| -rw-r--r-- | yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp b/yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp index 1747fd0ea7e..b689e4cf8b1 100644 --- a/yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp +++ b/yql/essentials/minikql/computation/mkql_computation_node_pack_ut.cpp @@ -27,6 +27,8 @@ namespace NKikimr { namespace NMiniKQL { +using NYql::TChunkedBuffer; + #ifdef WITH_VALGRIND constexpr static size_t PERFORMANCE_COUNT = 0x1000; #elif defined(NDEBUG) @@ -314,8 +316,8 @@ protected: TestVariantTypeImpl(PgmBuilder.NewVariantType(tupleType)); } - void ValidateEmbeddedLength(TRope buf, const TString& info) { - size_t size = buf.GetSize(); + void ValidateEmbeddedLength(TChunkedBuffer buf, const TString& info) { + size_t size = buf.Size(); TChunkedInputBuffer chunked(std::move(buf)); return ValidateEmbeddedLength(chunked, size, info); } @@ -352,13 +354,13 @@ protected: auto packedValue = packer.Pack(uValue); if constexpr (Transport) { if (expectedLength) { - UNIT_ASSERT_VALUES_EQUAL_C(packedValue.size(), *expectedLength, additionalMsg); + UNIT_ASSERT_VALUES_EQUAL_C(packedValue.Size(), *expectedLength, additionalMsg); } ValidateEmbeddedLength(packedValue, additionalMsg); return packer.Unpack(std::move(packedValue), HolderFactory); } else { if (expectedLength) { - UNIT_ASSERT_VALUES_EQUAL_C(packedValue.size(), *expectedLength, additionalMsg); + UNIT_ASSERT_VALUES_EQUAL_C(packedValue.Size(), *expectedLength, additionalMsg); } ValidateEmbeddedLength(packedValue, additionalMsg); return packer.Unpack(packedValue, HolderFactory); @@ -591,7 +593,10 @@ protected: auto buffer = packer.Pack(value); - TString packed = buffer.ConvertToString(); + TString packed; + TStringOutput sout(packed); + buffer.CopyTo(sout); + TStringBuf packedBuf(packed); if constexpr (Fast) { UNIT_ASSERT_VALUES_EQUAL(packed.size(), 73); @@ -600,14 +605,14 @@ protected: } for (size_t chunk = 1; chunk < packed.size(); ++chunk) { - TString first = packed.substr(0, chunk); - TString second = packed.substr(chunk); + TStringBuf first = packedBuf.substr(0, chunk); + TStringBuf second = packedBuf.substr(chunk); - TRope result(std::move(first)); - result.Insert(result.End(), TRope(std::move(second))); + TChunkedBuffer result(first, {}); + result.Append(second, {}); - UNIT_ASSERT_VALUES_EQUAL(result.size(), packed.size()); - UNIT_ASSERT(!result.IsContiguous()); + UNIT_ASSERT_VALUES_EQUAL(result.Size(), packed.size()); + UNIT_ASSERT(result.Size() != result.ContigousSize()); ValidateTupleValue(packer.Unpack(std::move(result), HolderFactory)); } @@ -632,7 +637,7 @@ protected: auto serialized = packer.Finish(); - auto listObj = listPacker.Unpack(TRope(serialized), HolderFactory); + auto listObj = listPacker.Unpack(TChunkedBuffer(serialized), HolderFactory); UNIT_ASSERT_VALUES_EQUAL(listObj.GetListLength(), count); const auto iter = listObj.GetListIterator(); for (NUdf::TUnboxedValue uVal; iter.Next(uVal);) { @@ -666,7 +671,7 @@ protected: auto scalarOptStrType = PgmBuilder.NewBlockType(optStrType, TBlockType::EShape::Scalar); auto blockOptTupleOptUi32StrType = PgmBuilder.NewBlockType(optTupleOptUi32StrType, TBlockType::EShape::Many); auto scalarUi64Type = PgmBuilder.NewBlockType(ui64Type, TBlockType::EShape::Scalar); - + auto tzDateType = PgmBuilder.NewDataType(NUdf::EDataSlot::TzDate); auto blockTzDateType = PgmBuilder.NewBlockType(tzDateType, TBlockType::EShape::Many); @@ -703,7 +708,7 @@ protected: TBlockItem b3items[] = { (i % 2) ? TBlockItem(i) : TBlockItem(), TBlockItem(a) }; TBlockItem b3 = (i % 7) ? TBlockItem(b3items) : TBlockItem(); builder3->Add(b3); - + TBlockItem tzDate {i}; tzDate.SetTimezoneId(i % 100); builder4->Add(tzDate); @@ -749,7 +754,7 @@ protected: } else { packer.AddWideItem(columns.data(), columns.size()); } - TRope packed = packer.Finish(); + TChunkedBuffer packed = packer.Finish(); TUnboxedValueBatch unpacked(rowType); packer.UnpackBatch(std::move(packed), HolderFactory, unpacked); |
