Search in sources :

Example 86 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class RecordBuilders method rel.

public static RelationshipRecord rel(long id, Consumer<RelationshipRecord>... modifiers) {
    RelationshipRecord record = new RelationshipRecord(id);
    record.initialize(true, Record.NO_NEXT_PROPERTY.intValue(), -1, -1, 0, Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), true, true);
    for (Consumer<RelationshipRecord> modifier : modifiers) {
        modifier.accept(record);
    }
    return record;
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

Example 87 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class OnlineIndexUpdatesTest method shouldContainFedRelationshipUpdate.

@Test
void shouldContainFedRelationshipUpdate() {
    OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(nodeStore, schemaCache, propertyPhysicalToLogicalConverter, new RecordStorageReader(neoStores), CursorContext.NULL, INSTANCE);
    long relId = 0;
    RelationshipRecord inUse = getRelationship(relId, true, ENTITY_TOKEN);
    Value propertyValue = Values.of("hej");
    long propertyId = createRelationshipProperty(inUse, propertyValue, 1);
    RelationshipRecord notInUse = getRelationship(relId, false, ENTITY_TOKEN);
    relationshipStore.updateRecord(inUse, CursorContext.NULL);
    Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
    PropertyRecord propertyBlocks = new PropertyRecord(propertyId);
    propertyBlocks.setRelId(relId);
    PropertyCommand propertyCommand = new PropertyCommand(recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);
    IndexDescriptor indexDescriptor = IndexPrototype.forSchema(fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 1, 4, 6 })).withName("index").materialise(0);
    createIndexes(indexDescriptor);
    onlineIndexUpdates.feed(nodeGroup(null), relationshipGroup(relationshipCommand, propertyCommand), -1);
    assertTrue(onlineIndexUpdates.hasUpdates());
    Iterator<IndexEntryUpdate<IndexDescriptor>> iterator = onlineIndexUpdates.iterator();
    assertEquals(iterator.next(), IndexEntryUpdate.remove(relId, indexDescriptor, propertyValue, null, null));
    assertFalse(iterator.hasNext());
}
Also used : IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Example 88 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class OnlineIndexUpdatesTest method shouldUpdateCorrectIndexes.

@Test
void shouldUpdateCorrectIndexes() {
    OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(nodeStore, schemaCache, propertyPhysicalToLogicalConverter, new RecordStorageReader(neoStores), CursorContext.NULL, INSTANCE);
    long relId = 0;
    RelationshipRecord inUse = getRelationship(relId, true, ENTITY_TOKEN);
    Value propertyValue = Values.of("hej");
    Value propertyValue2 = Values.of("da");
    long propertyId = createRelationshipProperty(inUse, propertyValue, 1);
    long propertyId2 = createRelationshipProperty(inUse, propertyValue2, 4);
    RelationshipRecord notInUse = getRelationship(relId, false, ENTITY_TOKEN);
    relationshipStore.updateRecord(inUse, CursorContext.NULL);
    Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
    PropertyRecord propertyBlocks = new PropertyRecord(propertyId);
    propertyBlocks.setRelId(relId);
    PropertyCommand propertyCommand = new PropertyCommand(recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);
    PropertyRecord propertyBlocks2 = new PropertyRecord(propertyId2);
    propertyBlocks2.setRelId(relId);
    PropertyCommand propertyCommand2 = new PropertyCommand(recordAccess.getIfLoaded(propertyId2).forReadingData(), propertyBlocks2);
    IndexDescriptor indexDescriptor0 = IndexPrototype.forSchema(fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 1, 4, 6 })).withName("index_0").materialise(0);
    IndexDescriptor indexDescriptor1 = IndexPrototype.forSchema(fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 2, 4, 6 })).withName("index_1").materialise(1);
    IndexDescriptor indexDescriptor = IndexPrototype.forSchema(fulltext(RELATIONSHIP, new int[] { ENTITY_TOKEN, OTHER_ENTITY_TOKEN }, new int[] { 1 })).withName("index_2").materialise(2);
    createIndexes(indexDescriptor0, indexDescriptor1, indexDescriptor);
    onlineIndexUpdates.feed(nodeGroup(null), relationshipGroup(relationshipCommand, propertyCommand, propertyCommand2), -1);
    assertTrue(onlineIndexUpdates.hasUpdates());
    assertThat(onlineIndexUpdates).contains(IndexEntryUpdate.remove(relId, indexDescriptor0, propertyValue, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor1, null, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor, propertyValue));
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Value(org.neo4j.values.storable.Value) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Test(org.junit.jupiter.api.Test)

