@@ -7,7 +7,7 @@ use std::sync::Arc;
77use crate :: cheap_clone:: CheapClone ;
88use crate :: components:: store:: write:: EntityModification ;
99use crate :: components:: store:: { self as s, Entity , EntityOperation } ;
10- use crate :: data:: store:: { EntityValidationError , Id , IdType , IntoEntityIterator } ;
10+ use crate :: data:: store:: { EntityV , EntityValidationError , Id , IdType , IntoEntityIterator } ;
1111use crate :: prelude:: ENV_VARS ;
1212use crate :: schema:: { EntityKey , InputSchema } ;
1313use crate :: util:: intern:: Error as InternError ;
@@ -29,8 +29,8 @@ pub enum GetScope {
2929#[ derive( Debug , Clone ) ]
3030enum EntityOp {
3131 Remove ,
32- Update ( Entity ) ,
33- Overwrite ( Entity ) ,
32+ Update ( EntityV ) ,
33+ Overwrite ( EntityV ) ,
3434}
3535
3636impl EntityOp {
@@ -41,7 +41,7 @@ impl EntityOp {
4141 use EntityOp :: * ;
4242 match ( self , entity) {
4343 ( Remove , _) => Ok ( None ) ,
44- ( Overwrite ( new) , _) | ( Update ( new) , None ) => Ok ( Some ( new) ) ,
44+ ( Overwrite ( new) , _) | ( Update ( new) , None ) => Ok ( Some ( new. e ) ) ,
4545 ( Update ( updates) , Some ( entity) ) => {
4646 let mut e = entity. borrow ( ) . clone ( ) ;
4747 e. merge_remove_null_fields ( updates) ?;
@@ -65,7 +65,7 @@ impl EntityOp {
6565 match self {
6666 // This is how `Overwrite` is constructed, by accumulating `Update` onto `Remove`.
6767 Remove => * self = Overwrite ( update) ,
68- Update ( current) | Overwrite ( current) => current. merge ( update) ,
68+ Update ( current) | Overwrite ( current) => current. e . merge ( update. e ) ,
6969 }
7070 }
7171}
@@ -278,9 +278,9 @@ impl EntityCache {
278278 ) -> Result < Option < Entity > , anyhow:: Error > {
279279 match op {
280280 EntityOp :: Update ( entity) | EntityOp :: Overwrite ( entity)
281- if query. matches ( key, entity) =>
281+ if query. matches ( key, & entity. e ) =>
282282 {
283- Ok ( Some ( entity. clone ( ) ) )
283+ Ok ( Some ( entity. e . clone ( ) ) )
284284 }
285285 EntityOp :: Remove => Ok ( None ) ,
286286 _ => Ok ( None ) ,
@@ -349,9 +349,9 @@ impl EntityCache {
349349 /// with existing data. The entity will be validated against the
350350 /// subgraph schema, and any errors will result in an `Err` being
351351 /// returned.
352- pub fn set ( & mut self , key : EntityKey , entity : Entity ) -> Result < ( ) , anyhow:: Error > {
352+ pub fn set ( & mut self , key : EntityKey , entity : EntityV ) -> Result < ( ) , anyhow:: Error > {
353353 // check the validate for derived fields
354- let is_valid = entity. validate ( & key) . is_ok ( ) ;
354+ let is_valid = entity. e . validate ( & key) . is_ok ( ) ;
355355
356356 self . entity_op ( key. clone ( ) , EntityOp :: Update ( entity) ) ;
357357
@@ -453,33 +453,33 @@ impl EntityCache {
453453 for ( key, update) in self . updates {
454454 use EntityModification :: * ;
455455
456- let is_poi = key. entity_type . is_poi ( ) ;
456+ // let is_poi = key.entity_type.is_poi();
457457 let current = self . current . remove ( & key) . and_then ( |entity| entity) ;
458458 let modification = match ( current, update) {
459459 // Entity was created
460460 ( None , EntityOp :: Update ( mut updates) )
461461 | ( None , EntityOp :: Overwrite ( mut updates) ) => {
462- updates. remove_null_fields ( ) ;
462+ updates. e . remove_null_fields ( ) ;
463463 let data = Arc :: new ( updates) ;
464- self . current . insert ( key . clone ( ) , Some ( data . cheap_clone ( ) ) ) ;
465- let vid = if is_poi { 0 } else { data. vid ( ) } ;
464+ self . current
465+ . insert ( key . clone ( ) , Some ( data. e . clone ( ) . into ( ) ) ) ;
466466 Some ( Insert {
467467 key,
468- data,
468+ data : data . e . clone ( ) . into ( ) ,
469469 block,
470470 end : None ,
471- vid,
471+ vid : data . vid ,
472472 } )
473473 }
474474 // Entity may have been changed
475475 ( Some ( current) , EntityOp :: Update ( updates) ) => {
476476 let mut data = current. as_ref ( ) . clone ( ) ;
477+ let vid = updates. vid ;
477478 data. merge_remove_null_fields ( updates)
478479 . map_err ( |e| key. unknown_attribute ( e) ) ?;
479480 let data = Arc :: new ( data) ;
480481 self . current . insert ( key. clone ( ) , Some ( data. cheap_clone ( ) ) ) ;
481482 if current != data {
482- let vid = if is_poi { 0 } else { data. vid ( ) } ;
483483 Some ( Overwrite {
484484 key,
485485 data,
@@ -494,15 +494,15 @@ impl EntityCache {
494494 // Entity was removed and then updated, so it will be overwritten
495495 ( Some ( current) , EntityOp :: Overwrite ( data) ) => {
496496 let data = Arc :: new ( data) ;
497- self . current . insert ( key . clone ( ) , Some ( data . clone ( ) ) ) ;
498- if current != data {
499- let vid = if is_poi { 0 } else { data. vid ( ) } ;
497+ self . current
498+ . insert ( key . clone ( ) , Some ( data . e . clone ( ) . into ( ) ) ) ;
499+ if current != data. e . clone ( ) . into ( ) {
500500 Some ( Overwrite {
501501 key,
502- data,
502+ data : data . e . clone ( ) . into ( ) ,
503503 block,
504504 end : None ,
505- vid,
505+ vid : data . vid ,
506506 } )
507507 } else {
508508 None
0 commit comments