コード例 #1
0
ファイル: SchemaCache.cs プロジェクト: Neo4Net/Neo4Net
            internal virtual void AddSchemaRule(SchemaRule rule)
            {
                if (rule is ConstraintRule)
                {
                    ConstraintRule constraintRule = ( ConstraintRule )rule;
                    ConstraintRuleById.put(constraintRule.Id, constraintRule);
                    ConstraintsConflict.Add(ConstraintSemantics.readConstraint(constraintRule));
                }
                else if (rule is StoreIndexDescriptor)
                {
                    CapableIndexDescriptor index = IndexProviderMap.withCapabilities(( StoreIndexDescriptor )rule);
                    IndexDescriptorById.put(index.Id, index);
                    SchemaDescriptor schemaDescriptor = index.Schema();
                    IndexDescriptorsConflict[schemaDescriptor] = index;
                    IndexDescriptorsByName[rule.Name]          = index;
                    foreach (int entityTokenId in schemaDescriptor.EntityTokenIds)
                    {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                        ISet <CapableIndexDescriptor> forLabel = IndexDescriptorsByLabel.getIfAbsentPut(entityTokenId, HashSet <object>::new);
                        forLabel.Add(index);
                    }

                    foreach (int propertyId in index.Schema().PropertyIds)
                    {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                        IList <CapableIndexDescriptor> indexesForProperty = IndexByProperty.getIfAbsentPut(propertyId, List <object>::new);
                        indexesForProperty.Add(index);
                    }
                }
            }
コード例 #2
0
ファイル: SCRuleNodeEditor.cs プロジェクト: kabirules/Kenny
        void EmitAddConstraintWidget()
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            int buttonWidth  = 250;
            int buttonHeight = 40;

            if (GUILayout.Button(new GUIContent("Add Constraint Rule"), GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
            {
                var menuPosition = Event.current.mousePosition;
                var rect         = new Rect(menuPosition, Vector2.one);
                var menu         = new GenericMenu();

                var constraintTypes = Assembly.GetAssembly(typeof(ConstraintRule)).GetTypes()
                                      .Where(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ConstraintRule))).ToArray();

                foreach (var type in constraintTypes)
                {
                    var path = ConstraintRule.GetFullMenuPath(type);
                    menu.AddItem(new GUIContent(path), false, HandleAddConstratinMenuClick, type);
                }

                menu.DropDown(rect);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
コード例 #3
0
ファイル: IntegrityValidator.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void validateSchemaRule(org.neo4j.storageengine.api.schema.SchemaRule schemaRule) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        public virtual void ValidateSchemaRule(SchemaRule schemaRule)
        {
            if (schemaRule is ConstraintRule)
            {
                ConstraintRule constraintRule = ( ConstraintRule )schemaRule;
                if (constraintRule.ConstraintDescriptor.enforcesUniqueness())
                {
                    try
                    {
                        _indexes.validateIndex(constraintRule.OwnedIndex);
                    }
                    catch (UniquePropertyValueValidationException e)
                    {
                        throw new TransactionFailureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.TransactionValidationFailed, e, "Index validation failed");
                    }
                    catch (Exception e) when(e is IndexNotFoundKernelException || e is IndexPopulationFailedKernelException)
                    {
                        // We don't expect this to occur, and if they do, it is because we are in a very bad state - out of
                        // disk or index corruption, or similar. This will kill the database such that it can be shut down
                        // and have recovery performed. It's the safest bet to avoid loosing data.
                        throw new TransactionFailureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.TransactionValidationFailed, e, "Index population failure");
                    }
                }
            }
        }
コード例 #4
0
ファイル: IndexMap.cs プロジェクト: Neo4Net/Neo4Net
        internal void PutUniquenessConstraint(ConstraintRule rule)
        {
            IndexBackedConstraintDescriptor constraintDescriptor = ( IndexBackedConstraintDescriptor )rule.ConstraintDescriptor;

            _uniquenessConstraintsById.put(rule.Id, constraintDescriptor);
            _constraintsByLabelThenProperty.add(constraintDescriptor);
        }
