Skip to content

Commit 5154dde

Browse files
poyrazKgithub-actions[bot]
authored andcommitted
style: automated clang-format fixes
1 parent a24c986 commit 5154dde

5 files changed

Lines changed: 37 additions & 30 deletions

File tree

include/common/cluster_manager.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <unordered_map>
1414
#include <vector>
1515

16-
#include "common/config.hpp"
1716
#include "common/bloom_filter.hpp"
17+
#include "common/config.hpp"
1818
#include "executor/types.hpp"
1919

2020
namespace cloudsql::raft {
@@ -243,7 +243,8 @@ class ClusterManager {
243243
const std::scoped_lock<std::mutex> lock(mutex_);
244244
auto it = bloom_filters_.find(context_id);
245245
if (it != bloom_filters_.end() && !it->second.filter_data.empty()) {
246-
return common::BloomFilter(it->second.filter_data.data(), it->second.filter_data.size());
246+
return common::BloomFilter(it->second.filter_data.data(),
247+
it->second.filter_data.size());
247248
}
248249
return common::BloomFilter(1); // Empty filter
249250
}

src/common/bloom_filter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ size_t BloomFilter::get_bit_position(size_t hash, size_t i) const {
8686
// Double hashing technique: h(i) = h1 + i * h2
8787
// Use two different hash seeds
8888
size_t h1 = hash;
89-
size_t h2 = murmur3_hash(reinterpret_cast<const uint8_t*>("salt"),
90-
4, 0xcafebabe);
89+
size_t h2 = murmur3_hash(reinterpret_cast<const uint8_t*>("salt"), 4, 0xcafebabe);
9190

9291
return (h1 + i * h2) % num_bits_;
9392
}

src/distributed/distributed_executor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt,
242242
}
243243

244244
// After Phase 1, each node will have received left table data.
245-
// Now broadcast bloom filter built from that data to all nodes for Phase 2 filtering.
246-
// The filter is sent as a separate RPC that data nodes will store and apply to their
247-
// right table shuffle. For now, we send a simple metadata-only filter that signals
248-
// "filtering enabled" - the actual filter building happens on each data node during
249-
// Phase 1 and they stash it for use during Phase 2.
245+
// Now broadcast bloom filter built from that data to all nodes for Phase 2
246+
// filtering. The filter is sent as a separate RPC that data nodes will store and
247+
// apply to their right table shuffle. For now, we send a simple metadata-only
248+
// filter that signals "filtering enabled" - the actual filter building happens on
249+
// each data node during Phase 1 and they stash it for use during Phase 2.
250250
//
251251
// In production, we'd collect and OR all local bloom filters, but for POC
252252
// we just signal that bloom filtering is enabled for this context.
@@ -255,7 +255,7 @@ QueryResult DistributedExecutor::execute(const parser::Statement& stmt,
255255
bf_args.build_table = left_table;
256256
bf_args.probe_table = right_table;
257257
bf_args.probe_key_col = right_key; // Tell probe side which column to filter on
258-
bf_args.filter_data.clear(); // Empty = filter built distributed
258+
bf_args.filter_data.clear(); // Empty = filter built distributed
259259
bf_args.expected_elements = data_nodes.size() * 1000; // Estimate
260260
bf_args.num_hashes = 4;
261261
auto bf_payload = bf_args.serialize();

src/main.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ int main(int argc, char* argv[]) {
475475
// Apply bloom filter if available for this context
476476
if (cluster_manager->has_bloom_filter(args.context_id)) {
477477
auto bloom = cluster_manager->get_bloom_filter(args.context_id);
478-
std::string probe_key_col = cluster_manager->get_probe_key_col(args.context_id);
478+
std::string probe_key_col =
479+
cluster_manager->get_probe_key_col(args.context_id);
479480

480481
// Get probe table schema to find key column index
481482
auto table_meta_opt = catalog->get_table_by_name(args.table_name);
@@ -498,21 +499,22 @@ int main(int argc, char* argv[]) {
498499
filtered_rows.push_back(std::move(row));
499500
}
500501
}
501-
cluster_manager->buffer_shuffle_data(args.context_id, args.table_name,
502-
std::move(filtered_rows));
502+
cluster_manager->buffer_shuffle_data(
503+
args.context_id, args.table_name,
504+
std::move(filtered_rows));
503505
} else {
504506
// Key column not found, buffer as-is
505-
cluster_manager->buffer_shuffle_data(args.context_id, args.table_name,
506-
std::move(args.rows));
507+
cluster_manager->buffer_shuffle_data(
508+
args.context_id, args.table_name, std::move(args.rows));
507509
}
508510
} else {
509511
// No metadata, buffer as-is
510-
cluster_manager->buffer_shuffle_data(args.context_id, args.table_name,
511-
std::move(args.rows));
512+
cluster_manager->buffer_shuffle_data(
513+
args.context_id, args.table_name, std::move(args.rows));
512514
}
513515
} else {
514-
cluster_manager->buffer_shuffle_data(args.context_id, args.table_name,
515-
std::move(args.rows));
516+
cluster_manager->buffer_shuffle_data(
517+
args.context_id, args.table_name, std::move(args.rows));
516518
}
517519
}
518520

