//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentAddsToPopulatedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentAddsToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_otherNodes[0].Id, false).withTokens(Id(COUNTRY_LABEL)).added(_propertyId, Values.of("Denmark")).build());
            updates.Add(EntityUpdates.forEntity(_otherNodes[1].Id, false).withTokens(Id(CAR_LABEL)).added(_propertyId, Values.of("BMW")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?countryLabelId = _labelsNameIdMap[COUNTRY_LABEL];
                int?carLabelId     = _labelsNameIdMap[CAR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, countryLabelId))
                {
                    assertEquals("Should be added by concurrent add.", 1, indexReader.CountIndexedNodes(_otherNodes[0].Id, new int[] { _propertyId }, Values.of("Denmark")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, carLabelId))
                {
                    assertEquals("Should be added by concurrent add.", 1, indexReader.CountIndexedNodes(_otherNodes[1].Id, new int[] { _propertyId }, Values.of("BMW")));
                }
            }
        }
Exemplo n.º 2
0
        public override EntityUpdates NodeAsUpdates(long nodeId)
        {
            NodeRecord node = NodeStore.getRecord(nodeId, NodeStore.newRecord(), FORCE);

            if (!node.InUse())
            {
                return(null);
            }
            long firstPropertyId = node.NextProp;

            if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue())
            {
                return(null);                        // no properties => no updates (it's not going to be in any index)
            }
            long[] labels = parseLabelsField(node).get(NodeStore);
            if (labels.Length == 0)
            {
                return(null);                        // no labels => no updates (it's not going to be in any index)
            }
            EntityUpdates.Builder update = EntityUpdates.forEntity(nodeId, true).withTokens(labels);
            foreach (PropertyRecord propertyRecord in PropertyStore.getPropertyRecordChain(firstPropertyId))
            {
                foreach (PropertyBlock property in propertyRecord)
                {
                    Value value = property.Type.value(property, PropertyStore);
                    update.Added(property.KeyIndexId, value);
                }
            }
            return(update.Build());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentDeletesToPopulatedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentDeletesToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_country1.Id, false).withTokens(Id(COUNTRY_LABEL)).removed(_propertyId, Values.of("Sweden")).build());
            updates.Add(EntityUpdates.forEntity(_color2.Id, false).withTokens(Id(COLOR_LABEL)).removed(_propertyId, Values.of("green")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?countryLabelId = _labelsNameIdMap[COUNTRY_LABEL];
                int?colorLabelId   = _labelsNameIdMap[COLOR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, countryLabelId))
                {
                    assertEquals("Should be removed by concurrent remove.", 0, indexReader.CountIndexedNodes(0, new int[] { _propertyId }, Values.of("Sweden")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals("Should be removed by concurrent remove.", 0, indexReader.CountIndexedNodes(3, new int[] { _propertyId }, Values.of("green")));
                }
            }
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean process(org.neo4j.storageengine.api.StorageNodeCursor cursor) throws FAILURE
        public override bool Process(StorageNodeCursor cursor)
        {
            long[] labels = cursor.Labels();
            if (labels.Length == 0 && LabelIds.Length != 0)
            {
                // This node has no labels at all
                return(false);
            }

            if (_labelUpdateVisitor != null)
            {
                // Notify the label update visitor
                _labelUpdateVisitor.visit(labelChanges(cursor.EntityReference(), EMPTY_LONG_ARRAY, labels));
            }

            if (_propertyUpdatesVisitor != null && containsAnyEntityToken(LabelIds, labels))
            {
                // Notify the property update visitor
                EntityUpdates.Builder updates = EntityUpdates.forEntity(cursor.EntityReference(), true).withTokens(labels);

                if (hasRelevantProperty(cursor, updates))
                {
                    return(_propertyUpdatesVisitor.visit(updates.Build()));
                }
            }
            return(false);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyConcurrentChangesToPopulatedIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ApplyConcurrentChangesToPopulatedIndex()
        {
            IList <EntityUpdates> updates = new List <EntityUpdates>(2);

            updates.Add(EntityUpdates.forEntity(_color2.Id, false).withTokens(Id(COLOR_LABEL)).changed(_propertyId, Values.of("green"), Values.of("pink")).build());
            updates.Add(EntityUpdates.forEntity(_car2.Id, false).withTokens(Id(CAR_LABEL)).changed(_propertyId, Values.of("Ford"), Values.of("SAAB")).build());

            LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new UpdateGenerator(this, updates));
            WaitAndActivateIndexes(_labelsNameIdMap, _propertyId);

            using (Transaction ignored = EmbeddedDatabase.beginTx())
            {
                int?colorLabelId = _labelsNameIdMap[COLOR_LABEL];
                int?carLabelId   = _labelsNameIdMap[CAR_LABEL];
                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals(format("Should be deleted by concurrent change. Reader is: %s, ", indexReader), 0, indexReader.CountIndexedNodes(_color2.Id, new int[] { _propertyId }, Values.of("green")));
                }
                using (IndexReader indexReader = GetIndexReader(_propertyId, colorLabelId))
                {
                    assertEquals("Should be updated by concurrent change.", 1, indexReader.CountIndexedNodes(_color2.Id, new int[] { _propertyId }, Values.of("pink")));
                }

                using (IndexReader indexReader = GetIndexReader(_propertyId, carLabelId))
                {
                    assertEquals("Should be added by concurrent change.", 1, indexReader.CountIndexedNodes(_car2.Id, new int[] { _propertyId }, Values.of("SAAB")));
                }
            }
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdateForMultipleExistingPropertiesAndLabels()
        public virtual void ShouldNotGenerateUpdateForMultipleExistingPropertiesAndLabels()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).existing(PROPERTY_KEY_ID1, Values.of("Neo")).existing(PROPERTY_KEY_ID2, Values.of(100L)).existing(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdatesForEmptyNodeUpdates()
        public virtual void ShouldNotGenerateUpdatesForEmptyNodeUpdates()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex()
        public virtual void ShouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_empty).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Remove(NODE_ID, _nonSchemaIndex, _values123)));
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdateWhenRemovingOneTokenForNonSchemaIndex()
        public virtual void ShouldNotGenerateUpdateWhenRemovingOneTokenForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_allLabels).withTokensAfter(_label).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties()
        public virtual void ShouldGenerateUpdatesForLabelAdditionWithExistingProperties()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_label).existing(PROPERTY_KEY_ID1, Values.of("Neo")).existing(PROPERTY_KEY_ID2, Values.of(100L)).existing(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Add(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Add(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateWhenRemovingOnePropertyForNonSchemaIndex()
        public virtual void ShouldGenerateUpdateWhenRemovingOnePropertyForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).removed(_property2.propertyKeyId(), _property2.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Change(NODE_ID, _nonSchemaIndex, _values123, new Value[] { _property1.value(), null, _property3.value() })));
        }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForWhenCompletingCompositeSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForWhenCompletingCompositeSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(PROPERTY_KEY_ID1, Values.of("Neo")).added(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_index123), PropertyLoader(_property2), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLoadPropertyForNoLabelsAndButPropertyAddition()
        public virtual void ShouldNotLoadPropertyForNoLabelsAndButPropertyAddition()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).added(_property1.propertyKeyId(), _property1.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_index1), AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdatesForLabelAdditionWithNoProperties()
        public virtual void ShouldNotGenerateUpdatesForLabelAdditionWithNoProperties()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_label).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLoadPropertyForLabelsAndNoPropertyChanges()
        public virtual void ShouldNotLoadPropertyForLabelsAndNoPropertyChanges()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_index1), AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdatesForLabelRemoveAndPropertyAdd()
        public virtual void ShouldNotGenerateUpdatesForLabelRemoveAndPropertyAdd()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_empty).added(_property1.propertyKeyId(), _property1.value()).added(_property2.propertyKeyId(), _property2.value()).added(_property3.propertyKeyId(), _property3.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForMultiplePropertyAdditionWithLabels()
        public virtual void ShouldGenerateUpdatesForMultiplePropertyAdditionWithLabels()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).added(_property1.propertyKeyId(), _property1.value()).added(_property2.propertyKeyId(), _property2.value()).added(_property3.propertyKeyId(), _property3.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Add(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Add(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Add(NODE_ID, _index123, _values123)));
        }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdatesForPropertyAdditionWithNoLabels()
        public virtual void ShouldNotGenerateUpdatesForPropertyAdditionWithNoLabels()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).added(_property1.propertyKeyId(), _property1.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, AssertNoLoading(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdatesForLabelRemovalWithExistingProperties()
        public virtual void ShouldGenerateUpdatesForLabelRemovalWithExistingProperties()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_empty).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Remove(NODE_ID, _index1, _property1.value()), IndexEntryUpdate.Remove(NODE_ID, _index2, _property2.value()), IndexEntryUpdate.Remove(NODE_ID, _index3, _property3.value()), IndexEntryUpdate.Remove(NODE_ID, _index123, _values123)));
        }
