@Override public int next() { return properties.next().propertyKeyId(); } }
@Override public int propertyKey() { if ( txStateValue != null ) { return txStateValue.propertyKeyId(); } return storeCursor.propertyKey(); }
@Override public void visitGraphPropertyChanges( Iterator<StorageProperty> added, Iterator<StorageProperty> changed, IntIterable removed ) { removed.each( recordState::graphRemoveProperty ); while ( changed.hasNext() ) { StorageProperty prop = changed.next(); recordState.graphChangeProperty( prop.propertyKeyId(), prop.value() ); } while ( added.hasNext() ) { StorageProperty prop = added.next(); recordState.graphAddProperty( prop.propertyKeyId(), prop.value() ); } }
@Override public void visitNodePropertyChanges( long id, Iterator<StorageProperty> added, Iterator<StorageProperty> changed, IntIterable removed ) { removed.each( propId -> recordState.nodeRemoveProperty( id, propId ) ); while ( changed.hasNext() ) { StorageProperty prop = changed.next(); recordState.nodeChangeProperty( id, prop.propertyKeyId(), prop.value() ); } while ( added.hasNext() ) { StorageProperty prop = added.next(); recordState.nodeAddProperty( id, prop.propertyKeyId(), prop.value() ); } }
@Override public void visitRelPropertyChanges( long id, Iterator<StorageProperty> added, Iterator<StorageProperty> changed, IntIterable removed ) { removed.each( relId -> recordState.relRemoveProperty( id, relId ) ); while ( changed.hasNext() ) { StorageProperty prop = changed.next(); recordState.relChangeProperty( id, prop.propertyKeyId(), prop.value() ); } while ( added.hasNext() ) { StorageProperty prop = added.next(); recordState.relAddProperty( id, prop.propertyKeyId(), prop.value() ); } }
private PropertyReceiver<StorageProperty> newPropertyReceiver( Map<Integer,Pair<StorageProperty,Long>> props ) { return ( property, propertyRecordId ) -> props.put( property.propertyKeyId(), Pair.of( property, propertyRecordId ) ); }
private PropertyLoader propertyLoader( StorageProperty... properties ) { Map<Integer, Value> propertyMap = new HashMap<>( ); for ( StorageProperty p : properties ) { propertyMap.put( p.propertyKeyId(), p.value() ); } return ( nodeId1, type, propertyIds, sink ) -> { MutableIntIterator iterator = propertyIds.intIterator(); while ( iterator.hasNext() ) { int propertyId = iterator.next(); if ( propertyMap.containsKey( propertyId ) ) { sink.onProperty( propertyId, propertyMap.get( propertyId ) ); iterator.remove(); } } }; }
@Test public void shouldNotGenerateUpdatesForLabelRemoveAndPropertyAdd() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( empty ) .added( property1.propertyKeyId(), property1.value() ) .added( property2.propertyKeyId(), property2.value() ) .added( property3.propertyKeyId(), property3.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, assertNoLoading(), EntityType.NODE ), emptyIterable() ); }
@Test public void shouldGenerateUpdateForFullNonSchemaIndexUpdate() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .added( property1.propertyKeyId(), property1.value() ) .added( property2.propertyKeyId(), property2.value() ) .added( property3.propertyKeyId(), property3.value() ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader(), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, nonSchemaIndex, values123 ) ) ); }
@Test public void shouldNotGenerateUpdatesForLabelAddAndPropertyRemove() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ).withTokensAfter( label ) .removed( property1.propertyKeyId(), property1.value() ) .removed( property2.propertyKeyId(), property2.value() ) .removed( property3.propertyKeyId(), property3.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, assertNoLoading(), EntityType.NODE ), emptyIterable() ); }
PropertyBlock block = record.getPropertyBlock( props.get( keyId ).first().propertyKeyId() ); StorageProperty data = block.newPropertyKeyValue( pStore ); if ( data.propertyKeyId() == prop1.propertyKeyId() ) relAddProperty( rel, prop1.propertyKeyId(), "-string2" ); else if ( data.propertyKeyId() == prop2.propertyKeyId() ) relAddProperty( rel, prop2.propertyKeyId(), -2 ); else if ( data.propertyKeyId() == prop3.propertyKeyId() ) relAddProperty( rel, prop3.propertyKeyId(), true );
@Test public void shouldNotLoadPropertyForNoLabelsAndButPropertyAddition() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ) .added( property1.propertyKeyId(), property1.value() ) .build(); // Then assertThat( updates.forIndexKeys( singleton( index1 ), assertNoLoading(), EntityType.NODE ), emptyIterable() ); }
@Test public void shouldGenerateUpdateForAllChangedNonSchemaIndex() { // When Value newValue1 = Values.of( "Nio" ); Value newValue2 = Values.of( 10L ); Value newValue3 = Values.pointValue( CoordinateReferenceSystem.WGS84, 32.3, 15.6 ); EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .changed( property1.propertyKeyId(), property1.value(), newValue1 ) .changed( property2.propertyKeyId(), property2.value(), newValue2 ) .changed( property3.propertyKeyId(), property3.value(), newValue3 ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.change( nodeId, nonSchemaIndex, values123, new Value[]{newValue1, newValue2, newValue3} ) ) ); }
@Test public void shouldGenerateUpdateWhenRemovingLastPropForNonSchemaIndex() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .removed( property2.propertyKeyId(), property2.value() ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property2), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.remove( nodeId, nonSchemaIndex, null, property2.value(), null ) ) ); }
@Test public void shouldNotGenerateUpdatesForPropertyAdditionWithNoLabels() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ) .added( property1.propertyKeyId(), property1.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, assertNoLoading(), EntityType.NODE ), emptyIterable() ); }
@Test public void shouldGenerateUpdateWhenRemovingOnePropertyForNonSchemaIndex() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .removed( property2.propertyKeyId(), property2.value() ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.change( nodeId, nonSchemaIndex, values123, new Value[]{property1.value(), null, property3.value()} ) ) ); }
@Test public void shouldGenerateUpdatesForSinglePropertyAdditionWithLabels() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ) .added( property1.propertyKeyId(), property1.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader(), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ) ) ); }
@Test public void shouldGenerateUpdatesForMultiplePropertyAdditionWithLabels() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ) .added( property1.propertyKeyId(), property1.value() ) .added( property2.propertyKeyId(), property2.value() ) .added( property3.propertyKeyId(), property3.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ), IndexEntryUpdate.add( nodeId, index2, property2.value() ), IndexEntryUpdate.add( nodeId, index3, property3.value() ), IndexEntryUpdate.add( nodeId, index123, values123 ) ) ); }
@Test public void shouldGenerateUpdateForSingleChangeNonSchemaIndex() { // When Value newValue2 = Values.of( 10L ); EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .changed( property2.propertyKeyId(), property2.value(), newValue2 ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.change( nodeId, nonSchemaIndex, values123, new Value[]{property1.value(), newValue2, property3.value()} ) ) ); }
@Test public void testProps1() throws Exception { initializeStores( databaseLayout, stringMap() ); startTx(); long nodeId = nextId( Node.class ); transaction.nodeDoCreate( nodeId ); pStore.nextId(); StorageProperty prop = nodeAddProperty( nodeId, index( "nisse" ), 10 ); commitTx(); ds.stop(); initializeStores( databaseLayout, stringMap() ); startTx(); StorageProperty prop2 = nodeAddProperty( nodeId, prop.propertyKeyId(), 5 ); transaction.nodeDoRemoveProperty( nodeId, prop2.propertyKeyId() ); transaction.nodeDoDelete( nodeId ); commitTx(); ds.stop(); }