Skip to content

Commit c76095e

Browse files
authored
removed nulls/optionals (#829)
## 📝 Summary On clickhouse using null is a little inefficient so I removed some Option that 99.9% of the time are Some --- ## ✅ I have completed the following steps: * [X] Run `make lint` * [X] Run `make test` * [ ] Added tests (if applicable) * [X] Added a stupid extra checkbox
1 parent 957b9a1 commit c76095e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crates/rbuilder-operator/src/clickhouse.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ pub struct BlockRow {
7878
/// Info about the bid that triggered the bid to be generated.
7979
/// Notice this may not be the top bid since a builder lowering it's bid could trigger a new bid
8080
/// against the new winner.
81-
pub triggering_bid_seen_time: Option<i64>,
82-
pub triggering_bid_relay: Option<String>,
81+
/// These 2 should be Option but for clickhouse optimization we use defaults as null values.
82+
pub triggering_bid_seen_time: i64,
83+
pub triggering_bid_relay: String,
8384
/// Info about the top bid among all relays we are trying to beat (best_relay_value)
84-
pub bid_to_beat_seen_time: Option<i64>,
85-
pub bid_to_beat_seen_relay: Option<String>,
85+
/// These 2 should be Option but for clickhouse optimization we use defaults as null values.
86+
pub bid_to_beat_seen_time: i64,
87+
pub bid_to_beat_seen_relay: String,
8688
}
8789

8890
impl ClickhouseRowExt for BlockRow {
@@ -295,30 +297,26 @@ impl BidObserver for BuiltBlocksWriter {
295297
let block_uses = block_uses
296298
.entry(built_block_trace.build_block_id)
297299
.or_insert(0);
298-
299300
let (triggering_bid_seen_time, triggering_bid_relay) = built_block_trace
300301
.competition_bid_context
301302
.triggering_bid_source_info
302303
.as_ref()
303304
.map(|info| {
304305
(
305-
Some(offset_date_to_clickhouse_timestamp(info.seen_time)),
306-
Some(info.relay.clone()),
306+
offset_date_to_clickhouse_timestamp(info.seen_time),
307+
info.relay.clone(),
307308
)
308309
})
309310
.unwrap_or_default();
310-
311311
let (bid_to_beat_seen_time, bid_to_beat_seen_relay, best_relay_value) =
312312
built_block_trace
313313
.competition_bid_context
314314
.seen_competition_bid
315315
.as_ref()
316316
.map(|bid_with_info| {
317317
(
318-
Some(offset_date_to_clickhouse_timestamp(
319-
bid_with_info.info.seen_time,
320-
)),
321-
Some(bid_with_info.info.relay.clone()),
318+
offset_date_to_clickhouse_timestamp(bid_with_info.info.seen_time),
319+
bid_with_info.info.relay.clone(),
322320
Some(bid_with_info.value),
323321
)
324322
})

0 commit comments

Comments
 (0)