Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updatesShouldEqualRegardlessOfCreationMethod()
        public virtual void UpdatesShouldEqualRegardlessOfCreationMethod()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Value[] singleAsArray = new Value[] { _singleValue };
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiAdd = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiAdd = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> singleRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiRemove = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
            IndexEntryUpdate <object> multiRemove = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue, singleValue);
            IndexEntryUpdate <object> singleChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue, _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);
            IndexEntryUpdate <object> multiChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), singleAsArray, singleAsArray);

            assertThat(singleAdd, equalTo(multiAdd));
            assertThat(singleRemove, equalTo(multiRemove));
            assertThat(singleChange, equalTo(multiChange));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMakeEntryConflictsForOneNode()
        public virtual void ShouldMakeEntryConflictsForOneNode()
        {
            LabelSchemaDescriptor       schema = SchemaDescriptorFactory.forLabel(LABEL_ID, 2);
            IndexEntryConflictException e      = new IndexEntryConflictException(0L, StatementConstants.NO_SUCH_NODE, Value);

            assertThat(e.EvidenceMessage(SchemaUtil.idTokenNameLookup, schema), equalTo("Node(0) already exists with label `label[1]` and property `property[2]` = 'hi'"));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMakeEntryConflicts()
        public virtual void ShouldMakeEntryConflicts()
        {
            LabelSchemaDescriptor       schema = SchemaDescriptorFactory.forLabel(LABEL_ID, 2);
            IndexEntryConflictException e      = new IndexEntryConflictException(0L, 1L, Value);

            assertThat(e.EvidenceMessage(SchemaUtil.idTokenNameLookup, schema), equalTo("Both Node(0) and Node(1) have the label `label[1]` and property `property[2]` = 'hi'"));
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPersistFulltextIndexSettings() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldPersistFulltextIndexSettings()
        {
            // Given
            File   indexFolder           = Directory.directory("indexFolder");
            string analyzerName          = "simple";
            string eventuallyConsistency = "true";
            string defaultAnalyzer       = "defaultAnalyzer";

            int[] propertyIds = new int[] { 1, 2, 3 };
            MultiTokenSchemaDescriptor schema = SchemaDescriptorFactory.multiToken(new int[] { 1, 2 }, EntityType.NODE, propertyIds);

            // A fulltext index descriptor with configurations
            Properties properties = properties(analyzerName, eventuallyConsistency);
            FulltextSchemaDescriptor fulltextSchemaDescriptor = new FulltextSchemaDescriptor(schema, properties);
            StoreIndexDescriptor     storeIndexDescriptor     = StoreIndexDescriptorFromSchema(fulltextSchemaDescriptor);
            TokenRegistry            tokenRegistry            = SimpleTokenHolder.CreatePopulatedTokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY, propertyIds);
            SimpleTokenHolder        tokenHolder             = new SimpleTokenHolder(tokenRegistry);
            FulltextIndexDescriptor  fulltextIndexDescriptor = readOrInitialiseDescriptor(storeIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(analyzerName, fulltextIndexDescriptor.AnalyzerName());
            assertEquals(bool.Parse(eventuallyConsistency), fulltextIndexDescriptor.EventuallyConsistent);

            // When persisting it
            FulltextIndexSettings.SaveFulltextIndexSettings(fulltextIndexDescriptor, indexFolder, Fs);

            // Then we should be able to load it back with settings being the same
            StoreIndexDescriptor    loadingIndexDescriptor = StoreIndexDescriptorFromSchema(schema);
            FulltextIndexDescriptor loadedDescriptor       = readOrInitialiseDescriptor(loadingIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(fulltextIndexDescriptor.AnalyzerName(), loadedDescriptor.AnalyzerName());
            assertEquals(fulltextIndexDescriptor.EventuallyConsistent, loadedDescriptor.EventuallyConsistent);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void dropShouldDeleteEntireIndexFolder()
        public virtual void DropShouldDeleteEntireIndexFolder()
        {
            // given
            File root = Storage.directory().directory("root");
            IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider(root).forProvider(GenericNativeIndexProvider.Descriptor);
            long indexId                    = 8;
            File indexDirectory             = directoryStructure.DirectoryForIndex(indexId);
            StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexId);
            IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache));
            PageCache             pageCache        = Storage.pageCache();
            FileSystemAbstraction fs               = Storage.fileSystem();
            File          indexFile                = new File(indexDirectory, "my-index");
            GenericLayout layout                   = new GenericLayout(1, spatialSettings);
            RecoveryCleanupWorkCollector immediate = immediate();
            IndexDropAction             dropAction = new FileSystemIndexDropAction(fs, directoryStructure);
            GenericNativeIndexPopulator populator  = new GenericNativeIndexPopulator(pageCache, fs, indexFile, layout, EMPTY, descriptor, spatialSettings, directoryStructure, mock(typeof(SpaceFillingCurveConfiguration)), dropAction, false);

            populator.Create();

            // when
            assertTrue(fs.ListFiles(indexDirectory).Length > 0);
            populator.Drop();

            // then
            assertFalse(fs.FileExists(indexDirectory));
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMakeCompositeEntryConflicts()
        public virtual void ShouldMakeCompositeEntryConflicts()
        {
            LabelSchemaDescriptor       schema = SchemaDescriptorFactory.forLabel(LABEL_ID, 2, 3, 4);
            ValueTuple                  values = ValueTuple.of(true, "hi", new long[] { 6L, 4L });
            IndexEntryConflictException e      = new IndexEntryConflictException(0L, 1L, values);

            assertThat(e.EvidenceMessage(SchemaUtil.idTokenNameLookup, schema), equalTo("Both Node(0) and Node(1) have the label `label[1]` " + "and properties `property[2]` = true, `property[3]` = 'hi', `property[4]` = [6, 4]"));
        }
Пример #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void createCompositeIndex(org.neo4j.graphdb.GraphDatabaseService graphDb, String label, String... properties) throws Exception
        protected internal override void CreateCompositeIndex(GraphDatabaseService graphDb, string label, params string[] properties)
        {
            GraphDatabaseAPI  @internal   = ( GraphDatabaseAPI )graphDb;
            KernelTransaction ktx         = @internal.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true);
            SchemaWrite       schemaWrite = ktx.SchemaWrite();
            TokenWrite        token       = ktx.TokenWrite();

            schemaWrite.IndexCreate(SchemaDescriptorFactory.forLabel(token.LabelGetOrCreateForName("Person"), token.PropertyKeyGetOrCreateForName("firstname"), token.PropertyKeyGetOrCreateForName("surname")));
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addShouldThrowIfAskedForChanged()
        public virtual void AddShouldThrowIfAskedForChanged()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            Thrown.expect(typeof(System.NotSupportedException));
            single.BeforeValues();
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createIndex() throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private IndexReference CreateIndex()
        {
            using (Transaction transaction = _kernel.beginTransaction(@implicit, AUTH_DISABLED))
            {
                IndexReference reference = transaction.SchemaWrite().indexCreate(SchemaDescriptorFactory.forLabel(1, 1));
                transaction.Success();
                return(reference);
            }
        }
Пример #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.storageengine.api.schema.IndexDescriptor createAnIndex(HighlyAvailableGraphDatabase db, org.neo4j.graphdb.Label label, String propertyName) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private static IndexDescriptor CreateAnIndex(HighlyAvailableGraphDatabase db, Label label, string propertyName)
        {
            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx        = KernelTransaction(db);
                int            labelId       = ktx.TokenWrite().labelGetOrCreateForName(label.Name());
                int            propertyKeyId = ktx.TokenWrite().propertyKeyGetOrCreateForName(propertyName);
                IndexReference index         = ktx.SchemaWrite().indexCreate(SchemaDescriptorFactory.forLabel(labelId, propertyKeyId));
                tx.Success();
                return(( IndexDescriptor )index);
            }
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void samplingTriggeredWhenIdsArePresent() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SamplingTriggeredWhenIdsArePresent()
        {
            // Given
            IndexSamplingManagerBean.StoreAccess storeAccess = new IndexSamplingManagerBean.StoreAccess();
            storeAccess.Registered(_dataSource);

            // When
            storeAccess.TriggerIndexSampling(EXISTING_LABEL, EXISTING_PROPERTY, false);

            // Then
            verify(_indexingService, times(1)).triggerIndexSampling(SchemaDescriptorFactory.forLabel(LABEL_ID, PROPERTY_ID), IndexSamplingMode.TRIGGER_REBUILD_UPDATED);
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexEntryUpdatesShouldBeEqual()
        public virtual void IndexEntryUpdatesShouldBeEqual()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> a = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> a = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> b = IndexEntryUpdate.add(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> b = IndexEntryUpdate.Add(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);

            assertThat(a, equalTo(b));
            assertThat(a.GetHashCode(), equalTo(b.GetHashCode()));
        }
Пример #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeShouldRetainValues()
        public virtual void RemoveShouldRetainValues()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> single = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue);
            IndexEntryUpdate <object> single = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multi = IndexEntryUpdate.remove(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4, 5), multiValue);
            IndexEntryUpdate <object> multi = IndexEntryUpdate.Remove(0, SchemaDescriptorFactory.forLabel(3, 4, 5), _multiValue);

            assertThat(single, not(equalTo(multi)));
            assertThat(single.Values(), equalTo(new object[] { _singleValue }));
            assertThat(multi.Values(), equalTo(_multiValue));
        }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void changedShouldRetainValues()
        public virtual void ChangedShouldRetainValues()
        {
            Value singleAfter = Values.of("Hello");
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> singleChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue, singleAfter);
            IndexEntryUpdate <object> singleChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue, singleAfter);

            Value[] multiAfter = new Value[] { Values.of("Hello"), Values.of("Hi") };
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: IndexEntryUpdate<?> multiChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4, 5), multiValue, multiAfter);
            IndexEntryUpdate <object> multiChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4, 5), _multiValue, multiAfter);

            assertThat(new object[] { _singleValue }, equalTo(singleChange.BeforeValues()));
            assertThat(new object[] { singleAfter }, equalTo(singleChange.Values()));
            assertThat(_multiValue, equalTo(multiChange.BeforeValues()));
            assertThat(multiAfter, equalTo(multiChange.Values()));
        }
