Skip to content

Commit b14774c

Browse files
poyrazKgithub-actions[bot]
authored andcommitted
style: automated clang-format fixes
1 parent 94e9577 commit b14774c

2 files changed

Lines changed: 49 additions & 39 deletions

File tree

src/executor/query_executor.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,12 @@ std::unique_ptr<Operator> QueryExecutor::build_plan(const parser::SelectStatemen
787787
col_name) {
788788
common::ValueType ktype = base_table_meta->columns[pos].type;
789789
current_root = std::make_unique<IndexScanOperator>(
790-
std::make_shared<storage::HeapTable>(base_table_name, bpm_,
791-
base_schema),
792-
std::make_unique<storage::BTreeIndex>(idx_info.name, bpm_,
793-
ktype),
794-
std::move(const_val), txn, &lock_manager_); index_used = true;
790+
std::make_shared<storage::HeapTable>(base_table_name, bpm_,
791+
base_schema),
792+
std::make_unique<storage::BTreeIndex>(idx_info.name, bpm_,
793+
ktype),
794+
std::move(const_val), txn, &lock_manager_);
795+
index_used = true;
795796
break;
796797
}
797798
}

src/storage/heap_table.cpp

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
8181
/* Scan slots in the current page starting from next_id_.slot_num */
8282
while (next_id_.slot_num < header.num_slots) {
8383
uint16_t offset = 0;
84-
std::memcpy(&offset, buffer + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
84+
std::memcpy(&offset,
85+
buffer + sizeof(PageHeader) + (next_id_.slot_num * sizeof(uint16_t)),
8586
sizeof(uint16_t));
86-
87+
8788
if (offset != 0) {
8889
/* Found a record: Deserialize it in-place from the pinned buffer */
8990
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
9091
const size_t data_len = Page::PAGE_SIZE - offset;
91-
92+
9293
if (data_len < 16) {
9394
table_.bpm_.unpin_page(table_.filename_, next_id_.page_num, false);
9495
return false;
@@ -97,11 +98,11 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
9798
// Read MVCC Header
9899
std::memcpy(&out_meta.xmin, data, 8);
99100
std::memcpy(&out_meta.xmax, data + 8, 8);
100-
101+
101102
size_t cursor = 16;
102103
std::vector<common::Value> values;
103104
values.reserve(table_.schema_.column_count());
104-
105+
105106
for (size_t i = 0; i < table_.schema_.column_count(); ++i) {
106107
if (cursor >= data_len) break;
107108
auto type = static_cast<common::ValueType>(data[cursor++]);
@@ -110,22 +111,27 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
110111
continue;
111112
}
112113

113-
if (type == common::ValueType::TYPE_BOOL ||
114-
type == common::ValueType::TYPE_INT8 || type == common::ValueType::TYPE_INT16 ||
115-
type == common::ValueType::TYPE_INT32 || type == common::ValueType::TYPE_INT64 ||
116-
type == common::ValueType::TYPE_FLOAT32 || type == common::ValueType::TYPE_FLOAT64) {
117-
114+
if (type == common::ValueType::TYPE_BOOL ||
115+
type == common::ValueType::TYPE_INT8 ||
116+
type == common::ValueType::TYPE_INT16 ||
117+
type == common::ValueType::TYPE_INT32 ||
118+
type == common::ValueType::TYPE_INT64 ||
119+
type == common::ValueType::TYPE_FLOAT32 ||
120+
type == common::ValueType::TYPE_FLOAT64) {
118121
if (cursor + 8 > data_len) break;
119-
120-
if (type == common::ValueType::TYPE_FLOAT32 || type == common::ValueType::TYPE_FLOAT64) {
122+
123+
if (type == common::ValueType::TYPE_FLOAT32 ||
124+
type == common::ValueType::TYPE_FLOAT64) {
121125
double v;
122126
std::memcpy(&v, data + cursor, 8);
123127
values.push_back(common::Value::make_float64(v));
124128
} else {
125129
int64_t v;
126130
std::memcpy(&v, data + cursor, 8);
127-
if (type == common::ValueType::TYPE_BOOL) values.push_back(common::Value::make_bool(v != 0));
128-
else values.push_back(common::Value::make_int64(v));
131+
if (type == common::ValueType::TYPE_BOOL)
132+
values.push_back(common::Value::make_bool(v != 0));
133+
else
134+
values.push_back(common::Value::make_int64(v));
129135
}
130136
cursor += 8;
131137
} else {
@@ -143,7 +149,7 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
143149
out_meta.tuple = executor::Tuple(std::move(values));
144150
last_id_ = next_id_;
145151
next_id_.slot_num++;
146-
152+
147153
table_.bpm_.unpin_page(table_.filename_, next_id_.page_num, false);
148154
return true;
149155
}
@@ -164,8 +170,8 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
164170

165171
/* Pre-serialize tuple to binary to determine size and avoid repeat work */
166172
std::vector<uint8_t> payload;
167-
payload.reserve(16 + (tuple.size() * 9));
168-
173+
payload.reserve(16 + (tuple.size() * 9));
174+
169175
uint64_t xmax = 0;
170176
payload.resize(16);
171177
std::memcpy(payload.data(), &xmin, 8);
@@ -208,7 +214,7 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
208214
auto* buffer = page->get_data();
209215
PageHeader header{};
210216
std::memcpy(&header, buffer, sizeof(PageHeader));
211-
217+
212218
// Initialize header if it's a new page
213219
if (header.free_space_offset == 0) {
214220
header.free_space_offset =
@@ -220,7 +226,7 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
220226
if (header.free_space_offset + required < Page::PAGE_SIZE &&
221227
header.num_slots < DEFAULT_SLOT_COUNT) {
222228
const uint16_t offset = header.free_space_offset;
223-
229+
224230
// Copy binary payload directly to page buffer
225231
std::memcpy(buffer + offset, payload.data(), payload.size());
226232

@@ -290,8 +296,8 @@ bool HeapTable::physical_remove(const TupleId& tuple_id) {
290296
}
291297

292298
const uint16_t zero = 0;
293-
std::memcpy(buffer + sizeof(PageHeader) + (tuple_id.slot_num * sizeof(uint16_t)),
294-
&zero, sizeof(uint16_t));
299+
std::memcpy(buffer + sizeof(PageHeader) + (tuple_id.slot_num * sizeof(uint16_t)), &zero,
300+
sizeof(uint16_t));
295301

296302
bpm_.unpin_page(filename_, tuple_id.page_num, true);
297303
return true;
@@ -334,7 +340,7 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
334340

335341
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
336342
const size_t data_len = Page::PAGE_SIZE - offset;
337-
343+
338344
if (data_len < 16) {
339345
bpm_.unpin_page(filename_, tuple_id.page_num, false);
340346
return false;
@@ -343,11 +349,11 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
343349
// Read MVCC Header
344350
std::memcpy(&out_meta.xmin, data, 8);
345351
std::memcpy(&out_meta.xmax, data + 8, 8);
346-
352+
347353
size_t cursor = 16;
348354
std::vector<common::Value> values;
349355
values.reserve(schema_.column_count());
350-
356+
351357
for (size_t i = 0; i < schema_.column_count(); ++i) {
352358
if (cursor >= data_len) break;
353359
auto type = static_cast<common::ValueType>(data[cursor++]);
@@ -356,22 +362,24 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
356362
continue;
357363
}
358364

359-
if (type == common::ValueType::TYPE_BOOL ||
360-
type == common::ValueType::TYPE_INT8 || type == common::ValueType::TYPE_INT16 ||
361-
type == common::ValueType::TYPE_INT32 || type == common::ValueType::TYPE_INT64 ||
362-
type == common::ValueType::TYPE_FLOAT32 || type == common::ValueType::TYPE_FLOAT64) {
363-
365+
if (type == common::ValueType::TYPE_BOOL || type == common::ValueType::TYPE_INT8 ||
366+
type == common::ValueType::TYPE_INT16 || type == common::ValueType::TYPE_INT32 ||
367+
type == common::ValueType::TYPE_INT64 || type == common::ValueType::TYPE_FLOAT32 ||
368+
type == common::ValueType::TYPE_FLOAT64) {
364369
if (cursor + 8 > data_len) break;
365-
366-
if (type == common::ValueType::TYPE_FLOAT32 || type == common::ValueType::TYPE_FLOAT64) {
370+
371+
if (type == common::ValueType::TYPE_FLOAT32 ||
372+
type == common::ValueType::TYPE_FLOAT64) {
367373
double v;
368374
std::memcpy(&v, data + cursor, 8);
369375
values.push_back(common::Value::make_float64(v));
370376
} else {
371377
int64_t v;
372378
std::memcpy(&v, data + cursor, 8);
373-
if (type == common::ValueType::TYPE_BOOL) values.push_back(common::Value::make_bool(v != 0));
374-
else values.push_back(common::Value::make_int64(v));
379+
if (type == common::ValueType::TYPE_BOOL)
380+
values.push_back(common::Value::make_bool(v != 0));
381+
else
382+
values.push_back(common::Value::make_int64(v));
375383
}
376384
cursor += 8;
377385
} else {
@@ -417,7 +425,8 @@ uint64_t HeapTable::tuple_count() const {
417425

418426
for (uint16_t i = 0; i < header.num_slots; ++i) {
419427
uint16_t offset = 0;
420-
std::memcpy(&offset, buffer + sizeof(PageHeader) + (i * sizeof(uint16_t)), sizeof(uint16_t));
428+
std::memcpy(&offset, buffer + sizeof(PageHeader) + (i * sizeof(uint16_t)),
429+
sizeof(uint16_t));
421430
if (offset != 0) {
422431
uint64_t xmax = 0;
423432
std::memcpy(&xmax, buffer + offset + 8, 8);

0 commit comments

Comments
 (0)