Skip to content

Commit cee4154

Browse files
committed
make vid entries internal to the entity
1 parent b27502c commit cee4154

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

graph/src/data/store/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ lazy_static! {
740740
}
741741

742742
/// An entity is represented as a map of attribute names to values.
743-
#[derive(Clone, CacheWeight, PartialEq, Eq, Serialize)]
743+
#[derive(Clone, CacheWeight, Eq, Serialize)]
744744
pub struct Entity(Object<Value>);
745745

746746
impl<'a> IntoIterator for &'a Entity {
@@ -874,10 +874,16 @@ impl Entity {
874874
}
875875

876876
pub fn get(&self, key: &str) -> Option<&Value> {
877+
if key == VID_FIELD {
878+
return None;
879+
}
877880
self.0.get(key)
878881
}
879882

880883
pub fn contains_key(&self, key: &str) -> bool {
884+
if key == VID_FIELD {
885+
return false;
886+
}
881887
self.0.contains_key(key)
882888
}
883889

@@ -919,7 +925,8 @@ impl Entity {
919925
/// Return the VID of this entity and if its missing or of a type different than
920926
/// i64 it panics.
921927
pub fn vid(&self) -> i64 {
922-
self.get(VID_FIELD)
928+
self.0
929+
.get(VID_FIELD)
923930
.expect("the vid must be set")
924931
.as_int8()
925932
.expect("the vid must be set to a valid value")
@@ -1062,6 +1069,12 @@ impl Entity {
10621069
}
10631070
}
10641071

1072+
impl PartialEq for Entity {
1073+
fn eq(&self, other: &Self) -> bool {
1074+
self.sorted_ref() == other.sorted_ref()
1075+
}
1076+
}
1077+
10651078
/// Convenience methods to modify individual attributes for tests.
10661079
/// Production code should not use/need this.
10671080
#[cfg(debug_assertions)]

0 commit comments

Comments
 (0)