Search in sources :

Example 21 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class EntityTokenUpdatesTest method shouldNotGenerateUpdatesForEmptyEntityUpdates.

@ParameterizedTest
@EnumSource(Entity.class)
void shouldNotGenerateUpdatesForEmptyEntityUpdates(Entity entity) {
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).build();
    assertThat(updates.tokenUpdateForIndexKey(entity.getTokenIndex(), -1)).isEmpty();
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class EntityTokenUpdatesTest method shouldGenerateUpdateForChangedTokens.

@ParameterizedTest
@EnumSource(Entity.class)
void shouldGenerateUpdateForChangedTokens(Entity entity) {
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).withTokens(TOKEN_1_ID).withTokensAfter(TOKEN_1_ID, TOKEN_2_ID).build();
    assertThat(updates.tokenUpdateForIndexKey(entity.getTokenIndex(), -1)).contains(IndexEntryUpdate.change(ENTITY_ID, entity.getTokenIndex(), new long[] { TOKEN_1_ID }, new long[] { TOKEN_1_ID, TOKEN_2_ID }));
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedChangedProperty.

@Test
void shouldConvertInlinedChangedProperty() {
    // GIVEN
    int key = 10;
    Value valueBefore = Values.of(12341);
    Value valueAfter = Values.of(738);
    PropertyRecord before = propertyRecord(property(key, valueBefore));
    PropertyRecord after = propertyRecord(property(key, valueAfter));
    // WHEN
    EntityUpdates update = convert(none, none, change(before, after));
    // THEN
    EntityUpdates expected = EntityUpdates.forEntity(0, false).changed(key, valueBefore, valueAfter).build();
    assertEquals(expected, update);
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Example 24 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertDynamicInlinedRemovedProperty.

@Test
void shouldConvertDynamicInlinedRemovedProperty() {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord(property(key, longString));
    PropertyRecord after = propertyRecord();
    // WHEN
    EntityUpdates update = convert(none, none, change(before, after));
    // THEN
    EntityUpdates expected = EntityUpdates.forEntity(0, false).removed(key, longString).build();
    assertEquals(expected, update);
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.jupiter.api.Test)

Example 25 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method applyConcurrentAddsToPopulatedIndex.

@ParameterizedTest
@MethodSource("parameters")
void applyConcurrentAddsToPopulatedIndex(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
    List<EntityUpdates> updates = new ArrayList<>(2);
    updates.add(EntityUpdates.forEntity(otherNodes[0].getId(), false).withTokens(id(COUNTRY_LABEL)).added(propertyId, Values.of("Denmark")).build());
    updates.add(EntityUpdates.forEntity(otherNodes[1].getId(), false).withTokens(id(CAR_LABEL)).added(propertyId, Values.of("BMW")).build());
    launchCustomIndexPopulation(schemaIndex, labelsNameIdMap, propertyId, new UpdateGenerator(updates));
    waitAndActivateIndexes(labelsNameIdMap, propertyId);
    try (Transaction tx = db.beginTx()) {
        Integer countryLabelId = labelsNameIdMap.get(COUNTRY_LABEL);
        Integer carLabelId = labelsNameIdMap.get(CAR_LABEL);
        try (var indexReader = getIndexReader(propertyId, countryLabelId)) {
            assertThat(indexReader.countIndexedEntities(otherNodes[0].getId(), NULL, new int[] { propertyId }, Values.of("Denmark"))).as("Should be added by concurrent add.").isEqualTo(1);
        }
        try (var indexReader = getIndexReader(propertyId, carLabelId)) {
            assertThat(indexReader.countIndexedEntities(otherNodes[1].getId(), NULL, new int[] { propertyId }, Values.of("BMW"))).as("Should be added by concurrent add.").isEqualTo(1);
        }
    }
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ArrayList(java.util.ArrayList) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)41 Test (org.junit.jupiter.api.Test)22 EnumSource (org.junit.jupiter.params.provider.EnumSource)21 Value (org.neo4j.values.storable.Value)6 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)4 ArrayList (java.util.ArrayList)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Transaction (org.neo4j.graphdb.Transaction)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3 PropertyKeyValue (org.neo4j.storageengine.api.PropertyKeyValue)3 StorageNodeCursor (org.neo4j.storageengine.api.StorageNodeCursor)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 StoragePropertyCursor (org.neo4j.storageengine.api.StoragePropertyCursor)1 StorageReader (org.neo4j.storageengine.api.StorageReader)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1