Esempio n. 1
0
 public override void Feed(EntityCommandGrouper <Command.NodeCommand> .Cursor nodeCommands, EntityCommandGrouper <Command.RelationshipCommand> .Cursor relationshipCommands)
 {
     while (nodeCommands.nextEntity())
     {
         GatherUpdatesFor(nodeCommands.currentEntityId(), nodeCommands.currentEntityCommand(), nodeCommands);
     }
     while (relationshipCommands.nextEntity())
     {
         GatherUpdatesFor(relationshipCommands.currentEntityId(), relationshipCommands.currentEntityCommand(), relationshipCommands);
     }
 }
Esempio n. 2
0
        private void GatherUpdatesFor(long nodeId, Command.NodeCommand nodeCommand, EntityCommandGrouper <Command.NodeCommand> .Cursor propertyCommands)
        {
            EntityUpdates.Builder nodePropertyUpdate = GatherUpdatesFromCommandsForNode(nodeId, nodeCommand, propertyCommands);

            EntityUpdates entityUpdates = nodePropertyUpdate.Build();

            // we need to materialize the IndexEntryUpdates here, because when we
            // consume (later in separate thread) the store might have changed.
            foreach (IndexEntryUpdate <SchemaDescriptor> update in _updateService.convertToIndexUpdates(entityUpdates, EntityType.NODE))
            {
                _updates.Add(update);
            }
        }
Esempio n. 3
0
        private EntityCommandGrouper <ENTITY> .Cursor Group <ENTITY>(ENTITY entityCommand, Type cls, params Command.PropertyCommand[] propertyCommands) where ENTITY : Org.Neo4j.Kernel.impl.transaction.command.Command
        {
            cls = typeof(ENTITY);
            EntityCommandGrouper <ENTITY> grouper = new EntityCommandGrouper <ENTITY>(cls, 8);

            if (entityCommand != null)
            {
                grouper.Add(entityCommand);
            }
            foreach (Command.PropertyCommand propertyCommand in propertyCommands)
            {
                grouper.Add(propertyCommand);
            }
            return(grouper.SortAndAccessGroups());
        }
Esempio n. 4
0
 public override void Feed(EntityCommandGrouper <Command.NodeCommand> .Cursor nodeCommands, EntityCommandGrouper <Command.RelationshipCommand> .Cursor relationshipCommands)
 {
     throw new System.NotSupportedException();
 }
Esempio n. 5
0
        private EntityUpdates.Builder GatherUpdatesFromCommandsForRelationship(long relationshipId, Command.RelationshipCommand relationshipCommand, EntityCommandGrouper <Command.RelationshipCommand> .Cursor propertyCommands)
        {
            long reltypeBefore;
            long reltypeAfter;

            if (relationshipCommand != null)
            {
                reltypeBefore = relationshipCommand.Before.Type;
                reltypeAfter  = relationshipCommand.After.Type;
            }
            else
            {
                RelationshipRecord relationshipRecord = LoadRelationship(relationshipId);
                reltypeBefore = reltypeAfter = relationshipRecord.Type;
            }
            bool complete = ProvidesCompleteListOfProperties(relationshipCommand);

            EntityUpdates.Builder relationshipPropertyUpdates = EntityUpdates.forEntity(relationshipId, complete).withTokens(reltypeBefore).withTokensAfter(reltypeAfter);
            _converter.convertPropertyRecord(propertyCommands, relationshipPropertyUpdates);
            return(relationshipPropertyUpdates);
        }
Esempio n. 6
0
        private EntityUpdates.Builder GatherUpdatesFromCommandsForNode(long nodeId, Command.NodeCommand nodeChanges, EntityCommandGrouper <Command.NodeCommand> .Cursor propertyCommandsForNode)
        {
            long[] nodeLabelsBefore;
            long[] nodeLabelsAfter;
            if (nodeChanges != null)
            {
                nodeLabelsBefore = parseLabelsField(nodeChanges.Before).get(_nodeStore);
                nodeLabelsAfter  = parseLabelsField(nodeChanges.After).get(_nodeStore);
            }
            else
            {
                /* If the node doesn't exist here then we've most likely encountered this scenario:
                 * - TX1: Node N exists and has property record P
                 * - rotate log
                 * - TX2: P gets changed
                 * - TX3: N gets deleted (also P, but that's irrelevant for this scenario)
                 * - N is persisted to disk for some reason
                 * - crash
                 * - recover
                 * - TX2: P has changed and updates to indexes are gathered. As part of that it tries to read
                 *        the labels of N (which does not exist a.t.m.).
                 *
                 * We can actually (if we disregard any potential inconsistencies) just assume that
                 * if this happens and we're in recovery mode that the node in question will be deleted
                 * in an upcoming transaction, so just skip this update.
                 */
                NodeRecord nodeRecord = LoadNode(nodeId);
                nodeLabelsBefore = nodeLabelsAfter = parseLabelsField(nodeRecord).get(_nodeStore);
            }

            // First get possible Label changes
            bool complete = ProvidesCompleteListOfProperties(nodeChanges);

            EntityUpdates.Builder nodePropertyUpdates = EntityUpdates.forEntity(nodeId, complete).withTokens(nodeLabelsBefore).withTokensAfter(nodeLabelsAfter);

            // Then look for property changes
            _converter.convertPropertyRecord(propertyCommandsForNode, nodePropertyUpdates);
            return(nodePropertyUpdates);
        }
Esempio n. 7
0
        private void GatherUpdatesFor(long relationshipId, Command.RelationshipCommand relationshipCommand, EntityCommandGrouper <Command.RelationshipCommand> .Cursor propertyCommands)
        {
            EntityUpdates.Builder relationshipPropertyUpdate = GatherUpdatesFromCommandsForRelationship(relationshipId, relationshipCommand, propertyCommands);

            EntityUpdates entityUpdates = relationshipPropertyUpdate.Build();

            // we need to materialize the IndexEntryUpdates here, because when we
            // consume (later in separate thread) the store might have changed.
            foreach (IndexEntryUpdate <SchemaDescriptor> update in _updateService.convertToIndexUpdates(entityUpdates, EntityType.RELATIONSHIP))
            {
                _updates.Add(update);
            }
        }