コード例 #5
0
 private static DiagnosticType GetDiagnosticType(ConstraintRule rule)
 {
     return(rule switch
     {
         ConstraintRule.Permit => DiagnosticType.RedundantlyPermitted,
         ConstraintRule.Prohibit => DiagnosticType.RedundantlyProhibited,
         _ => throw new InvalidEnumArgumentException(),
     });
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnCorrectUniquenessRuleForLabelAndProperty() throws org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException, org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnCorrectUniquenessRuleForLabelAndProperty()
        {
            // Given
            CreateSchema(UniquenessConstraint(LABEL1, PROP1), UniquenessConstraint(LABEL2, PROP1));

            // When
            ConstraintRule rule = _storage.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(LabelId(LABEL1), PropId(PROP1)));

            // Then
            assertNotNull(rule);
            AssertRule(rule, LABEL1, PROP1, Org.Neo4j.@internal.Kernel.Api.schema.constraints.ConstraintDescriptor_Type.Unique);
        }
コード例 #7
0
ファイル: SCRuleNodeEditor.cs プロジェクト: kabirules/Kenny
        void DestroyConstraintRule(ConstraintRule rule)
        {
            var ruleNode    = target as SCRuleNode;
            var constraints = new List <ConstraintRule>(ruleNode.constraints);

            Undo.RegisterCompleteObjectUndo(GetOwningAsset(), "Delete Node Spatial Constraint");
            Undo.RecordObject(ruleNode, "Delete Constraint");

            constraints.Remove(rule);
            Undo.DestroyObjectImmediate(rule);

            ruleNode.constraints = constraints.ToArray();
        }
