Skip to content

Commit fe0a76f

Browse files
poyrazKgithub-actions[bot]
authored andcommitted
style: automated clang-format fixes
1 parent 356f001 commit fe0a76f

4 files changed

Lines changed: 28 additions & 37 deletions

File tree

include/executor/operator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Operator {
8989
state_ = ExecState::Done;
9090
return false;
9191
}
92-
92+
9393
// Forward declare TupleView inside Operator pointer context
9494
virtual bool next_view(storage::HeapTable::TupleView& out_view) {
9595
(void)out_view;

include/storage/heap_table.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class HeapTable {
120120
std::pmr::memory_resource* mr_; /**< Memory resource for tuple allocations */
121121
Page* current_page_ = nullptr;
122122
uint32_t current_page_num_ = 0xFFFFFFFF;
123-
123+
124124
/* Caching for Phase 2 optimization */
125125
const uint8_t* cached_buffer_ = nullptr;
126126
PageHeader cached_header_{};

src/executor/operator.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ bool SeqScanOperator::next(Tuple& out_tuple) {
9898
}
9999

100100
bool SeqScanOperator::next_view(storage::HeapTable::TupleView& out_view) {
101-
102101
if (!iterator_ || iterator_->is_done()) {
103102
set_state(ExecState::Done);
104103
return false;
@@ -117,10 +116,10 @@ bool SeqScanOperator::next_view(storage::HeapTable::TupleView& out_view) {
117116
const auto& snapshot = txn->get_snapshot();
118117
const uint64_t my_id = txn->get_id();
119118

120-
const bool xmin_visible =
121-
(out_view.xmin == my_id) || (out_view.xmin == 0) || snapshot.is_visible(out_view.xmin);
122-
const bool xmax_visible =
123-
(out_view.xmax == 0) || (out_view.xmax != my_id && !snapshot.is_visible(out_view.xmax));
119+
const bool xmin_visible = (out_view.xmin == my_id) || (out_view.xmin == 0) ||
120+
snapshot.is_visible(out_view.xmin);
121+
const bool xmax_visible = (out_view.xmax == 0) || (out_view.xmax != my_id &&
122+
!snapshot.is_visible(out_view.xmax));
124123

125124
visible = xmin_visible && xmax_visible;
126125
} else {
@@ -134,7 +133,6 @@ bool SeqScanOperator::next_view(storage::HeapTable::TupleView& out_view) {
134133
return false;
135134
}
136135

137-
138136
void SeqScanOperator::close() {
139137
iterator_.reset();
140138
set_state(ExecState::Done);
@@ -927,7 +925,6 @@ void LimitOperator::set_params(const std::vector<common::Value>* params) {
927925
if (child_) child_->set_params(params);
928926
}
929927

930-
931928
bool ProjectOperator::next_view(storage::HeapTable::TupleView& out_view) {
932929
if (!child_) return false;
933930
return child_->next_view(out_view);
@@ -941,8 +938,9 @@ bool FilterOperator::next_view(storage::HeapTable::TupleView& out_view) {
941938
// we might need to materialize for the condition check.
942939
// For benchmarks with NO condition, next_view is still fast.
943940
bool result = true;
944-
// Evaluation would require materialization. For now we skip condition if next_view is called
945-
// or we materialize. For PARITY with SQLite scan view, we assume no condition in the bench.
941+
// Evaluation would require materialization. For now we skip condition if next_view is
942+
// called or we materialize. For PARITY with SQLite scan view, we assume no condition in the
943+
// bench.
946944
if (result) return true;
947945
}
948946
set_state(ExecState::Done);

src/storage/heap_table.cpp

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,27 @@ HeapTable::~HeapTable() {
5555

5656
/* --- Iterator Implementation --- */
5757

58-
5958
common::Value HeapTable::TupleView::get_value(size_t col_index) const {
6059
if (!schema || col_index >= schema->column_count()) {
6160
return common::Value::make_null();
6261
}
63-
62+
6463
// We must walk the serialized payload from the beginning to reach col_index
6564
size_t cursor = 0;
6665
for (size_t i = 0; i <= col_index; ++i) {
6766
if (cursor >= payload_len) return common::Value::make_null();
68-
67+
6968
auto type = static_cast<common::ValueType>(payload_data[cursor++]);
70-
69+
7170
if (type == common::ValueType::TYPE_NULL) {
7271
if (i == col_index) return common::Value::make_null();
7372
continue;
7473
}
7574

76-
if (type == common::ValueType::TYPE_BOOL ||
77-
type == common::ValueType::TYPE_INT8 ||
78-
type == common::ValueType::TYPE_INT16 ||
79-
type == common::ValueType::TYPE_INT32 ||
80-
type == common::ValueType::TYPE_INT64 ||
81-
type == common::ValueType::TYPE_FLOAT32 ||
75+
if (type == common::ValueType::TYPE_BOOL || type == common::ValueType::TYPE_INT8 ||
76+
type == common::ValueType::TYPE_INT16 || type == common::ValueType::TYPE_INT32 ||
77+
type == common::ValueType::TYPE_INT64 || type == common::ValueType::TYPE_FLOAT32 ||
8278
type == common::ValueType::TYPE_FLOAT64) {
83-
8479
if (cursor + 8 > payload_len) return common::Value::make_null();
8580

8681
if (i == col_index) {
@@ -105,9 +100,9 @@ common::Value HeapTable::TupleView::get_value(size_t col_index) const {
105100
uint32_t len;
106101
std::memcpy(&len, payload_data + cursor, 4);
107102
cursor += 4;
108-
103+
109104
if (cursor + len > payload_len) return common::Value::make_null();
110-
105+
111106
if (i == col_index) {
112107
std::string s(reinterpret_cast<const char*>(payload_data + cursor), len);
113108
return common::Value::make_text(s);
@@ -201,14 +196,13 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
201196
eof_ = true;
202197
return false;
203198
}
204-
199+
205200
// Cache page header and buffer pointer (Phase 2 optimization)
206201
cached_buffer_ = reinterpret_cast<const uint8_t*>(current_page_->get_data());
207202
std::memcpy(&cached_header_, cached_buffer_, sizeof(PageHeader));
208203
}
209204

210205
if (cached_header_.free_space_offset == 0) {
211-
212206
table_.bpm_.unpin_page_by_id(table_.file_id_, current_page_num_, false);
213207
current_page_ = nullptr;
214208
cached_buffer_ = nullptr;
@@ -219,9 +213,10 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
219213
/* Scan slots in the current page starting from next_id_.slot_num */
220214
while (next_id_.slot_num < cached_header_.num_slots) {
221215
uint16_t offset = 0;
222-
std::memcpy(&offset,
223-
cached_buffer_ + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
224-
sizeof(uint16_t));
216+
std::memcpy(
217+
&offset,
218+
cached_buffer_ + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
219+
sizeof(uint16_t));
225220

226221
if (offset != 0) {
227222
/* Found a record: Deserialize it in-place from the pinned buffer */
@@ -599,7 +594,7 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
599594
return false;
600595
}
601596

602-
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
597+
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
603598

604599
uint16_t tuple_data_len;
605600
std::memcpy(&tuple_data_len, data, 2);
@@ -761,7 +756,6 @@ bool HeapTable::write_page(uint32_t page_num, const char* buffer) {
761756
}
762757

763758
bool HeapTable::Iterator::next_view(TupleView& out_view) {
764-
765759
if (eof_) {
766760
return false;
767761
}
@@ -775,14 +769,13 @@ bool HeapTable::Iterator::next_view(TupleView& out_view) {
775769
eof_ = true;
776770
return false;
777771
}
778-
772+
779773
// Cache page header and buffer pointer (Phase 2 optimization)
780774
cached_buffer_ = reinterpret_cast<const uint8_t*>(current_page_->get_data());
781775
std::memcpy(&cached_header_, cached_buffer_, sizeof(PageHeader));
782776
}
783777

784778
if (cached_header_.free_space_offset == 0) {
785-
786779
table_.bpm_.unpin_page_by_id(table_.file_id_, current_page_num_, false);
787780
current_page_ = nullptr;
788781
cached_buffer_ = nullptr;
@@ -793,9 +786,10 @@ bool HeapTable::Iterator::next_view(TupleView& out_view) {
793786
/* Scan slots in the current page starting from next_id_.slot_num */
794787
while (next_id_.slot_num < cached_header_.num_slots) {
795788
uint16_t offset = 0;
796-
std::memcpy(&offset,
797-
cached_buffer_ + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
798-
sizeof(uint16_t));
789+
std::memcpy(
790+
&offset,
791+
cached_buffer_ + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
792+
sizeof(uint16_t));
799793

800794
if (offset != 0) {
801795
const uint8_t* const data = cached_buffer_ + offset;
@@ -840,4 +834,3 @@ bool HeapTable::Iterator::next_view(TupleView& out_view) {
840834
}
841835

842836
} // namespace cloudsql::storage
843-

0 commit comments

Comments
 (0)