Пример #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBePossibleToCreateIndexWithDuplicateLabel() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBePossibleToCreateIndexWithDuplicateLabel()
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.api.schema.MultiTokenSchemaDescriptor descriptor = org.neo4j.kernel.api.schema.SchemaDescriptorFactory.multiToken(new int[]{0, 0}, org.neo4j.storageengine.api.EntityType.NODE, 1);
                MultiTokenSchemaDescriptor descriptor = SchemaDescriptorFactory.multiToken(new int[] { 0, 0 }, EntityType.NODE, 1);
                schemaWrite.IndexCreate(descriptor);
                fail("Should have failed");
            }
            catch (RepeatedLabelInSchemaException)
            {
                // then good
            }
        }
Пример #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.internal.kernel.api.schema.SchemaDescriptor readMultiTokenSchema(ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private static SchemaDescriptor ReadMultiTokenSchema(ByteBuffer source)
        {
            sbyte      schemaDescriptorType = source.get();
            EntityType type;

            switch (schemaDescriptorType)
            {
            case SIMPLE_LABEL:
                type = EntityType.NODE;
                break;

            case SIMPLE_REL_TYPE:
                type = EntityType.RELATIONSHIP;
                break;

            default:
                throw new MalformedSchemaRuleException(format("Got unknown schema descriptor type '%d'.", schemaDescriptorType));
            }
            int[] entityTokenIds = ReadTokenIdList(source);
            int[] propertyIds    = ReadTokenIdList(source);
            return(SchemaDescriptorFactory.multiToken(entityTokenIds, type, propertyIds));
        }
