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));
}
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);
}
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());
}
Aggregations