Skip to content

Commit 4264b47

Browse files
committed
graph: Rename EntityMod to EntityModification
Also, remove original EntityModification. This avoids a conversion from EntityModification to EntityMod when creating a batch.
1 parent 4ae0eff commit 4264b47

File tree

4 files changed

+112
-169
lines changed

4 files changed

+112
-169
lines changed

graph/src/components/store/entity_cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::fmt::{self, Debug};
55
use std::sync::Arc;
66

77
use crate::cheap_clone::CheapClone;
8+
use crate::components::store::write::EntityModification;
89
use crate::components::store::{self as s, Entity, EntityKey, EntityOp, EntityOperation};
910
use crate::data::store::IntoEntityIterator;
1011
use crate::prelude::ENV_VARS;
@@ -279,7 +280,7 @@ impl EntityCache {
279280

280281
let mut mods = Vec::new();
281282
for (key, update) in self.updates {
282-
use s::EntityModification::*;
283+
use EntityModification::*;
283284

284285
let current = self.current.remove(&key).and_then(|entity| entity);
285286
let modification = match (current, update) {

graph/src/components/store/mod.rs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::time::Duration;
2626
use std::{fmt, io};
2727

2828
use crate::blockchain::Block;
29+
use crate::components::store::write::EntityModification;
2930
use crate::data::store::scalar::Bytes;
3031
use crate::data::store::*;
3132
use crate::data::value::Word;
@@ -723,7 +724,7 @@ impl StoreEvent {
723724
let changes: Vec<_> = mods
724725
.into_iter()
725726
.map(|op| {
726-
use self::EntityModification::*;
727+
use EntityModification::*;
727728
match op {
728729
Insert { key, .. } | Overwrite { key, .. } | Remove { key, .. } => {
729730
EntityChange::for_data(subgraph_id.clone(), key.clone())
@@ -1002,75 +1003,6 @@ impl Display for DeploymentLocator {
10021003
// connection checkouts
10031004
pub type PoolWaitStats = Arc<RwLock<MovingStats>>;
10041005

1005-
/// An entity operation that can be transacted into the store; as opposed to
1006-
/// `EntityOperation`, we already know whether a `Set` should be an `Insert`
1007-
/// or `Update`
1008-
#[derive(Clone, Debug, PartialEq, Eq)]
1009-
pub enum EntityModification {
1010-
/// Insert the entity
1011-
Insert {
1012-
key: EntityKey,
1013-
data: Entity,
1014-
block: BlockNumber,
1015-
end: Option<BlockNumber>,
1016-
},
1017-
/// Update the entity by overwriting it
1018-
Overwrite {
1019-
key: EntityKey,
1020-
data: Entity,
1021-
block: BlockNumber,
1022-
end: Option<BlockNumber>,
1023-
},
1024-
/// Remove the entity
1025-
Remove { key: EntityKey, block: BlockNumber },
1026-
}
1027-
1028-
impl EntityModification {
1029-
pub fn insert(key: EntityKey, data: Entity, block: BlockNumber) -> Self {
1030-
EntityModification::Insert {
1031-
key,
1032-
data,
1033-
block,
1034-
end: None,
1035-
}
1036-
}
1037-
1038-
pub fn overwrite(key: EntityKey, data: Entity, block: BlockNumber) -> Self {
1039-
EntityModification::Overwrite {
1040-
key,
1041-
data,
1042-
block,
1043-
end: None,
1044-
}
1045-
}
1046-
1047-
pub fn remove(key: EntityKey, block: BlockNumber) -> Self {
1048-
EntityModification::Remove { key, block }
1049-
}
1050-
1051-
pub fn entity_ref(&self) -> &EntityKey {
1052-
use EntityModification::*;
1053-
match self {
1054-
Insert { key, .. } | Overwrite { key, .. } | Remove { key, .. } => key,
1055-
}
1056-
}
1057-
1058-
pub fn entity(&self) -> Option<&Entity> {
1059-
match self {
1060-
EntityModification::Insert { data, .. }
1061-
| EntityModification::Overwrite { data, .. } => Some(data),
1062-
EntityModification::Remove { .. } => None,
1063-
}
1064-
}
1065-
1066-
pub fn is_remove(&self) -> bool {
1067-
match self {
1068-
EntityModification::Remove { .. } => true,
1069-
_ => false,
1070-
}
1071-
}
1072-
}
1073-
10741006
/// A representation of entity operations that can be accumulated.
10751007
#[derive(Debug, Clone)]
10761008
enum EntityOp {

0 commit comments

Comments
 (0)