Exemplo n.º 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForPartialNonSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForPartialNonSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(PROPERTY_KEY_ID1, Values.of("Neo")).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _nonSchemaIndex, _property1.value(), null, null)));
        }
Exemplo n.º 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdateForPartialCompositeSchemaIndexUpdate()
        public virtual void ShouldNotGenerateUpdateForPartialCompositeSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(PROPERTY_KEY_ID1, Values.of("Neo")).added(PROPERTY_KEY_ID3, Values.pointValue(CoordinateReferenceSystem.WGS84, 12.3, 45.6)).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_index123), PropertyLoader(), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForFullNonSchemaIndexUpdate()
        public virtual void ShouldGenerateUpdateForFullNonSchemaIndexUpdate()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).added(_property1.propertyKeyId(), _property1.value()).added(_property2.propertyKeyId(), _property2.value()).added(_property3.propertyKeyId(), _property3.value()).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _nonSchemaIndex, _values123)));
        }
Exemplo n.º 23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotGenerateUpdateWhenAddingAnotherUselessTokenForNonSchemaIndex()
        public virtual void ShouldNotGenerateUpdateWhenAddingAnotherUselessTokenForNonSchemaIndex()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(LABEL_ID1, UNUSED_LABEL_ID).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), emptyIterable());
        }
