@Override public ValueGroup propertyType() { if ( txStateValue != null ) { return txStateValue.value().valueGroup(); } return storeCursor.propertyType(); }
@Override public Value propertyValue() { if ( txStateValue != null ) { return txStateValue.value(); } Value value = storeCursor.propertyValue(); assertOpen.assertOpen(); return value; }
@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() ); } }
@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 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 shouldGenerateUpdatesForLabelRemovalWithExistingProperties() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( empty ).build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.remove( nodeId, index1, property1.value() ), IndexEntryUpdate.remove( nodeId, index2, property2.value() ), IndexEntryUpdate.remove( nodeId, index3, property3.value() ), IndexEntryUpdate.remove( nodeId, index123, values123 ) ) ); }
@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 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 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() ); }
@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 shouldGenerateUpdateForLabelAdditionWithExistingProperty() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( empty ).withTokensAfter( label ).build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader( property1 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ) ) ); }
@Test public void shouldGenerateUpdateForLabelRemovalWithExistingProperty() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( empty ).build(); // Then assertThat( updates.forIndexKeys( indexes, propertyLoader( property1 ), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.remove( nodeId, index1, property1.value() ) ) ); }
@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 shouldGenerateUpdateForPartialNonSchemaIndexUpdate() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ).withTokens( label ).withTokensAfter( label ) .added( propertyKeyId1, Values.of( "Neo" ) ) .build(); // Then assertThat( updates.forIndexKeys( singleton( nonSchemaIndex ), propertyLoader(), EntityType.NODE ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, nonSchemaIndex, property1.value(), null, null ) ) ); }
@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 shouldNotGenerateUpdatesForPropertyAdditionWithNoLabels() { // When EntityUpdates updates = EntityUpdates.forEntity( nodeId ) .added( property1.propertyKeyId(), property1.value() ) .build(); // Then assertThat( updates.forIndexKeys( indexes, assertNoLoading(), EntityType.NODE ), emptyIterable() ); }
private StorageProperty relAddProperty( long relationshipId, int key, Object value ) { StorageProperty property = new PropertyKeyValue( key, Values.of( value ) ); Value oldValue = Values.NO_VALUE; try ( StorageRelationshipScanCursor cursor = storageReader.allocateRelationshipScanCursor() ) { cursor.single( relationshipId ); if ( cursor.next() ) { StorageProperty fetched = getProperty( key, cursor.propertiesReference() ); if ( fetched != null ) { oldValue = fetched.value(); } } } transaction.relationshipDoReplaceProperty( relationshipId, key, oldValue, Values.of( value ) ); return property; }