Search in sources :

Example 6 with NodeCommand

use of org.neo4j.internal.recordstorage.Command.NodeCommand 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 7 with NodeCommand

use of org.neo4j.internal.recordstorage.Command.NodeCommand in project neo4j by neo4j.

the class IndexTransactionApplierFactoryTest method node.

private static NodeCommand node(long nodeId) {
    NodeRecord after = new NodeRecord(nodeId).initialize(true, NO_NEXT_PROPERTY.intValue(), false, NO_NEXT_RELATIONSHIP.intValue(), 0);
    NodeLabelsField.parseLabelsField(after).add(1, null, null, NULL, INSTANCE);
    return new NodeCommand(new NodeRecord(nodeId), after);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeCommand(org.neo4j.internal.recordstorage.Command.NodeCommand)

Example 8 with NodeCommand

use of org.neo4j.internal.recordstorage.Command.NodeCommand in project neo4j by neo4j.

the class OnlineIndexUpdatesTest method shouldContainFedNodeUpdate.

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

Aggregations

NodeCommand (org.neo4j.internal.recordstorage.Command.NodeCommand)8 Test (org.junit.jupiter.api.Test)6 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)6 RelationshipCommand (org.neo4j.internal.recordstorage.Command.RelationshipCommand)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 ArrayList (java.util.ArrayList)2 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)2 RelationshipGroupCommand (org.neo4j.internal.recordstorage.Command.RelationshipGroupCommand)2 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)2 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)2 StorageCommand (org.neo4j.storageengine.api.StorageCommand)2 Value (org.neo4j.values.storable.Value)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1 DEFAULT_DATABASE_NAME (org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME)1