Пример #17
0
            public virtual void TriggerIndexSampling(string labelKey, string propertyKey, bool forceSample)
            {
                int   labelKeyId    = NO_TOKEN;
                int   propertyKeyId = NO_TOKEN;
                State state         = this.State;

                if (state != null)
                {
                    labelKeyId    = state.TokenHolders.labelTokens().getIdByName(labelKey);
                    propertyKeyId = state.TokenHolders.propertyKeyTokens().getIdByName(propertyKey);
                }
                if (state == null || labelKeyId == NO_TOKEN || propertyKeyId == NO_TOKEN)
                {
                    throw new System.ArgumentException("No property or label key was found associated with " + propertyKey + " and " + labelKey);
                }
                try
                {
                    state.IndexingService.triggerIndexSampling(SchemaDescriptorFactory.forLabel(labelKeyId, propertyKeyId), GetIndexSamplingMode(forceSample));
                }
                catch (IndexNotFoundKernelException e)
                {
                    throw new System.ArgumentException(e.Message);
                }
            }
Пример #18
0
        // READ HELP

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.internal.kernel.api.schema.SchemaDescriptor readSchema(ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private static SchemaDescriptor ReadSchema(ByteBuffer source)
        {
            int[] propertyIds;
            sbyte schemaDescriptorType = source.get();

            switch (schemaDescriptorType)
            {
            case SIMPLE_LABEL:
                int labelId = source.Int;
                propertyIds = ReadTokenIdList(source);
                return(SchemaDescriptorFactory.forLabel(labelId, propertyIds));

            case SIMPLE_REL_TYPE:
                int relTypeId = source.Int;
                propertyIds = ReadTokenIdList(source);
                return(SchemaDescriptorFactory.forRelType(relTypeId, propertyIds));

            case GENERIC_MULTI_TOKEN_TYPE:
                return(ReadMultiTokenSchema(source));

            default:
                throw new MalformedSchemaRuleException(format("Got unknown schema descriptor type '%d'.", schemaDescriptorType));
            }
        }
Пример #19
0
 protected internal override LabelSchemaDescriptor LabelSchemaDescriptor(int labelId, params int[] propertyIds)
 {
     return(SchemaDescriptorFactory.forLabel(labelId, propertyIds));
 }
Пример #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadBasicEntities() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadBasicEntities()
        {
            // GIVEN
            MemoryStream @out = new MemoryStream(1_000);
            FormattedLog log  = FormattedLog.toOutputStream(@out);
            InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
            long nodeId              = 5;
            long indexNodeId         = 7;
            long nodeNotInTheIndexId = 17;
            long indexId             = 99;
            long relationshipGroupId = 10;
            long relationshipId      = 15;
            long propertyId          = 20;

            logger.Error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
            logger.Error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
            logger.Error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
            logger.Error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
            logger.Error(RecordType.INDEX, new IndexEntry(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexNodeId), idTokenNameLookup, 0), "Some index error", "Something wrong with index");
            logger.Error(RecordType.NODE, new NodeRecord(nodeNotInTheIndexId), "Some index error", IndexDescriptorFactory.forSchema(forLabel(1, 2), new IndexProviderDescriptor("key", "version")).withId(indexId).ToString());
            string text = @out.ToString();

            // WHEN
            ReportInconsistencies     inconsistencies = new ReportInconsistencies();
            InconsistencyReportReader reader          = new InconsistencyReportReader(inconsistencies);

            reader.Read(new StreamReader(new StringReader(text)));

            // THEN
            assertTrue(inconsistencies.ContainsNodeId(nodeId));
            // assertTrue( inconsistencies.containsNodeId( indexNodeId ) );
            assertTrue(inconsistencies.ContainsNodeId(nodeNotInTheIndexId));
            assertTrue(inconsistencies.ContainsRelationshipId(relationshipId));
            assertTrue(inconsistencies.ContainsRelationshipGroupId(relationshipGroupId));
            assertTrue(inconsistencies.ContainsPropertyId(propertyId));
            assertTrue(inconsistencies.ContainsSchemaIndexId(indexId));
        }
