//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); }
internal virtual bool HasRelevantProperty(CURSOR cursor, EntityUpdates.Builder updates) { if (!cursor.hasProperties()) { return(false); } bool hasRelevantProperty = false; _propertyCursor.init(cursor.propertiesReference()); while (_propertyCursor.next()) { int propertyKeyId = _propertyCursor.propertyKey(); if (_propertyKeyIdFilter.test(propertyKeyId)) { // This relationship has a property of interest to us Value value = _propertyCursor.propertyValue(); // No need to validate values before passing them to the updater since the index implementation // is allowed to fail in which ever way it wants to. The result of failure will be the same as // a failed validation, i.e. population FAILED. updates.Added(propertyKeyId, value); hasRelevantProperty = true; } } return(hasRelevantProperty); }
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()); }
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); } }
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); } }
//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); }
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); }
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); }