Skip to content

Commit 3a189e9

Browse files
committed
graph, store: propagate skip_duplicates to RowGroup
Add skip_duplicates: bool field to RowGroup struct alongside immutable, update RowGroup::new() to accept the parameter, and wire it from entity_type.skip_duplicates() in RowGroups::group_entry(). All other call sites (RowGroupForPerfTest, test helpers, example) pass false.
1 parent d489a35 commit 3a189e9

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

graph/examples/append_row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub fn main() -> anyhow::Result<()> {
104104
};
105105
mods.push(md);
106106
}
107-
let mut group = RowGroup::new(THING_TYPE.clone(), false);
107+
let mut group = RowGroup::new(THING_TYPE.clone(), false, false);
108108

109109
let start = Instant::now();
110110
for md in mods {

graph/src/components/store/write.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,20 @@ pub struct RowGroup {
344344
rows: Vec<EntityModification>,
345345

346346
immutable: bool,
347+
skip_duplicates: bool,
347348

348349
/// Map the `key.entity_id` of all entries in `rows` to the index with
349350
/// the most recent entry for that id to speed up lookups.
350351
last_mod: LastMod,
351352
}
352353

353354
impl RowGroup {
354-
pub fn new(entity_type: EntityType, immutable: bool) -> Self {
355+
pub fn new(entity_type: EntityType, immutable: bool, skip_duplicates: bool) -> Self {
355356
Self {
356357
entity_type,
357358
rows: Vec::new(),
358359
immutable,
360+
skip_duplicates,
359361
last_mod: LastMod::new(),
360362
}
361363
}
@@ -604,8 +606,8 @@ impl RowGroup {
604606
pub struct RowGroupForPerfTest(RowGroup);
605607

606608
impl RowGroupForPerfTest {
607-
pub fn new(entity_type: EntityType, immutable: bool) -> Self {
608-
Self(RowGroup::new(entity_type, immutable))
609+
pub fn new(entity_type: EntityType, immutable: bool, skip_duplicates: bool) -> Self {
610+
Self(RowGroup::new(entity_type, immutable, skip_duplicates))
609611
}
610612

611613
pub fn push(&mut self, emod: EntityModification, block: BlockNumber) -> Result<(), StoreError> {
@@ -685,8 +687,12 @@ impl RowGroups {
685687
Some(pos) => &mut self.groups[pos],
686688
None => {
687689
let immutable = entity_type.is_immutable();
688-
self.groups
689-
.push(RowGroup::new(entity_type.clone(), immutable));
690+
let skip_duplicates = entity_type.skip_duplicates();
691+
self.groups.push(RowGroup::new(
692+
entity_type.clone(),
693+
immutable,
694+
skip_duplicates,
695+
));
690696
// unwrap: we just pushed an entry
691697
self.groups.last_mut().unwrap()
692698
}
@@ -1080,6 +1086,7 @@ mod test {
10801086
entity_type: ENTRY_TYPE.clone(),
10811087
rows,
10821088
immutable: false,
1089+
skip_duplicates: false,
10831090
last_mod,
10841091
};
10851092
let act = group
@@ -1187,7 +1194,7 @@ mod test {
11871194
impl Group {
11881195
fn new() -> Self {
11891196
Self {
1190-
group: RowGroup::new(THING_TYPE.clone(), false),
1197+
group: RowGroup::new(THING_TYPE.clone(), false, false),
11911198
}
11921199
}
11931200

store/test-store/tests/postgres/relational.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ async fn conflicting_entity() {
996996
let fred = entity! { layout.input_schema => id: id.clone(), name: id.clone() };
997997
let fred = Arc::new(fred);
998998
let types: Vec<_> = types.into_iter().cloned().collect();
999-
let mut group = RowGroup::new(entity_type.clone(), false);
999+
let mut group = RowGroup::new(entity_type.clone(), false, false);
10001000
group
10011001
.push(
10021002
EntityModification::Insert {

store/test-store/tests/postgres/relational_bytes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn row_group_update(
8585
block: BlockNumber,
8686
data: impl IntoIterator<Item = (EntityKey, Entity)>,
8787
) -> RowGroup {
88-
let mut group = RowGroup::new(entity_type.clone(), false);
88+
let mut group = RowGroup::new(entity_type.clone(), false, false);
8989
for (key, data) in data {
9090
group
9191
.push(EntityModification::overwrite(key, data, block), block)
@@ -99,7 +99,7 @@ pub fn row_group_insert(
9999
block: BlockNumber,
100100
data: impl IntoIterator<Item = (EntityKey, Entity)>,
101101
) -> RowGroup {
102-
let mut group = RowGroup::new(entity_type.clone(), false);
102+
let mut group = RowGroup::new(entity_type.clone(), false, false);
103103
for (key, data) in data {
104104
group
105105
.push(EntityModification::insert(key, data, block), block)
@@ -113,7 +113,7 @@ pub fn row_group_delete(
113113
block: BlockNumber,
114114
data: impl IntoIterator<Item = EntityKey>,
115115
) -> RowGroup {
116-
let mut group = RowGroup::new(entity_type.clone(), false);
116+
let mut group = RowGroup::new(entity_type.clone(), false, false);
117117
for key in data {
118118
group
119119
.push(EntityModification::remove(key, block), block)

0 commit comments

Comments
 (0)