Skip to content

Commit 9931a63

Browse files
committed
fix
1 parent e0003de commit 9931a63

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ydb/core/persqueue/partition_key_range/partition_key_range.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ namespace NKikimr {
66
namespace NPQ {
77

88
TString MiddleOf(const TString& from, const TString& to) {
9-
if (from > to && to.size() != 0) {
10-
return "";
11-
}
12-
139
auto GetChar = [](const TString& str, size_t i, unsigned char defaultValue) {
1410
if (i >= str.size()) {
1511
return defaultValue;
@@ -27,6 +23,7 @@ TString MiddleOf(const TString& from, const TString& to) {
2723
bool diffFound = false;
2824

2925
size_t maxSize = std::max(from.size(), to.size());
26+
result.reserve(maxSize + 1);
3027
for (size_t i = 0; i < maxSize; ++i) {
3128
ui16 f = GetChar(from, i, 0);
3229
ui16 t = GetChar(to, i, 0xFF);
@@ -82,7 +79,7 @@ TString MiddleOf(const TString& from, const TString& to) {
8279
}
8380

8481
if (result == from) {
85-
result << static_cast<unsigned char>(0xFFu);
82+
result << static_cast<unsigned char>(diffFound ? 0xFFu: 0x7Fu);
8683
}
8784

8885
return result;

ydb/core/persqueue/ut/autoscaling_ut.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ Y_UNIT_TEST_SUITE(TopicAutoscaling) {
717717
auto res = NKikimr::NPQ::MiddleOf(AsString({0x01, 0xFF, 0xFF, 0xFF}), AsString({0x02, 0x00, 0x00, 0x10}));
718718
UNIT_ASSERT_VALUES_EQUAL(ToHex(res), "02 00 00 07");
719719
}
720+
{
721+
auto res = NKikimr::NPQ::MiddleOf(AsString({0xFF, 0xFF}), AsString({0xFF}));
722+
UNIT_ASSERT_VALUES_EQUAL(ToHex(res), "FF FF 7F");
723+
}
720724
}
721725
}
722726

0 commit comments

Comments
 (0)