Skip to content

Commit 9acd51e

Browse files
author
Zoran Cvetkov
committed
address review
1 parent 48accf7 commit 9acd51e

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

graph/src/components/store/traits.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ pub trait ReadStore: Send + Sync + 'static {
235235
keys: BTreeSet<EntityKey>,
236236
) -> Result<BTreeMap<EntityKey, Entity>, StoreError>;
237237

238-
/// Looks up entities using the given store key for a range of blocks.
238+
/// Returns all versions of entities of the given entity_type that were
239+
/// changed in the given block_range.
239240
fn get_range(
240241
&self,
241242
entity_type: &EntityType,

store/postgres/src/block_range.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ pub enum EntityBlockRange {
140140
}
141141

142142
impl EntityBlockRange {
143-
pub fn new(immutable: bool, block_range: std::ops::Range<BlockNumber>) -> Self {
143+
pub fn new(table: &Table, block_range: std::ops::Range<BlockNumber>) -> Self {
144144
let start: Bound<BlockNumber> = Bound::Included(block_range.start);
145145
let end: Bound<BlockNumber> = Bound::Excluded(block_range.end);
146146
let block_range: BlockRange = BlockRange(start, end);
147-
if immutable {
147+
if table.immutable {
148148
Self::Immutable(block_range)
149149
} else {
150150
Self::Mutable(block_range)

store/postgres/src/relational.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,7 @@ impl Layout {
530530
for e in vec {
531531
let block = e.clone().deserialize_block_number::<Entity>()?;
532532
let en = e.deserialize_with_layout::<Entity>(self, None)?;
533-
match entities.get_mut(&block) {
534-
Some(vec) => vec.push(en),
535-
None => {
536-
let _ = entities.insert(block, vec![en]);
537-
}
538-
};
533+
entities.entry(block).or_default().push(en);
539534
}
540535
}
541536
Ok(entities)

store/postgres/src/relational_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ pub struct FindRangeQuery<'a> {
20142014

20152015
impl<'a> FindRangeQuery<'a> {
20162016
pub fn new(table: &'a Table, block_range: Range<BlockNumber>) -> Self {
2017-
let eb_range = EntityBlockRange::new(table.immutable, block_range);
2017+
let eb_range = EntityBlockRange::new(&table, block_range);
20182018
Self { table, eb_range }
20192019
}
20202020
}

0 commit comments

Comments
 (0)