Пример #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateHighIdsOnExternalTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUpdateHighIdsOnExternalTransaction()
        {
            // GIVEN
            NeoStores neoStores = NeoStoresRule.builder().build();
            HighIdTransactionApplier tracker = new HighIdTransactionApplier(neoStores);

            // WHEN
            // Nodes
            tracker.VisitNodeCommand(Commands.CreateNode(10, 2, 3));
            tracker.VisitNodeCommand(Commands.CreateNode(20, 4, 5));

            // Relationships
            tracker.VisitRelationshipCommand(Commands.CreateRelationship(4, 10, 20, 0));
            tracker.VisitRelationshipCommand(Commands.CreateRelationship(45, 10, 20, 1));

            // Label tokens
            tracker.VisitLabelTokenCommand(Commands.CreateLabelToken(3, 0));
            tracker.VisitLabelTokenCommand(Commands.CreateLabelToken(5, 1));

            // Property tokens
            tracker.VisitPropertyKeyTokenCommand(Commands.CreatePropertyKeyToken(3, 0));
            tracker.VisitPropertyKeyTokenCommand(Commands.CreatePropertyKeyToken(5, 1));

            // Relationship type tokens
            tracker.VisitRelationshipTypeTokenCommand(Commands.CreateRelationshipTypeToken(3, 0));
            tracker.VisitRelationshipTypeTokenCommand(Commands.CreateRelationshipTypeToken(5, 1));

            // Relationship groups
            tracker.VisitRelationshipGroupCommand(Commands.CreateRelationshipGroup(10, 1));
            tracker.VisitRelationshipGroupCommand(Commands.CreateRelationshipGroup(20, 2));

            // Schema rules
            tracker.VisitSchemaRuleCommand(Commands.CreateIndexRule(EMPTY.ProviderDescriptor, 10, SchemaDescriptorFactory.forLabel(0, 1)));
            tracker.VisitSchemaRuleCommand(Commands.CreateIndexRule(EMPTY.ProviderDescriptor, 20, SchemaDescriptorFactory.forLabel(1, 2)));

            // Properties
            tracker.VisitPropertyCommand(Commands.CreateProperty(10, PropertyType.STRING, 0, 6, 7));
            tracker.VisitPropertyCommand(Commands.CreateProperty(20, PropertyType.ARRAY, 1, 8, 9));

            tracker.Close();

            // THEN
            assertEquals("NodeStore", 20 + 1, neoStores.NodeStore.HighId);
            assertEquals("DynamicNodeLabelStore", 5 + 1, neoStores.NodeStore.DynamicLabelStore.HighId);
            assertEquals("RelationshipStore", 45 + 1, neoStores.RelationshipStore.HighId);
            assertEquals("RelationshipTypeStore", 5 + 1, neoStores.RelationshipTypeTokenStore.HighId);
            assertEquals("RelationshipType NameStore", 1 + 1, neoStores.RelationshipTypeTokenStore.NameStore.HighId);
            assertEquals("PropertyKeyStore", 5 + 1, neoStores.PropertyKeyTokenStore.HighId);
            assertEquals("PropertyKey NameStore", 1 + 1, neoStores.PropertyKeyTokenStore.NameStore.HighId);
            assertEquals("LabelStore", 5 + 1, neoStores.LabelTokenStore.HighId);
            assertEquals("Label NameStore", 1 + 1, neoStores.LabelTokenStore.NameStore.HighId);
            assertEquals("PropertyStore", 20 + 1, neoStores.PropertyStore.HighId);
            assertEquals("PropertyStore DynamicStringStore", 7 + 1, neoStores.PropertyStore.StringStore.HighId);
            assertEquals("PropertyStore DynamicArrayStore", 9 + 1, neoStores.PropertyStore.ArrayStore.HighId);
            assertEquals("SchemaStore", 20 + 1, neoStores.SchemaStore.HighId);
        }
