@Override protected Relationship newRelationshipProxyById( long id ) { return EmbeddedProxySPI.newRelationshipProxy( id ); }
@Override public Relationship relationship( long id, long startNodeId, int typeId, long endNodeId ) { return spi.newRelationshipProxy( id, startNodeId, typeId, endNodeId ); } }
@Override public AnyValue mapRelationship( VirtualRelationshipValue value ) { if ( value instanceof RelationshipValue ) { return value; } return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( value.id() ) ); }
public static RelationshipValue materializeRelationshipValue( EmbeddedProxySPI proxySpi, Object anyValue ) { // Null check has to be done outside by the generated code if ( anyValue instanceof RelationshipValue ) { return (RelationshipValue) anyValue; } else if ( anyValue instanceof VirtualRelationshipValue ) { return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( ((VirtualRelationshipValue) anyValue).id() ) ); } else if ( anyValue instanceof Relationship ) { return ValueUtils.fromRelationshipProxy( (Relationship) anyValue ); } throw new IllegalArgumentException( "Do not know how to materialize relationship value from type " + anyValue.getClass().getName() ); }
private Relationship relationship( long relId ) { RelationshipProxy relationship = proxySpi.newRelationshipProxy( relId ); if ( !state.relationshipVisit( relId, relationship ) ) { // This relationship has been created or changed in this transaction RelationshipProxy cached = relationshipsReadFromStore.get( relId ); if ( cached != null ) { return cached; } try { // Get this relationship data from the store store.relationshipVisit( relId, relationship ); relationshipsReadFromStore.put( relId, relationship ); } catch ( EntityNotFoundException e ) { throw new IllegalStateException( "Getting deleted relationship data should have been covered by the tx state", e ); } } return relationship; }
private TxStateTransactionDataSnapshot snapshot() { EmbeddedProxySPI spi = mock( EmbeddedProxySPI.class ); when( spi.newNodeProxy( anyLong() ) ).thenAnswer( invocation -> new NodeProxy( spi, invocation.getArgument( 0 ) ) ); when( spi.newRelationshipProxy( anyLong() ) ).thenAnswer( invocation -> new RelationshipProxy( spi, invocation.getArgument( 0 ) ) ); when( spi.newRelationshipProxy( anyLong(), anyLong(), anyInt(), anyLong() ) ).thenAnswer( invocation -> new RelationshipProxy( spi, invocation.getArgument( 0 ), invocation.getArgument( 1 ), invocation.getArgument( 2 ), invocation.getArgument( 3 ) ) ); return new TxStateTransactionDataSnapshot( state, spi, ops, transaction ); } }
@Before public void setup() { EmbeddedProxySPI manager = mock( EmbeddedProxySPI.class ); when( manager.newNodeProxy( anyLong() ) ).thenAnswer( invocationOnMock -> { long id = invocationOnMock.getArgument( 0 ); NodeProxy mock = mock( NodeProxy.class ); when( mock.getId() ).thenReturn( id ); return mock; } ); when( manager.newRelationshipProxy( anyLong() ) ).thenAnswer( invocationOnMock -> { long id = invocationOnMock.getArgument( 0 ); RelationshipProxy mock = mock( RelationshipProxy.class ); when( mock.getId() ).thenReturn( id ); return mock; } ); converter = new ParameterConverter( manager ); }
.mapToObj( id -> (AnyValue) ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( id ) ) ) .collect( Collectors.toList() ) );
for ( int i = 0; i < relationships.length; i++ ) relationship[i] = proxySpi.newRelationshipProxy( relationships[i].id() );
public static AnyValue materializeAnyValueResult( EmbeddedProxySPI proxySpi, Object anyValue ) { if ( anyValue instanceof VirtualNodeValue ) { if ( anyValue instanceof NodeValue ) { return (AnyValue) anyValue; } return ValueUtils.fromNodeProxy( proxySpi.newNodeProxy( ((VirtualNodeValue) anyValue).id() ) ); } if ( anyValue instanceof VirtualRelationshipValue ) { if ( anyValue instanceof RelationshipValue ) { return (AnyValue) anyValue; } return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( ((VirtualRelationshipValue) anyValue).id() ) ); } // If it is a list or map, run it through a ValueMapper that will create proxy objects for entities if needed. // This will first do a dry run and return as it is if no conversion is needed. // If in the future we will always create proxy objects directly whenever we create values we can skip this // Doing this conversion lazily instead, by wrapping with TransformedListValue or TransformedMapValue is probably not a // good idea because of the complexities involved (see TOMBSTONE in VirtualValues about why TransformedListValue was killed). // NOTE: There is also a case where a ListValue can be storable (ArrayValueListValue) where no conversion is needed if ( (anyValue instanceof ListValue && !((ListValue) anyValue).storable()) || anyValue instanceof MapValue ) { return CompiledMaterializeValueMapper.mapAnyValue( proxySpi, (AnyValue) anyValue ); } return (AnyValue) anyValue; }
long relationshipId = transaction.dataWrite() .relationshipCreate( nodeId, relationshipTypeId, otherNode.getId() ); return spi.newRelationshipProxy( relationshipId, nodeId, relationshipTypeId, otherNode.getId() );
@Override public Relationship relationship( long id, long startNodeId, int typeId, long endNodeId ) { return spi.newRelationshipProxy( id, startNodeId, typeId, endNodeId ); } }
@Override protected Relationship newRelationshipProxyById( long id ) { return EmbeddedProxySPI.newRelationshipProxy( id ); }
@Override protected Relationship newRelationshipProxyById( long id ) { return nodeManager.newRelationshipProxy( id ); }
@Override public AnyValue mapRelationship( VirtualRelationshipValue value ) { if ( value instanceof RelationshipValue ) { return value; } return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( value.id() ) ); }
public static RelationshipValue materializeRelationshipValue( EmbeddedProxySPI proxySpi, Object anyValue ) { // Null check has to be done outside by the generated code if ( anyValue instanceof RelationshipValue ) { return (RelationshipValue) anyValue; } else if ( anyValue instanceof VirtualRelationshipValue ) { return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( ((VirtualRelationshipValue) anyValue).id() ) ); } else if ( anyValue instanceof Relationship ) { return ValueUtils.fromRelationshipProxy( (Relationship) anyValue ); } throw new IllegalArgumentException( "Do not know how to materialize relationship value from type " + anyValue.getClass().getName() ); }
private Relationship relationship( long relId ) { RelationshipProxy relationship = proxySpi.newRelationshipProxy( relId ); if ( !state.relationshipVisit( relId, relationship ) ) { // This relationship has been created or changed in this transaction RelationshipProxy cached = relationshipsReadFromStore.get( relId ); if ( cached != null ) { return cached; } try { // Get this relationship data from the store store.relationshipVisit( relId, relationship ); relationshipsReadFromStore.put( relId, relationship ); } catch ( EntityNotFoundException e ) { throw new IllegalStateException( "Getting deleted relationship data should have been covered by the tx state", e ); } } return relationship; }
.mapToObj( id -> (AnyValue) ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( id ) ) ) .collect( Collectors.toList() ) );
long relationshipId = transaction.dataWrite() .relationshipCreate( nodeId, relationshipTypeId, otherNode.getId() ); return spi.newRelationshipProxy( relationshipId, nodeId, relationshipTypeId, otherNode.getId() );
public static AnyValue materializeAnyValueResult( EmbeddedProxySPI proxySpi, Object anyValue ) { if ( anyValue instanceof VirtualNodeValue ) { if ( anyValue instanceof NodeValue ) { return (AnyValue) anyValue; } return ValueUtils.fromNodeProxy( proxySpi.newNodeProxy( ((VirtualNodeValue) anyValue).id() ) ); } if ( anyValue instanceof VirtualRelationshipValue ) { if ( anyValue instanceof RelationshipValue ) { return (AnyValue) anyValue; } return ValueUtils.fromRelationshipProxy( proxySpi.newRelationshipProxy( ((VirtualRelationshipValue) anyValue).id() ) ); } // If it is a list or map, run it through a ValueMapper that will create proxy objects for entities if needed. // This will first do a dry run and return as it is if no conversion is needed. // If in the future we will always create proxy objects directly whenever we create values we can skip this // Doing this conversion lazily instead, by wrapping with TransformedListValue or TransformedMapValue is probably not a // good idea because of the complexities involved (see TOMBSTONE in VirtualValues about why TransformedListValue was killed). // NOTE: There is also a case where a ListValue can be storable (ArrayValueListValue) where no conversion is needed if ( (anyValue instanceof ListValue && !((ListValue) anyValue).storable()) || anyValue instanceof MapValue ) { return CompiledMaterializeValueMapper.mapAnyValue( proxySpi, (AnyValue) anyValue ); } return (AnyValue) anyValue; }