Search in sources :

Example 1 with NodeUpdates

use of org.neo4j.kernel.api.index.NodeUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertDynamicChangedProperty.

@Test
public void shouldConvertDynamicChangedProperty() throws Exception {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord(property(key, longString));
    PropertyRecord after = propertyRecord(property(key, longerString));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(0).changed(key, longString, longerString).build();
    assertEquals(expected, update);
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 2 with NodeUpdates

use of org.neo4j.kernel.api.index.NodeUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldTreatPropertyThatMovedToAnotherRecordAsChange.

@Test
public void shouldTreatPropertyThatMovedToAnotherRecordAsChange() throws Exception {
    // GIVEN
    int key = 12;
    String oldValue = "value1";
    String newValue = "value two";
    PropertyRecordChange movedFrom = change(propertyRecord(property(key, oldValue)), propertyRecord());
    PropertyRecordChange movedTo = change(propertyRecord(), propertyRecord(property(key, newValue)));
    // WHEN
    NodeUpdates update = convert(none, none, movedFrom, movedTo);
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(0).changed(key, oldValue, newValue).build();
    assertEquals(expected, update);
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecordChange(org.neo4j.kernel.impl.transaction.state.PropertyRecordChange) Test(org.junit.Test)

Example 3 with NodeUpdates

use of org.neo4j.kernel.api.index.NodeUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedChangedProperty.

@Test
public void shouldConvertInlinedChangedProperty() throws Exception {
    // GIVEN
    int key = 10;
    int valueBefore = 12341, valueAfter = 738;
    PropertyRecord before = propertyRecord(property(key, valueBefore));
    PropertyRecord after = propertyRecord(property(key, valueAfter));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    NodeUpdates expected = NodeUpdates.forNode(0).changed(key, valueBefore, valueAfter).build();
    assertEquals(expected, update);
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 4 with NodeUpdates

use of org.neo4j.kernel.api.index.NodeUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldNotConvertDynamicAddedProperty.

@Test
public void shouldNotConvertDynamicAddedProperty() throws Exception {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord();
    PropertyRecord after = propertyRecord(property(key, longString));
    // WHEN
    NodeUpdates update = convert(none, none, change(before, after));
    // THEN
    assertFalse(update.hasIndexingAppropriateUpdates());
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.Test)

Example 5 with NodeUpdates

use of org.neo4j.kernel.api.index.NodeUpdates in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method applyConcurrentChangesToPopulatedIndex.

@Test
public void applyConcurrentChangesToPopulatedIndex() throws Exception {
    List<NodeUpdates> updates = new ArrayList<>(2);
    updates.add(NodeUpdates.forNode(3, id(COLOR_LABEL)).changed(propertyId, "green", "pink").build());
    updates.add(NodeUpdates.forNode(5, id(CAR_LABEL)).changed(propertyId, "Ford", "SAAB").build());
    launchCustomIndexPopulation(labelsNameIdMap, propertyId, updates);
    waitAndActivateIndexes(labelsNameIdMap, propertyId);
    try (Transaction ignored = embeddedDatabase.beginTx()) {
        Integer colorLabelId = labelsNameIdMap.get(COLOR_LABEL);
        Integer carLabelId = labelsNameIdMap.get(CAR_LABEL);
        try (IndexReader indexReader = getIndexReader(propertyId, colorLabelId)) {
            assertEquals("Should be deleted by concurrent change.", 0, indexReader.countIndexedNodes(3, "green"));
        }
        try (IndexReader indexReader = getIndexReader(propertyId, colorLabelId)) {
            assertEquals("Should be updated by concurrent change.", 1, indexReader.countIndexedNodes(3, "pink"));
        }
        try (IndexReader indexReader = getIndexReader(propertyId, carLabelId)) {
            assertEquals("Should be added by concurrent change.", 1, indexReader.countIndexedNodes(5, "SAAB"));
        }
    }
}
Also used : NodeUpdates(org.neo4j.kernel.api.index.NodeUpdates) Transaction(org.neo4j.graphdb.Transaction) ArrayList(java.util.ArrayList) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) Test(org.junit.Test)

Aggregations

NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)28 Test (org.junit.Test)25 NeoStores (org.neo4j.kernel.impl.store.NeoStores)9 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)5 NeoStoreIndexStoreView (org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView)5 ArrayList (java.util.ArrayList)4 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 Transaction (org.neo4j.graphdb.Transaction)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3 Collection (java.util.Collection)2 Visitor (org.neo4j.helpers.collection.Visitor)2 KernelException (org.neo4j.kernel.api.exceptions.KernelException)2 NodeLabelUpdate (org.neo4j.kernel.api.labelscan.NodeLabelUpdate)2 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)2 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)2 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Boolean.parseBoolean (java.lang.Boolean.parseBoolean)1