//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));
        }
        // PRIVATE

        // READ INDEX

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.storageengine.api.schema.StoreIndexDescriptor readIndexRule(long id, ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private static StoreIndexDescriptor ReadIndexRule(long id, ByteBuffer source)
        {
            IndexProviderDescriptor indexProvider = ReadIndexProviderDescriptor(source);
            sbyte             indexRuleType       = source.get();
            Optional <string> name;

            switch (indexRuleType)
            {
            case GENERAL_INDEX:
            {
                SchemaDescriptor schema = ReadSchema(source);
                name = ReadRuleName(source);
                return(IndexDescriptorFactory.forSchema(schema, name, indexProvider).withId(id));
            }

            case UNIQUE_INDEX:
            {
                long             owningConstraint = source.Long;
                SchemaDescriptor schema           = ReadSchema(source);
                name = ReadRuleName(source);
                IndexDescriptor descriptor = IndexDescriptorFactory.uniqueForSchema(schema, name, indexProvider);
                return(owningConstraint == NO_OWNING_CONSTRAINT_YET?descriptor.WithId(id) : descriptor.WithIds(id, owningConstraint));
            }

            default:
                throw new MalformedSchemaRuleException(format("Got unknown index rule type '%d'.", indexRuleType));
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateIndexDescriptorsFromSchema()
        public virtual void ShouldCreateIndexDescriptorsFromSchema()
        {
            IndexDescriptor desc;

            desc = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1));
            assertThat(desc.Type(), equalTo(IndexDescriptor.Type.GENERAL));
            assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)));

            desc = IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1));
            assertThat(desc.Type(), equalTo(IndexDescriptor.Type.UNIQUE));
            assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)));
        }
Exemple #4
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));
        }
Exemple #5
0
 public static IndexDescriptor NamedUniqueForLabel(string name, int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(labelId, propertyIds), name, ProviderDescriptor));
 }
Exemple #6
0
 public static IndexDescriptor UniqueForLabel(int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(labelId, propertyIds), null, ProviderDescriptor));
 }
Exemple #7
0
 public static StoreIndexDescriptor ConstraintIndexRule(long ruleId, int labelId, int propertyId, IndexProviderDescriptor descriptor)
 {
     return(IndexDescriptorFactory.uniqueForSchema(forLabel(labelId, propertyId), descriptor).withId(ruleId));
 }
Exemple #8
0
 public virtual IndexDescriptor OwnedIndexDescriptor()
 {
     return(IndexDescriptorFactory.uniqueForSchema(_schema));
 }
Exemple #9
0
 public static IndexDescriptor ForLabel(int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(labelId, propertyIds)));
 }
 private void InitializeInstanceFields()
 {
     _index      = IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId));
     _predicate  = exact(_propertyKeyId, _value);
     _resourceId = indexEntryResourceId(_labelId, _predicate);
 }