Skip to content

Commit 0dc042b

Browse files
poyrazKgithub-actions[bot]
authored andcommitted
style: automated clang-format fixes
1 parent 6cf093b commit 0dc042b

4 files changed

Lines changed: 40 additions & 35 deletions

File tree

include/executor/types.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#define CLOUDSQL_EXECUTOR_TYPES_HPP
1212

1313
#include <cstdint>
14+
#include <initializer_list>
1415
#include <memory>
1516
#include <memory_resource>
1617
#include <stdexcept>
1718
#include <string>
1819
#include <vector>
19-
#include <initializer_list>
2020

2121
#include "common/value.hpp"
2222

@@ -131,21 +131,22 @@ class Tuple {
131131

132132
public:
133133
Tuple() = default;
134-
134+
135135
// Explicit PMR vector constructor
136136
explicit Tuple(std::pmr::vector<common::Value> values) : values_(std::move(values)) {}
137-
137+
138138
// Initializer list constructor
139139
Tuple(std::initializer_list<common::Value> list) : values_(list) {}
140140

141141
// Support allocation from a custom memory resource
142142
explicit Tuple(std::pmr::memory_resource* mr)
143143
: values_(mr ? mr : std::pmr::get_default_resource()) {}
144-
144+
145145
// Support construction from standard vector or PMR vector with specific resource
146146
template <typename VectorType,
147147
typename = std::enable_if_t<!std::is_same_v<std::decay_t<VectorType>, Tuple>>,
148-
typename std::enable_if_t<!std::is_same_v<std::decay_t<VectorType>, std::pmr::memory_resource*>>* = nullptr>
148+
typename std::enable_if_t<
149+
!std::is_same_v<std::decay_t<VectorType>, std::pmr::memory_resource*>>* = nullptr>
149150
Tuple(const VectorType& values, std::pmr::memory_resource* mr = nullptr)
150151
: values_(values.begin(), values.end(), mr ? mr : std::pmr::get_default_resource()) {}
151152

src/executor/operator.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,21 @@ bool SortOperator::open() {
382382
}
383383

384384
/* Perform sort using child schema for evaluation */
385-
std::stable_sort(sorted_tuples_.begin(), sorted_tuples_.end(),
386-
[this](const Tuple& a, const Tuple& b) {
387-
for (size_t i = 0; i < sort_keys_.size(); ++i) {
388-
const common::Value val_a = sort_keys_[i]->evaluate(&a, &schema_, get_params());
389-
const common::Value val_b = sort_keys_[i]->evaluate(&b, &schema_, get_params());
390-
const bool asc = ascending_[i];
391-
if (val_a < val_b) {
392-
return asc;
393-
}
394-
if (val_b < val_a) {
395-
return !asc;
396-
}
397-
}
398-
return false;
399-
});
385+
std::stable_sort(
386+
sorted_tuples_.begin(), sorted_tuples_.end(), [this](const Tuple& a, const Tuple& b) {
387+
for (size_t i = 0; i < sort_keys_.size(); ++i) {
388+
const common::Value val_a = sort_keys_[i]->evaluate(&a, &schema_, get_params());
389+
const common::Value val_b = sort_keys_[i]->evaluate(&b, &schema_, get_params());
390+
const bool asc = ascending_[i];
391+
if (val_a < val_b) {
392+
return asc;
393+
}
394+
if (val_b < val_a) {
395+
return !asc;
396+
}
397+
}
398+
return false;
399+
});
400400

401401
current_index_ = 0;
402402
set_state(ExecState::Open);
@@ -502,7 +502,8 @@ bool AggregateOperator::open() {
502502
if (!is_global) {
503503
key = "";
504504
for (const auto& gb : group_by_) {
505-
auto val = gb ? gb->evaluate(&tuple, &child_schema, get_params()) : common::Value::make_null();
505+
auto val = gb ? gb->evaluate(&tuple, &child_schema, get_params())
506+
: common::Value::make_null();
506507
key += val.to_string() + "|";
507508
gb_vals.push_back(std::move(val));
508509
}
@@ -724,7 +725,8 @@ bool HashJoinOperator::next(Tuple& out_tuple) {
724725
if (left_->next(next_left)) {
725726
left_tuple_ = std::move(next_left);
726727
left_had_match_ = false;
727-
const common::Value key = left_key_->evaluate(&(left_tuple_.value()), &left_schema, get_params());
728+
const common::Value key =
729+
left_key_->evaluate(&(left_tuple_.value()), &left_schema, get_params());
728730

729731
/* Look up in hash table */
730732
auto range = hash_table_.equal_range(key.to_string());

src/executor/query_executor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ QueryResult QueryExecutor::execute(const PreparedStatement& prepared,
204204
for (const auto& idx_info : prepared.table_meta->indexes) {
205205
if (!idx_info.column_positions.empty()) {
206206
uint16_t pos = idx_info.column_positions[0];
207-
if (!apply_index_write(*prepared.indexes[cached_idx_ptr++], tuple.get(pos), tid,
208-
IndexOp::Insert, err)) {
207+
if (!apply_index_write(*prepared.indexes[cached_idx_ptr++], tuple.get(pos),
208+
tid, IndexOp::Insert, err)) {
209209
throw std::runtime_error(err);
210210
}
211211
}

src/storage/heap_table.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
106106
if (offset != 0) {
107107
/* Found a record: Deserialize it in-place from the pinned buffer */
108108
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
109-
109+
110110
// Read Tuple Length (first 2 bytes)
111111
uint16_t tuple_data_len;
112112
std::memcpy(&tuple_data_len, data, 2);
113-
113+
114114
const size_t record_len = static_cast<size_t>(tuple_data_len);
115-
if (record_len < 18) { // 2 len + 8 xmin + 8 xmax
115+
if (record_len < 18) { // 2 len + 8 xmin + 8 xmax
116116
table_.bpm_.unpin_page(table_.filename_, next_id_.page_num, false);
117117
return false;
118118
}
@@ -123,8 +123,10 @@ bool HeapTable::Iterator::next_meta(TupleMeta& out_meta) {
123123

124124
size_t cursor = 18;
125125
std::pmr::vector<common::Value> values(mr_);
126-
127-
std::cerr << "DEBUG: Iterator::next_meta values.reserve(" << table_.schema_.column_count() << ") iter=" << this << " table=" << &table_ << " mr=" << mr_ << std::endl;
126+
127+
std::cerr << "DEBUG: Iterator::next_meta values.reserve("
128+
<< table_.schema_.column_count() << ") iter=" << this
129+
<< " table=" << &table_ << " mr=" << mr_ << std::endl;
128130
values.reserve(table_.schema_.column_count());
129131

130132
for (size_t i = 0; i < table_.schema_.column_count(); ++i) {
@@ -209,7 +211,7 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
209211
};
210212

211213
uint64_t xmax = 0;
212-
payload_size = 18; // 2 len + 8 xmin + 8 xmax
214+
payload_size = 18; // 2 len + 8 xmin + 8 xmax
213215
// placeholder for length
214216
std::memset(payload_ptr, 0, 2);
215217
std::memcpy(payload_ptr + 2, &xmin, 8);
@@ -247,7 +249,7 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
247249
}
248250

249251
const auto required = static_cast<uint16_t>(payload_size);
250-
std::memcpy(payload_ptr, &required, 2); // set final length
252+
std::memcpy(payload_ptr, &required, 2); // set final length
251253

252254
while (true) {
253255
// Use cached page if available
@@ -260,7 +262,7 @@ HeapTable::TupleId HeapTable::insert(const executor::Tuple& tuple, uint64_t xmin
260262
if (!cached_page_) {
261263
cached_page_ = bpm_.new_page(filename_, &cached_page_id_);
262264
if (!cached_page_) {
263-
return {0, 0}; // Buffer pool full or allocation failed
265+
return {0, 0}; // Buffer pool full or allocation failed
264266
}
265267
last_page_id_ = cached_page_id_;
266268
}
@@ -406,7 +408,7 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
406408
if (offset == 0) return false;
407409

408410
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
409-
411+
410412
uint16_t tuple_data_len;
411413
std::memcpy(&tuple_data_len, data, 2);
412414
const size_t record_len = static_cast<size_t>(tuple_data_len);
@@ -481,7 +483,7 @@ bool HeapTable::get_meta(const TupleId& tuple_id, TupleMeta& out_meta) const {
481483
}
482484

483485
const uint8_t* const data = reinterpret_cast<const uint8_t*>(buffer + offset);
484-
486+
485487
uint16_t tuple_data_len;
486488
std::memcpy(&tuple_data_len, data, 2);
487489
const size_t record_len = static_cast<size_t>(tuple_data_len);
@@ -573,7 +575,7 @@ uint64_t HeapTable::tuple_count() const {
573575
sizeof(uint16_t));
574576
if (offset != 0) {
575577
uint64_t xmax = 0;
576-
std::memcpy(&xmax, buffer + offset + 10, 8); // 2 len + 8 xmin
578+
std::memcpy(&xmax, buffer + offset + 10, 8); // 2 len + 8 xmin
577579
if (xmax == 0) count++;
578580
}
579581
}

0 commit comments

Comments
 (0)