Пример #22
0
 internal override LabelSchemaDescriptor MakeDescriptor(int typeId, int propertyKeyId)
 {
     return(SchemaDescriptorFactory.forLabel(typeId, propertyKeyId));
 }
Пример #23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor createUniqueConstraint(int labelId, int pkId) throws Exception
        private ConstraintDescriptor CreateUniqueConstraint(int labelId, int pkId)
        {
            KernelTransaction ktx = ktx();

            return(ktx.SchemaWrite().uniquePropertyConstraintCreate(SchemaDescriptorFactory.forLabel(labelId, pkId)));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor createConstraint() throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private ConstraintDescriptor CreateConstraint()
        {
            using (Transaction transaction = _kernel.beginTransaction(@implicit, AUTH_DISABLED))
            {
                ConstraintDescriptor descriptor = transaction.SchemaWrite().uniquePropertyConstraintCreate(SchemaDescriptorFactory.forLabel(1, 1));
                transaction.Success();
                return(descriptor);
            }
        }
Пример #25
0
 public static IndexDescriptor UniqueForLabel(int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(labelId, propertyIds), null, ProviderDescriptor));
 }
 private void InitializeInstanceFields()
 {
     _index      = IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId));
     _predicate  = exact(_propertyKeyId, _value);
     _resourceId = indexEntryResourceId(_labelId, _predicate);
 }
Пример #27
0
 public static IndexDescriptor NamedUniqueForLabel(string name, int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(labelId, propertyIds), name, ProviderDescriptor));
 }
Пример #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createSchemaIndex(int labelId, int pkId) throws Exception
        private IndexReference CreateSchemaIndex(int labelId, int pkId)
        {
            KernelTransaction ktx = ktx();

            return(ktx.SchemaWrite().indexCreate(SchemaDescriptorFactory.forLabel(labelId, pkId)));
        }