コード例 #8
0
ファイル: SchemaRecordCheck.cs プロジェクト: Neo4Net/Neo4Net
            public override void CheckConstraintRule(ConstraintRule rule, DynamicRecord record, RecordAccess records, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
            {
                outerInstance.checkSchema(rule, record, records, engine);

                if (rule.ConstraintDescriptor.enforcesUniqueness())
                {
                    DynamicRecord previousObligation = outerInstance.indexObligations[rule.OwnedIndex] = record.Clone();
                    if (previousObligation != null)
                    {
                        engine.Report().duplicateObligation(previousObligation);
                    }
                }
            }
コード例 #9
0
ファイル: SCRuleNodeEditor.cs プロジェクト: kabirules/Kenny
        void EmitConstraintScript(ConstraintRule constraint, RuleNodeEditorUIState.ConstraintUIState constraintUI)
        {
            EditorGUILayout.BeginHorizontal();

            // Draw the enabled toggle box
            constraintUI.enabled = EditorGUILayout.Toggle(constraintUI.enabled, GUILayout.Width(26));

            // Draw the fold out rule text (in bold)
            var origFontStyle = EditorStyles.label.fontStyle;

            EditorStyles.foldout.fontStyle = FontStyle.Bold;
            constraintUI.foldout           = EditorGUILayout.Foldout(constraintUI.foldout, constraint.ToString(), true);
            EditorStyles.label.fontStyle   = origFontStyle;

            // Draw the close button
            if (GUILayout.Button("x", GUILayout.Width(20)))
            {
                DestroyConstraintRule(constraint);
                constraintUI.foldout = false;
            }
            EditorGUILayout.EndHorizontal();

            if (constraintUI.foldout)
            {
                EditorGUI.indentLevel++;

                // Emit the property fields
                {
                    var csobject = new SerializedObject(constraint);
                    csobject.Update();

                    foreach (var field in constraint.GetType().GetFields())
                    {
                        if (field.GetCustomAttributes(typeof(HideInInspector), true).Length > 0)
                        {
                            // Do not show this property
                            continue;
                        }

                        SerializedProperty property = csobject.FindProperty(field.Name);
                        EditorGUILayout.PropertyField(property);
                    }

                    csobject.ApplyModifiedProperties();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
コード例 #10
0
ファイル: SCRuleNodeEditor.cs プロジェクト: kabirules/Kenny
        void AddConstraintRule(System.Type constraintType)
        {
            var constraint = CreateInstance(constraintType) as ConstraintRule;

            constraint.ruleName = ConstraintRule.GetScriptName(constraintType);

            var ruleNode       = target as SCRuleNode;
            var constraintList = new List <ConstraintRule>(ruleNode.constraints);

            constraintList.Add(constraint);
            ruleNode.constraints = constraintList.ToArray();

            // Add this constraint to the theme graph's asset file so it is serialized and not garbage collected
            AssetDatabase.AddObjectToAsset(constraint, GetAssetObject());
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void committedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CommittedConstraintRuleShouldCrossReferenceTheCorrespondingIndexRule()
        {
            // when
            SchemaWrite statement = schemaWriteInNewTransaction();

            statement.UniquePropertyConstraintCreate(Descriptor);
            commit();

            // then
            SchemaStorage        schema         = new SchemaStorage(NeoStores().SchemaStore);
            StoreIndexDescriptor indexRule      = Schema.indexGetForSchema(TestIndexDescriptorFactory.uniqueForLabel(TypeId, PropertyKeyId));
            ConstraintRule       constraintRule = Schema.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(TypeId, PropertyKeyId));

            assertEquals(constraintRule.Id, indexRule.OwningConstraint.Value);
            assertEquals(indexRule.Id, constraintRule.OwnedIndex);
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetRelatedNodeConstraints()
        public virtual void ShouldGetRelatedNodeConstraints()
        {
            // given
            ConstraintRule constraint1 = ConstraintRule.constraintRule(1L, ConstraintDescriptorFactory.uniqueForLabel(1, 5, 6), null);
            ConstraintRule constraint2 = ConstraintRule.constraintRule(2L, ConstraintDescriptorFactory.uniqueForLabel(1, 5), null);
            ConstraintRule constraint3 = ConstraintRule.constraintRule(3L, ConstraintDescriptorFactory.uniqueForLabel(2, 5), null);

            _indexMap.putUniquenessConstraint(constraint1);
            _indexMap.putUniquenessConstraint(constraint2);
            _indexMap.putUniquenessConstraint(constraint3);

            // when/then
            assertEquals(asSet(constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), false, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5, 6), true, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(), EntityTokens(1), Properties(5), false, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor, constraint3.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1, 2), EntityTokens(), Properties(), false, NODE));
        }
コード例 #13
0
ファイル: SchemaRecordCheck.cs プロジェクト: Neo4Net/Neo4Net
 public override void CheckConstraintRule(ConstraintRule rule, DynamicRecord record, RecordAccess records, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
 {
     if (rule.ConstraintDescriptor.enforcesUniqueness())
     {
         DynamicRecord obligation = outerInstance.constraintObligations[rule.Id];
         if (obligation == null)
         {
             engine.Report().missingObligation(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.ConstraintIndexRule);
         }
         else
         {
             if (obligation.Id != rule.OwnedIndex)
             {
                 engine.Report().uniquenessConstraintNotReferencingBack(obligation);
             }
         }
     }
 }
コード例 #14
0
ファイル: SchemaCacheTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListConstraintsForSchema()
        public virtual void ShouldListConstraintsForSchema()
        {
            // Given
            ConstraintRule rule1 = UniquenessConstraintRule(0, 1, 1, 0);
            ConstraintRule rule2 = UniquenessConstraintRule(1, 2, 1, 0);
            ConstraintRule rule3 = NodePropertyExistenceConstraintRule(2, 1, 2);

            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(rule1);
            cache.AddSchemaRule(rule2);
            cache.AddSchemaRule(rule3);

            // When
            ISet <ConstraintDescriptor> listed = asSet(cache.ConstraintsForSchema(rule3.Schema()));

            // Then
            assertEquals(singleton(rule3.ConstraintDescriptor), listed);
        }
コード例 #15
0
ファイル: SchemaCache.cs プロジェクト: Neo4Net/Neo4Net
            internal virtual void RemoveSchemaRule(long id)
            {
                if (ConstraintRuleById.containsKey(id))
                {
                    ConstraintRule rule = ConstraintRuleById.remove(id);
                    ConstraintsConflict.remove(rule.ConstraintDescriptor);
                }
                else if (IndexDescriptorById.containsKey(id))
                {
                    CapableIndexDescriptor index  = IndexDescriptorById.remove(id);
                    SchemaDescriptor       schema = index.Schema();
                    IndexDescriptorsConflict.Remove(schema);
                    IndexDescriptorsByName.Remove(index.Name, index);

                    foreach (int entityTokenId in Schema.EntityTokenIds)
                    {
                        ISet <CapableIndexDescriptor> forLabel = IndexDescriptorsByLabel.get(entityTokenId);

                        /* Previously, a bug made it possible to create fulltext indexes with repeated labels or relationship types
                         * which would cause us to try and remove the same entity token twice which could cause a NPE if the 'forLabel'
                         * set would be empty after the first removal such that the set would be completely removed from 'indexDescriptorsByLabel'.
                         * Fixed as of 3.5.10 */
                        if (forLabel != null)
                        {
                            forLabel.remove(index);
                            if (forLabel.Count == 0)
                            {
                                IndexDescriptorsByLabel.remove(entityTokenId);
                            }
                        }
                    }

                    foreach (int propertyId in index.Schema().PropertyIds)
                    {
                        IList <CapableIndexDescriptor> forProperty = IndexByProperty.get(propertyId);
                        forProperty.Remove(index);
                        if (forProperty.Count == 0)
                        {
                            IndexByProperty.remove(propertyId);
                        }
                    }
                }
            }
コード例 #16
0
        /// <summary>
        /// Get the constraint rule that matches the given ConstraintDescriptor </summary>
        /// <param name="descriptor"> the ConstraintDescriptor to match </param>
        /// <returns> the matching ConstrainRule </returns>
        /// <exception cref="SchemaRuleNotFoundException"> if no ConstraintRule matches the given descriptor </exception>
        /// <exception cref="DuplicateSchemaRuleException"> if two or more ConstraintRules match the given descriptor </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.impl.store.record.ConstraintRule constraintsGetSingle(final org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor descriptor) throws org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException, org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public virtual ConstraintRule ConstraintsGetSingle(ConstraintDescriptor descriptor)
        {
            IEnumerator <ConstraintRule> rules = LoadAllSchemaRules(descriptor.isSame, typeof(ConstraintRule), false);

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            if (!rules.hasNext())
            {
                throw new SchemaRuleNotFoundException(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.map(descriptor), descriptor.Schema());
            }

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ConstraintRule rule = rules.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            if (rules.hasNext())
            {
                throw new DuplicateSchemaRuleException(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.map(descriptor), descriptor.Schema());
            }
            return(rule);
        }
コード例 #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveNodeConstraints()
        public virtual void ShouldRemoveNodeConstraints()
        {
            // given
            ConstraintRule constraint1 = ConstraintRule.constraintRule(1L, ConstraintDescriptorFactory.uniqueForLabel(1, 5, 6), null);
            ConstraintRule constraint2 = ConstraintRule.constraintRule(2L, ConstraintDescriptorFactory.uniqueForLabel(1, 5), null);
            ConstraintRule constraint3 = ConstraintRule.constraintRule(3L, ConstraintDescriptorFactory.uniqueForLabel(2, 5), null);

            _indexMap.putUniquenessConstraint(constraint1);
            _indexMap.putUniquenessConstraint(constraint2);
            _indexMap.putUniquenessConstraint(constraint3);
            assertEquals(asSet(constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE));

            // and when
            _indexMap.removeUniquenessConstraint(constraint1.Id);
            _indexMap.removeUniquenessConstraint(constraint2.Id);
            _indexMap.removeUniquenessConstraint(constraint3.Id);

            // then
            assertTrue(_indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE).Count == 0);
        }
コード例 #18
0
ファイル: SchemaCacheTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListConstraintsForLabel()
        public virtual void ShouldListConstraintsForLabel()
        {
            // Given
            ConstraintRule rule1 = UniquenessConstraintRule(0, 1, 1, 0);
            ConstraintRule rule2 = UniquenessConstraintRule(1, 2, 1, 0);
            ConstraintRule rule3 = NodePropertyExistenceConstraintRule(2, 1, 2);

            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(rule1);
            cache.AddSchemaRule(rule2);
            cache.AddSchemaRule(rule3);

            // When
            ISet <ConstraintDescriptor> listed = asSet(cache.ConstraintsForLabel(1));

            // Then
            ISet <ConstraintDescriptor> expected = asSet(rule1.ConstraintDescriptor, rule3.ConstraintDescriptor);

            assertEquals(expected, listed);
        }
コード例 #19
0
ファイル: SchemaCacheTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListConstraintsForRelationshipType()
        public virtual void ShouldListConstraintsForRelationshipType()
        {
            // Given
            ConstraintRule rule1 = RelPropertyExistenceConstraintRule(0, 1, 1);
            ConstraintRule rule2 = RelPropertyExistenceConstraintRule(0, 2, 1);
            ConstraintRule rule3 = RelPropertyExistenceConstraintRule(0, 1, 2);

            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(rule1);
            cache.AddSchemaRule(rule2);
            cache.AddSchemaRule(rule3);

            // When
            ISet <ConstraintDescriptor> listed = asSet(cache.ConstraintsForRelationshipType(1));

            // Then
            ISet <ConstraintDescriptor> expected = asSet(rule1.ConstraintDescriptor, rule3.ConstraintDescriptor);

            assertEquals(expected, listed);
        }
コード例 #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldValidateUniquenessIndexes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldValidateUniquenessIndexes()
		 {
			  // Given
			  NeoStores store = mock( typeof( NeoStores ) );
			  IndexingService indexes = mock( typeof( IndexingService ) );
			  IntegrityValidator validator = new IntegrityValidator( store, indexes );
			  UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForLabel( 1, 1 );

			  doThrow( new UniquePropertyValueValidationException( constraint, ConstraintValidationException.Phase.VERIFICATION, new Exception() ) ).when(indexes).validateIndex(2L);

			  ConstraintRule record = ConstraintRule.constraintRule( 1L, constraint, 2L );

			  // When
			  try
			  {
					validator.ValidateSchemaRule( record );
					fail( "Should have thrown integrity error." );
			  }
			  catch ( Exception )
			  {
					// good
			  }
		 }
コード例 #21
0
 private void AssertRule(ConstraintRule rule, string label, string propertyKey, Org.Neo4j.@internal.Kernel.Api.schema.constraints.ConstraintDescriptor_Type type)
 {
     assertTrue(SchemaDescriptorPredicates.hasLabel(rule, LabelId(label)));
     assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(propertyKey)));
     assertEquals(type, rule.ConstraintDescriptor.type());
 }
