|
4 | 4 |
|
5 | 5 | namespace NKikimr::NGRpcProxy::V1 {
|
6 | 6 |
|
7 |
| -bool RemoveEmptyMessages(PersQueue::V1::MigrationStreamingReadServerMessage::DataBatch& data) { |
8 |
| - auto batchRemover = [&](PersQueue::V1::MigrationStreamingReadServerMessage::DataBatch::Batch& batch) -> bool { |
9 |
| - return batch.message_data_size() == 0; |
10 |
| - }; |
11 |
| - auto partitionDataRemover = [&](PersQueue::V1::MigrationStreamingReadServerMessage::DataBatch::PartitionData& partition) -> bool { |
12 |
| - NProtoBuf::RemoveRepeatedFieldItemIf(partition.mutable_batches(), batchRemover); |
13 |
| - return partition.batches_size() == 0; |
14 |
| - }; |
15 |
| - NProtoBuf::RemoveRepeatedFieldItemIf(data.mutable_partition_data(), partitionDataRemover); |
16 |
| - return !data.partition_data().empty(); |
| 7 | +/* |
| 8 | + for (const auto& partData : data.GetPartitionData()) { |
| 9 | + for (const auto& batch : partData.GetBatch()) { |
| 10 | + if (batch.MessageDataSize() > 0) { |
| 11 | + return true; |
| 12 | + } |
| 13 | + } |
| 14 | + } |
| 15 | + return false; |
| 16 | +
|
| 17 | +*/ |
| 18 | + |
| 19 | +bool HasEmptyMessages(PersQueue::V1::MigrationStreamingReadServerMessage::DataBatch& data) { |
| 20 | + for (const auto& partData : data.partition_data()) { |
| 21 | + for (const auto& batch : partData.batches()) { |
| 22 | + if (batch.message_data_size() > 0) { |
| 23 | + return true; |
| 24 | + } |
| 25 | + } |
| 26 | + } |
| 27 | + return false; |
17 | 28 | }
|
18 | 29 |
|
19 | 30 | // TODO: remove after refactor
|
20 |
| -bool RemoveEmptyMessages(Topic::StreamReadMessage::ReadResponse& data) { |
21 |
| - auto batchRemover = [&](Topic::StreamReadMessage::ReadResponse::Batch& batch) -> bool { |
22 |
| - return batch.message_data_size() == 0; |
23 |
| - }; |
24 |
| - auto partitionDataRemover = [&](Topic::StreamReadMessage::ReadResponse::PartitionData& partition) -> bool { |
25 |
| - NProtoBuf::RemoveRepeatedFieldItemIf(partition.mutable_batches(), batchRemover); |
26 |
| - return partition.batches_size() == 0; |
27 |
| - }; |
28 |
| - NProtoBuf::RemoveRepeatedFieldItemIf(data.mutable_partition_data(), partitionDataRemover); |
29 |
| - return !data.partition_data().empty(); |
| 31 | +bool HasMessages(Topic::StreamReadMessage::ReadResponse& data) { |
| 32 | + for (const auto& partData : data.partition_data()) { |
| 33 | + for (const auto& batch : partData.batches()) { |
| 34 | + if (batch.message_data_size() > 0) { |
| 35 | + return true; |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + return false; |
30 | 40 | }
|
31 | 41 |
|
32 | 42 | }
|
0 commit comments