Skip to content

Commit 6643041

Browse files
committed
refactor: remove WriteBuffer GetBatchCount
1 parent f3db380 commit 6643041

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/paimon/core/mergetree/write_buffer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ class WriteBuffer {
6161
/// Flush all buffered batches into KeyValueInMemoryRecordReaders and clear the buffer.
6262
/// @param[in,out] last_sequence_number current sequence number, updated after flush
6363
/// @return list of KeyValueRecordReaders built from buffered data
64-
Result<std::vector<std::unique_ptr<KeyValueRecordReader>>> Flush(
65-
int64_t& last_sequence_number);
64+
Result<std::vector<std::unique_ptr<KeyValueRecordReader>>> Flush(int64_t& last_sequence_number);
6665

6766
/// Return current memory usage in bytes.
68-
int64_t GetMemoryUsage() const { return current_memory_in_bytes_; }
67+
int64_t GetMemoryUsage() const {
68+
return current_memory_in_bytes_;
69+
}
6970

7071
/// Return whether the buffer is empty.
71-
bool IsEmpty() const { return batch_vec_.empty(); }
72-
73-
/// Return the number of batches in the buffer.
74-
size_t GetBatchCount() const { return batch_vec_.size(); }
72+
bool IsEmpty() const {
73+
return batch_vec_.empty();
74+
}
7575

7676
/// Clear the buffer without building readers (for error paths or Close).
7777
void Clear();

src/paimon/core/mergetree/write_buffer_test.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,13 @@ TEST_F(WriteBufferTest, TestFlushResetsStateAndAdvancesSequenceNumber) {
9797
ASSERT_OK(write_buffer.Write(CreateBatch(array1, /*row_kinds=*/{})));
9898
ASSERT_OK(write_buffer.Write(CreateBatch(array2, /*row_kinds=*/{})));
9999
ASSERT_FALSE(write_buffer.IsEmpty());
100-
ASSERT_EQ(write_buffer.GetBatchCount(), 2);
101100
ASSERT_GT(write_buffer.GetMemoryUsage(), 0);
102101

103102
int64_t last_sequence_number = 10;
104103
ASSERT_OK_AND_ASSIGN(auto readers, write_buffer.Flush(last_sequence_number));
105104

106105
ASSERT_EQ(readers.size(), 2);
107106
ASSERT_TRUE(write_buffer.IsEmpty());
108-
ASSERT_EQ(write_buffer.GetBatchCount(), 0);
109107
ASSERT_EQ(write_buffer.GetMemoryUsage(), 0);
110108
ASSERT_EQ(last_sequence_number, 13);
111109

@@ -168,10 +166,9 @@ TEST_F(WriteBufferTest, TestFlushPreservesRowKinds) {
168166
}
169167

170168
ASSERT_EQ(actual_row_kind_values,
171-
(std::vector<int8_t>{RowKind::Insert()->ToByteValue(),
172-
RowKind::UpdateBefore()->ToByteValue(),
173-
RowKind::UpdateAfter()->ToByteValue(),
174-
RowKind::Delete()->ToByteValue()}));
169+
(std::vector<int8_t>{
170+
RowKind::Insert()->ToByteValue(), RowKind::UpdateBefore()->ToByteValue(),
171+
RowKind::UpdateAfter()->ToByteValue(), RowKind::Delete()->ToByteValue()}));
175172
ASSERT_EQ(actual_sequence_numbers, (std::vector<int64_t>{0, 1, 2, 3}));
176173
}
177174

@@ -223,8 +220,8 @@ TEST_F(WriteBufferTest, TestEstimateMemoryUse) {
223220
arrow::field("f0", arrow::list(arrow::int32())),
224221
arrow::field("f1", arrow::map(arrow::utf8(), arrow::int64())),
225222
arrow::field("f2", arrow::struct_({arrow::field("sub1", arrow::int64()),
226-
arrow::field("sub2", arrow::float64()),
227-
arrow::field("sub3", arrow::boolean())})),
223+
arrow::field("sub2", arrow::float64()),
224+
arrow::field("sub3", arrow::boolean())})),
228225
};
229226
auto array = std::dynamic_pointer_cast<arrow::StructArray>(
230227
arrow::ipc::internal::json::ArrayFromJSON(arrow::struct_({fields}), R"([
@@ -242,4 +239,4 @@ TEST_F(WriteBufferTest, TestEstimateMemoryUse) {
242239
}
243240
}
244241

245-
} // namespace paimon::test
242+
} // namespace paimon::test

0 commit comments

Comments
 (0)