コード例 #22
0
ファイル: SchemaCacheTest.cs プロジェクト: Neo4Net/Neo4Net
 protected internal override ConstraintDescriptor ReadNonStandardConstraint(ConstraintRule rule, string errorMessage)
 {
     if (!rule.ConstraintDescriptor.enforcesPropertyExistence())
     {
         throw new System.InvalidOperationException("Unsupported constraint type: " + rule);
     }
     return(rule.ConstraintDescriptor);
 }
コード例 #23
0
 public void RegisterRedundantlyConstrainedType(ITypeSymbol type, ConstraintRule rule)
 {
     erroneousTypes[GetDiagnosticType(rule)].Add(type);
 }
コード例 #24
0
ファイル: SchemaStoreTest.cs プロジェクト: Neo4Net/Neo4Net
 private ConstraintRule ConstraintUniqueRule(long ruleId, long ownedIndexId, int labelId, params int[] propertyIds)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyIds), ownedIndexId));
 }
コード例 #25
0
ファイル: SchemaStoreTest.cs プロジェクト: Neo4Net/Neo4Net
 private ConstraintRule ConstraintExistsRule(long ruleId, int labelId, params int[] propertyIds)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.existsForLabel(labelId, propertyIds)));
 }
コード例 #26
0
 private ConstraintRule GetUniquePropertyConstraintRule(long id, string label, string property)
 {
     return(ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.uniqueForLabel(LabelId(label), PropId(property)), 0L));
 }