@@ -536,10 +538,10 @@ int main(int argc, char* argv[]) {
536538
(void)h;
537539
auto args = cloudsql::network::BloomFilterArgs::deserialize(p);
538540
if (cluster_manager != nullptr) {
539-
cluster_manager->set_bloom_filter(args.context_id, args.build_table,
540-
args.probe_table, args.probe_key_col,
541-
args.filter_data, args.expected_elements,
542-
args.num_hashes);
541+
cluster_manager->set_bloom_filter(
542+
args.context_id, args.build_table, args.probe_table,
543+
args.probe_key_col, args.filter_data, args.expected_elements,
544+
args.num_hashes);
543545
}
544546
cloudsql::network::QueryResultsReply reply;
545547
reply.success = true;

tests/bloom_filter_test.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* @brief Unit tests for BloomFilter implementation
44
*/
55

6+
#include "common/bloom_filter.hpp"
7+
68
#include <gtest/gtest.h>
79

810
#include <vector>
911

10-
#include "common/bloom_filter.hpp"
1112
#include "common/cluster_manager.hpp"
1213
#include "common/value.hpp"
1314
#include "executor/types.hpp"
@@ -202,8 +203,8 @@ TEST(BloomFilterTests, ClusterManagerBloomFilterStorage) {
202203
auto filter_data = original.serialize();
203204

204205
// Test set_bloom_filter and has_bloom_filter
205-
cm.set_bloom_filter("ctx1", "table_build", "table_probe", "key_col",
206-
filter_data, original.expected_elements(), original.num_hashes());
206+
cm.set_bloom_filter("ctx1", "table_build", "table_probe", "key_col", filter_data,
207+
original.expected_elements(), original.num_hashes());
207208
EXPECT_TRUE(cm.has_bloom_filter("ctx1"));
208209

209210
// Test get_bloom_filter reconstructs correctly
@@ -240,10 +241,14 @@ TEST(BloomFilterTests, BloomFilterApplicationLogic) {
240241

241242
// Simulate tuple filtering (as done in PushData handler)
242243
std::vector<cloudsql::executor::Tuple> tuples;
243-
tuples.push_back(cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(10)})); // match
244-
tuples.push_back(cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(15)})); // no match
245-
tuples.push_back(cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(20)})); // match
246-
tuples.push_back(cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(99)})); // no match
244+
tuples.push_back(
245+
cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(10)})); // match
246+
tuples.push_back(cloudsql::executor::Tuple(
247+
std::initializer_list<Value>{Value::make_int64(15)})); // no match
248+
tuples.push_back(
249+
cloudsql::executor::Tuple(std::initializer_list<Value>{Value::make_int64(20)})); // match
250+
tuples.push_back(cloudsql::executor::Tuple(
251+
std::initializer_list<Value>{Value::make_int64(99)})); // no match
247252

248253
std::vector<cloudsql::executor::Tuple> filtered;
249254
for (auto& row : tuples) {

0 commit comments

Comments
 (0)