Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.api.index.IndexAccessor getOnlineAccessor(org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor, org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig samplingConfig) throws java.io.IOException
        public override IndexAccessor GetOnlineAccessor(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig)
        {
            SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.Create(descriptor, _config).withOperationalMode(_operationalMode).withSamplingConfig(samplingConfig).withIndexStorage(GetIndexStorage(descriptor.Id)).build();

            luceneIndex.open();
            return(new LuceneIndexAccessor(luceneIndex, descriptor));
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private LuceneIndexAccessor createAccessor(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage indexStorage) throws java.io.IOException
        private LuceneIndexAccessor CreateAccessor(PartitionedIndexStorage indexStorage)
        {
            SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.Create(_index, Config.defaults()).withIndexStorage(indexStorage).build();

            luceneIndex.open();
            return(new LuceneIndexAccessor(luceneIndex, _index));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void readOnlyIndexCreation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ReadOnlyIndexCreation()
        {
            using (SchemaIndex schemaIndex = LuceneSchemaIndexBuilder.Create(_descriptor, ReadOnlyConfig).withFileSystem(_fileSystemRule).withOperationalMode(OperationalMode.single).withIndexRootFolder(_testDir.directory("a")).build())
            {
                assertTrue(schemaIndex.ReadOnly, "Builder should construct read only index.");
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void writableIndexCreation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void WritableIndexCreation()
        {
            using (SchemaIndex schemaIndex = LuceneSchemaIndexBuilder.Create(_descriptor, DefaultConfig).withFileSystem(_fileSystemRule).withOperationalMode(OperationalMode.single).withIndexRootFolder(_testDir.directory("b")).build())
            {
                assertFalse(schemaIndex.ReadOnly, "Builder should construct writable index.");
            }
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private LuceneIndexAccessor createDefaultIndexAccessor() throws java.io.IOException
        private LuceneIndexAccessor CreateDefaultIndexAccessor()
        {
            SchemaIndex index = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(_testDir.directory("testIndex")).build();

            index.create();
            index.open();
            return(new LuceneIndexAccessor(index, _descriptor));
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            File folder = _testDir.directory("folder");

            _indexStorage     = new PartitionedIndexStorage(_directoryFactory, _fileSystemRule.get(), folder);
            _index            = LuceneSchemaIndexBuilder.create(_descriptor, Config.defaults()).withIndexStorage(_indexStorage).build();
            _schemaDescriptor = _descriptor.schema();
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp()
        internal virtual void SetUp()
        {
            File folder = _testDir.directory("folder");
            PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(_dirFactory, _fileSystem, folder);

            IndexDescriptor descriptor = IndexDescriptorFactory.forSchema(_labelSchemaDescriptor);

            _index = LuceneSchemaIndexBuilder.create(descriptor, Config.defaults()).withIndexStorage(indexStorage).build();
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setPartitionSize() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SetPartitionSize()
        {
            System.setProperty("luceneSchemaIndex.maxPartitionSize", _docsPerPartition.ToString());

            Factory <IndexWriterConfig> configFactory = new TestConfigFactory();

            _index = LuceneSchemaIndexBuilder.create(_descriptor, Config.defaults()).withFileSystem(_fileSystem).withIndexRootFolder(new File(_testDir.directory("uniquenessVerification"), "index")).withWriterConfig(configFactory).withDirectoryFactory(DirectoryFactory.PERSISTENT).build();

            _index.create();
            _index.open();
        }
Example #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private boolean indexIsOnline(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage indexStorage, org.neo4j.storageengine.api.schema.IndexDescriptor descriptor) throws java.io.IOException
        private bool IndexIsOnline(PartitionedIndexStorage indexStorage, IndexDescriptor descriptor)
        {
            using (SchemaIndex index = LuceneSchemaIndexBuilder.Create(descriptor, _config).withIndexStorage(indexStorage).build())
            {
                if (index.exists())
                {
                    index.open();
                    return(index.Online);
                }
                return(false);
            }
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void updateMultiplePartitionedIndex() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void UpdateMultiplePartitionedIndex()
        {
            using (SchemaIndex index = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(_testDir.directory("partitionedIndexForUpdates")).build())
            {
                index.create();
                index.open();
                AddDocumentToIndex(index, 45);

                index.IndexWriter.updateDocument(LuceneDocumentStructure.NewTermForChangeOrRemove(100), LuceneDocumentStructure.DocumentRepresentingProperties(( long )100, Values.intValue(100)));
                index.maybeRefreshBlocking();

                long documentsInIndex = Iterators.count(index.allDocumentsReader().GetEnumerator());
                assertEquals(46, documentsInIndex, "Index should contain 45 added and 1 updated document.");
            }
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createFailPartitionedIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void CreateFailPartitionedIndex()
        {
            using (SchemaIndex failedIndex = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(new File(_testDir.directory("failedIndexFolder"), "failedIndex")).build())
            {
                failedIndex.open();

                AddDocumentToIndex(failedIndex, 35);
                assertEquals(4, failedIndex.Partitions.size());

                failedIndex.markAsFailed("Some failure");
                failedIndex.flush();

                assertTrue(failedIndex.Open);
                assertFalse(failedIndex.Online);
            }
        }
Example #12
0
        public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory)
        {
            SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.Create(descriptor, _config).withFileSystem(_fileSystem).withOperationalMode(_operationalMode).withSamplingConfig(samplingConfig).withIndexStorage(GetIndexStorage(descriptor.Id)).withWriterConfig(IndexWriterConfigs.population).build();

            if (luceneIndex.ReadOnly)
            {
                throw new System.NotSupportedException("Can't create populator for read only index");
            }
            if (descriptor.Type() == UNIQUE)
            {
                return(new UniqueLuceneIndexPopulator(luceneIndex, descriptor));
            }
            else
            {
                return(new NonUniqueLuceneIndexPopulator(luceneIndex, samplingConfig));
            }
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void openClosePartitionedIndex() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void OpenClosePartitionedIndex()
        {
            SchemaIndex reopenIndex = null;

            try
            {
                reopenIndex = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(new File(_testDir.directory("reopenIndexFolder"), "reopenIndex")).build();
                reopenIndex.open();

                AddDocumentToIndex(reopenIndex, 1);

                reopenIndex.close();
                assertFalse(reopenIndex.Open);

                reopenIndex.open();
                assertTrue(reopenIndex.Open);

                AddDocumentToIndex(reopenIndex, 10);

                reopenIndex.close();
                assertFalse(reopenIndex.Open);

                reopenIndex.open();
                assertTrue(reopenIndex.Open);

                reopenIndex.close();
                reopenIndex.open();
                AddDocumentToIndex(reopenIndex, 100);

                reopenIndex.maybeRefreshBlocking();

                using (LuceneAllDocumentsReader allDocumentsReader = reopenIndex.allDocumentsReader())
                {
                    assertEquals(111, allDocumentsReader.MaxCount(), "All documents should be visible");
                }
            }
            finally
            {
                if (reopenIndex != null)
                {
                    reopenIndex.close();
                }
            }
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPopulateDropIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void CreatePopulateDropIndex()
        {
            File crudOperation = _testDir.directory("indexCRUDOperation");

            using (SchemaIndex crudIndex = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(new File(crudOperation, "crudIndex")).build())
            {
                crudIndex.open();

                AddDocumentToIndex(crudIndex, 1);
                assertEquals(1, crudIndex.Partitions.size());

                AddDocumentToIndex(crudIndex, 21);
                assertEquals(3, crudIndex.Partitions.size());

                crudIndex.drop();

                assertFalse(crudIndex.Open);
                assertEquals(0, crudOperation.list().length);
            }
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "{0}") public static java.util.Collection<Object[]> implementations()
        public static ICollection <object[]> Implementations()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File dir = new java.io.File("dir");
            File dir = new File("dir");

            return(Arrays.asList(Arg(_generalIndex, dirFactory1 =>
            {
                SchemaIndex index = LuceneSchemaIndexBuilder.Create(_generalIndex, _config).withFileSystem(FileSystemRule.get()).withDirectoryFactory(dirFactory1).withIndexRootFolder(new File(dir, "1")).build();

                index.create();
                index.open();
                return new LuceneIndexAccessor(index, _generalIndex);
            }), Arg(_uniqueIndex, dirFactory1 =>
            {
                SchemaIndex index = LuceneSchemaIndexBuilder.Create(_uniqueIndex, _config).withFileSystem(FileSystemRule.get()).withDirectoryFactory(dirFactory1).withIndexRootFolder(new File(dir, "testIndex")).build();

                index.create();
                index.open();
                return new LuceneIndexAccessor(index, _uniqueIndex);
            })));
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _index = LuceneSchemaIndexBuilder.create(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)), Config.defaults()).withFileSystem(Fs).withIndexRootFolder(Directory.directory()).build();
            _index.create();
            _index.open();
        }
Example #17
0
        private SchemaIndex NewSchemaIndex()
        {
            LuceneSchemaIndexBuilder builder = LuceneSchemaIndexBuilder.Create(_descriptor, Config.defaults());

            return(builder.WithIndexRootFolder(new File(_testDir.directory("index"), "testIndex")).withDirectoryFactory(_dirFactory).withFileSystem(_fs).build());
        }