コード例 #27
0
 private ConstraintRule GetRelationshipPropertyExistenceConstraintRule(long id, string type, string property)
 {
     return(ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.existsForRelType(TypeId(type), PropId(property))));
 }
コード例 #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean visitSchemaRuleCommand(Command.SchemaRuleCommand command) throws java.io.IOException
            public override bool VisitSchemaRuleCommand(Command.SchemaRuleCommand command)
            {
                SchemaRule schemaRule = command.SchemaRule;

                if (command.SchemaRule is StoreIndexDescriptor)
                {
                    StoreIndexDescriptor indexRule = ( StoreIndexDescriptor )schemaRule;
                    // Why apply index updates here? Here's the thing... this is a batch applier, which means that
                    // index updates are gathered throughout the batch and applied in the end of the batch.
                    // Assume there are some transactions creating or modifying nodes that may not be covered
                    // by an existing index, but a later transaction in the same batch creates such an index.
                    // In that scenario the index would be created, populated and then fed the [this time duplicate]
                    // update for the node created before the index. The most straight forward solution is to
                    // apply pending index updates up to this point in this batch before index schema changes occur.
                    outerInstance.applyPendingLabelAndIndexUpdates();

                    switch (command.Mode)
                    {
                    case UPDATE:
                        // Shouldn't we be more clear about that we are waiting for an index to come online here?
                        // right now we just assume that an update to index records means wait for it to be online.
                        if (indexRule.CanSupportUniqueConstraint())
                        {
                            // Register activations into the IndexActivator instead of IndexingService to avoid deadlock
                            // that could insue for applying batches of transactions where a previous transaction in the same
                            // batch acquires a low-level commit lock that prevents the very same index population to complete.
                            outerInstance.indexActivator.ActivateIndex(schemaRule.Id);
                        }
                        break;

                    case CREATE:
                        // Add to list so that all these indexes will be created in one call later
                        CreatedIndexes = CreatedIndexes == null ? new List <StoreIndexDescriptor>() : CreatedIndexes;
                        CreatedIndexes.Add(indexRule);
                        break;

                    case DELETE:
                        outerInstance.indexingService.DropIndex(indexRule);
                        outerInstance.indexActivator.IndexDropped(schemaRule.Id);
                        break;

                    default:
                        throw new System.InvalidOperationException(command.Mode.name());
                    }
                }
                // Keep IndexingService updated on constraint changes
                else if (schemaRule is ConstraintRule)
                {
                    ConstraintRule constraintRule = ( ConstraintRule )schemaRule;
                    switch (command.Mode)
                    {
                    case CREATE:
                    case UPDATE:
                        outerInstance.indexingService.PutConstraint(constraintRule);
                        break;

                    case DELETE:
                        outerInstance.indexingService.RemoveConstraint(constraintRule.Id);
                        break;

                    default:
                        throw new System.InvalidOperationException(command.Mode.name());
                    }
                }
                return(false);
            }