示例#1
0
 public static void AssertConfigMatches(IndexImplementation indexProvider, string indexName, IDictionary <string, string> storedConfig, IDictionary <string, string> suppliedConfig)
 {
     if (suppliedConfig != null && !indexProvider.ConfigMatches(storedConfig, suppliedConfig))
     {
         throw new System.ArgumentException("Supplied index configuration:\n" + suppliedConfig + "\ndoesn't match stored config in a valid way:\n" + storedConfig + "\nfor '" + indexName + "'");
     }
 }
 public override void RegisterIndexProvider(string name, IndexImplementation index)
 {
     if (_indexProviders.ContainsKey(name))
     {
         throw new System.ArgumentException("Index provider '" + name + "' already registered");
     }
     _indexProviders[name] = index;
 }
        public override IndexImplementation GetProviderByName(string name)
        {
            IndexImplementation provider = _indexProviders[name];

            if (provider == null)
            {
                throw new System.ArgumentException("No index provider '" + name + "' found. Maybe the intended provider (or one more of its " + "dependencies) " + "aren't on the classpath or it failed to load.");
            }
            return(provider);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.api.ExplicitIndex nodeChanges(String indexName) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        public override ExplicitIndex NodeChanges(string indexName)
        {
            IDictionary <string, string> configuration = _indexConfigStore.get(typeof(Node), indexName);

            if (configuration == null)
            {
                throw new ExplicitIndexNotFoundKernelException("Node index '" + indexName + " not found");
            }
            string providerName          = configuration[Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER];
            IndexImplementation provider = _providerLookup.getProviderByName(providerName);
            ExplicitIndexProviderTransaction transaction = _transactions.computeIfAbsent(providerName, k => provider.NewTransaction(this));

            return(transaction.NodeIndex(indexName, configuration));
        }
        public override bool CheckIndexExistence(IndexEntityType entityType, string indexName, IDictionary <string, string> config)
        {
            IDictionary <string, string> configuration = _indexConfigStore.get(entityType.entityClass(), indexName);

            if (configuration == null)
            {
                return(false);
            }

            string providerName          = configuration[Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER];
            IndexImplementation provider = _providerLookup.getProviderByName(providerName);

            assertConfigMatches(provider, indexName, configuration, config);
            return(true);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.api.ExplicitIndex relationshipChanges(String indexName) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        public override ExplicitIndex RelationshipChanges(string indexName)
        {
            IDictionary <string, string> configuration = _indexConfigStore.get(typeof(Relationship), indexName);

            if (configuration == null)
            {
                throw new ExplicitIndexNotFoundKernelException("Relationship index '" + indexName + " not found");
            }
            string providerName          = configuration[Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER];
            IndexImplementation provider = _providerLookup.getProviderByName(providerName);
            ExplicitIndexProviderTransaction transaction = _transactions[providerName];

            if (transaction == null)
            {
                _transactions[providerName] = transaction = provider.NewTransaction(this);
            }
            return(transaction.RelationshipIndex(indexName, configuration));
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCountAllIndexFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldCountAllIndexFiles()
        {
            // Explicit index file
            File explicitIndex = _testDirectory.databaseLayout().file("explicitIndex");

            CreateFileOfSize(explicitIndex, 1);

            IndexImplementation indexImplementation = mock(typeof(IndexImplementation));

            when(indexImplementation.GetIndexImplementationDirectory(any())).thenReturn(explicitIndex);
            when(_explicitIndexProviderLookup.allIndexProviders()).thenReturn(iterable(indexImplementation));

            // Schema index files
            File schemaIndex = _testDirectory.databaseLayout().file("schemaIndex");

            CreateFileOfSize(schemaIndex, 2);
            IndexDirectoryStructure directoryStructure = mock(typeof(IndexDirectoryStructure));

            when(directoryStructure.RootDirectory()).thenReturn(schemaIndex);
            when(_indexProvider.directoryStructure()).thenReturn(directoryStructure);

            File schemaIndex2 = _testDirectory.databaseLayout().file("schemaIndex2");

            CreateFileOfSize(schemaIndex2, 3);
            IndexDirectoryStructure directoryStructure2 = mock(typeof(IndexDirectoryStructure));

            when(directoryStructure2.RootDirectory()).thenReturn(schemaIndex2);
            when(_indexProvider2.directoryStructure()).thenReturn(directoryStructure2);

            // Label scan store
            File labelScan = _testDirectory.databaseLayout().labelScanStore();

            CreateFileOfSize(labelScan, 4);
            when(_labelScanStore.LabelScanStoreFile).thenReturn(labelScan);

            // Count all files
            assertEquals(10, _storeSizeBean.IndexStoreSize);
        }
        public override bool UnregisterIndexProvider(string name)
        {
            IndexImplementation removed = _indexProviders.Remove(name);

            return(removed != null);
        }