Example 89 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class OnlineIndexUpdatesTest method shouldDifferentiateNodesAndRelationships.

@Test
void shouldDifferentiateNodesAndRelationships() {
    OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(nodeStore, schemaCache, propertyPhysicalToLogicalConverter, new RecordStorageReader(neoStores), CursorContext.NULL, INSTANCE);
    int nodeId = 0;
    NodeRecord inUseNode = getNode(nodeId, true);
    Value nodePropertyValue = Values.of("hej");
    long nodePropertyId = createNodeProperty(inUseNode, nodePropertyValue, 1);
    NodeRecord notInUseNode = getNode(nodeId, false);
    nodeStore.updateRecord(inUseNode, CursorContext.NULL);
    NodeCommand nodeCommand = new NodeCommand(inUseNode, notInUseNode);
    PropertyRecord nodePropertyBlocks = new PropertyRecord(nodePropertyId);
    nodePropertyBlocks.setNodeId(nodeId);
    PropertyCommand nodePropertyCommand = new PropertyCommand(recordAccess.getIfLoaded(nodePropertyId).forReadingData(), nodePropertyBlocks);
    IndexDescriptor nodeIndexDescriptor = IndexPrototype.forSchema(fulltext(NODE, ENTITY_TOKENS, new int[] { 1, 4, 6 })).withName("index").materialise(0);
    createIndexes(nodeIndexDescriptor);
    long relId = 0;
    RelationshipRecord inUse = getRelationship(relId, true, ENTITY_TOKEN);
    Value relationshipPropertyValue = Values.of("da");
    long propertyId = createRelationshipProperty(inUse, relationshipPropertyValue, 1);
    RelationshipRecord notInUse = getRelationship(relId, false, ENTITY_TOKEN);
    relationshipStore.updateRecord(inUse, CursorContext.NULL);
    Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
    PropertyRecord relationshipPropertyBlocks = new PropertyRecord(propertyId);
    relationshipPropertyBlocks.setRelId(relId);
    PropertyCommand relationshipPropertyCommand = new PropertyCommand(recordAccess.getIfLoaded(propertyId).forReadingData(), relationshipPropertyBlocks);
    FulltextSchemaDescriptor schema = fulltext(RELATIONSHIP, ENTITY_TOKENS, new int[] { 1, 4, 6 });
    IndexDescriptor relationshipIndexDescriptor = IndexPrototype.forSchema(schema).withName("index").materialise(1);
    createIndexes(relationshipIndexDescriptor);
    onlineIndexUpdates.feed(nodeGroup(nodeCommand, nodePropertyCommand), relationshipGroup(relationshipCommand, relationshipPropertyCommand), -1);
    assertTrue(onlineIndexUpdates.hasUpdates());
    assertThat(onlineIndexUpdates).contains(IndexEntryUpdate.remove(relId, relationshipIndexDescriptor, relationshipPropertyValue, null, null), IndexEntryUpdate.remove(nodeId, nodeIndexDescriptor, nodePropertyValue, null, null));
}
Also used : RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) Value(org.neo4j.values.storable.Value) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand) Test(org.junit.jupiter.api.Test)

Example 90 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class ConsistencyCheckServiceIntegrationTest method prepareDbWithDeletedRelationshipPartOfTheChain.

private void prepareDbWithDeletedRelationshipPartOfTheChain() {
    RelationshipType relationshipType = RelationshipType.withName("testRelationshipType");
    fixture.apply(tx -> {
        Node node1 = set(tx.createNode());
        Node node2 = set(tx.createNode(), property("key", "value"));
        node1.createRelationshipTo(node2, relationshipType);
        node1.createRelationshipTo(node2, relationshipType);
        node1.createRelationshipTo(node2, relationshipType);
        node1.createRelationshipTo(node2, relationshipType);
        node1.createRelationshipTo(node2, relationshipType);
        node1.createRelationshipTo(node2, relationshipType);
    });
    NeoStores neoStores = fixture.neoStores();
    RelationshipStore relationshipStore = neoStores.getRelationshipStore();
    RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
    RelationshipRecord record = relationshipStore.getRecord(4, relationshipRecord, RecordLoad.FORCE, NULL);
    record.setInUse(false);
    relationshipStore.updateRecord(relationshipRecord, NULL);
}
Also used : Node(org.neo4j.graphdb.Node) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipType(org.neo4j.graphdb.RelationshipType) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

Aggregations

RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)207 Test (org.junit.Test)73 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)69 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)43 Test (org.junit.jupiter.api.Test)34 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)19 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)14 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)12 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)12 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)12 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)11 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)9 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)7 IOException (java.io.IOException)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6