Skip to content

Commit

Permalink
refactor: insert_by_key
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Jan 18, 2024
1 parent 8969b2a commit 6283027
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/mito2/src/memtable/merge_tree/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,7 @@ impl MutablePart {
.plain_block
.get_or_insert_with(|| PlainBlock::new(metadata, INITIAL_BUILDER_CAPACITY));

if primary_key.is_some() {
// None means no primary key so we only push the key when it is `Some`.
block.key.push(primary_key);
}

block.value.push(key_value);
block.insert_by_key(primary_key, key_value);
}

/// Tries to intern the primary key, returns the id of the dictionary and the key.
Expand Down Expand Up @@ -345,6 +340,16 @@ impl PlainBlock {
value: ValueBuilder::new(metadata, capacity),
}
}

/// Inserts the row by key.
fn insert_by_key(&mut self, primary_key: Option<&[u8]>, key_value: &KeyValue) {
if primary_key.is_some() {
// None means no primary key so we only push the key when it is `Some`.
self.key.push(primary_key);
}

self.value.push(key_value);
}
}

/// Mutable buffer for values.
Expand Down

0 comments on commit 6283027

Please sign in to comment.