-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix and refactor log merge policy, fixes #1035 #1043
Conversation
src/indexer/log_merge_policy.rs
Outdated
if let Some(&(first_segment, log_size)) = sorted_segments_with_log_size.first() { | ||
let mut current_max_log_size = log_size; | ||
let mut levels = vec![vec![first_segment]]; | ||
for &(segment, segment_log_size) in (&sorted_segments_with_log_size).iter().skip(1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it the same without the parenthesis and the &?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for &(segment, segment_log_size) in sorted_segments_with_log_size.iter().skip(1) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I assume someone started with an iter on the ref &sorted_segments_with_log_size and added the skip later
src/indexer/log_merge_policy.rs
Outdated
.map(|ind_vec| { | ||
MergeCandidate(ind_vec.iter().map(|&ind| segments[ind].id()).collect()) | ||
}) | ||
.map(|segments| MergeCandidate(segments.iter().map(|&seg| seg.id()).collect())) | ||
.collect() | ||
} else { | ||
return vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is dead code btw because of the early exit above
fixes a bug in log merge policy where an index was wrongly referenced by its index
use std::cmp; | ||
use std::f64; | ||
|
||
const DEFAULT_LEVEL_LOG_SIZE: f64 = 0.75; | ||
const DEFAULT_MIN_LAYER_SIZE: u32 = 10_000; | ||
const DEFAULT_MIN_MERGE_SIZE: usize = 8; | ||
const DEFAULT_MAX_MERGE_SIZE: usize = 10_000_000; | ||
const DEFAULT_MIN_NUM_SEGMENTS_IN_MERGE: usize = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
fixes a bug in log merge policy where an index was wrongly referenced by its index