Exemplo n.º 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForLabelAdditionWithExistingProperty()
        public virtual void ShouldGenerateUpdateForLabelAdditionWithExistingProperty()
        {
            // When
            EntityUpdates updates = EntityUpdates.forEntity(NODE_ID, false).withTokens(_empty).withTokensAfter(_label).build();

            // Then
            assertThat(updates.ForIndexKeys(_indexes, PropertyLoader(_property1), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Add(NODE_ID, _index1, _property1.value())));
        }
Exemplo n.º 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateUpdateForAllChangedNonSchemaIndex()
        public virtual void ShouldGenerateUpdateForAllChangedNonSchemaIndex()
        {
            // When
            Value         newValue1 = Values.of("Nio");
            Value         newValue2 = Values.of(10L);
            Value         newValue3 = Values.pointValue(CoordinateReferenceSystem.WGS84, 32.3, 15.6);
            EntityUpdates updates   = EntityUpdates.forEntity(NODE_ID, false).withTokens(_label).withTokensAfter(_label).changed(_property1.propertyKeyId(), _property1.value(), newValue1).changed(_property2.propertyKeyId(), _property2.value(), newValue2).changed(_property3.propertyKeyId(), _property3.value(), newValue3).build();

            // Then
            assertThat(updates.ForIndexKeys(singleton(_nonSchemaIndex), PropertyLoader(_property1, _property2, _property3), EntityType.NODE), containsInAnyOrder(IndexEntryUpdate.Change(NODE_ID, _nonSchemaIndex, _values123, new Value[] { newValue1, newValue2, newValue3 })));
        }
Exemplo n.º 26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected boolean process(org.neo4j.storageengine.api.StorageRelationshipScanCursor cursor) throws FAILURE
        protected internal override bool Process(StorageRelationshipScanCursor cursor)
        {
            int reltype = cursor.Type();

            if (_propertyUpdatesVisitor != null && containsAnyEntityToken(_relationshipTypeIds, reltype))
            {
                // Notify the property update visitor
                EntityUpdates.Builder updates = EntityUpdates.forEntity(cursor.EntityReference(), true).withTokens(reltype);

                if (hasRelevantProperty(cursor, updates))
                {
                    return(_propertyUpdatesVisitor.visit(updates.Build()));
                }
            }
            return(false);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
 internal virtual EntityUpdates Add(long nodeId, int propertyKeyId, object value, long[] labels)
 {
     return(EntityUpdates.forEntity(nodeId, true).withTokens(labels).added(propertyKeyId, Values.of(value)).build());
 }